Skip to content

Commit

Permalink
Merge pull request #44 from vshn/redis
Browse files Browse the repository at this point in the history
redis composition
  • Loading branch information
mweibel authored Nov 14, 2022
2 parents 94223db + 37a4180 commit 15e2709
Show file tree
Hide file tree
Showing 31 changed files with 1,505 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
- composition-objectstorage-exoscale
- composition-dbaas-postgres-exoscale
- composition-dbaas-mysql-exoscale
- composition-dbaas-redis-exoscale
defaults:
run:
working-directory: ${{ env.PACKAGE_SUBDIR }}
Expand All @@ -47,6 +48,7 @@ jobs:
- composition-objectstorage-exoscale
- composition-dbaas-postgres-exoscale
- composition-dbaas-mysql-exoscale
- composition-dbaas-redis-exoscale
defaults:
run:
working-directory: ${{ env.PACKAGE_SUBDIR }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
# Kubebuilder
/apis/generated/
/apis/**/zz_generated.deepcopy.go

# jsonnet builder
component/jsonnetfile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
= pkg.appcat.composition.dbaas.exoscale.redis

The parent key for all of the following parameters is `pkg.appcat.composition.dbaas.exoscale.redis`.

== `secretNamespaces:redis`

[horizontal]
type:: string
default:: `provider-exoscale-secrets-redis`

The namespace where the provider-exoscale stores intermediate credential `Secrets` for `Redis` resources.
The idea is to have them in their own namespace so that they don't clutter any other namespace.
In the composition the `Secrets` are being used for accessing redis databases on exoscale.com.
1 change: 1 addition & 0 deletions docs/modules/ROOT/partials/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
** xref:references/composition/dbaas/exoscale/common.adoc[Common Parameters]
** xref:references/composition/dbaas/exoscale/postgres.adoc[composition.dbaas.exoscale.postgres]
** xref:references/composition/dbaas/exoscale/mysql.adoc[composition.dbaas.exoscale.mysql]
** xref:references/composition/dbaas/exoscale/redis.adoc[composition.dbaas.exoscale.redis]
104 changes: 104 additions & 0 deletions packages/composition/dbaas/exoscale/redis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
classes:
- .common

parameters:
pkg.appcat.composition.dbaas.exoscale:
secretNamespaces:
redis: syn-provider-exoscale-secrets

appcat:
compositions:
"exoscale.redis.appcat.vshn.io":
commonPatchSets:
annotations: {}
labels: {}
commonResources:
observeClaimNamespace: {}
spec:
compositeTypeRef:
apiVersion: appcat.vshn.io/v1
kind: XExoscaleRedis
writeConnectionSecretsToNamespace: ${crossplane:namespace}
resources:

- base:
apiVersion: exoscale.crossplane.io/v1
kind: Redis
metadata: {} # patched
spec:
forProvider:
ipFilter: "" # patched
maintenance:
dayOfWeek: "" # patched
timeOfDay: "" # patched
redisSettings: {} # patched
size:
plan: "" # patched
zone: "" # patched
terminationProtection: false
writeConnectionSecretToRef:
name: "" # patched
namespace: ${pkg.appcat.composition.dbaas.exoscale:secretNamespaces:redis}
providerConfigRef:
name: exoscale-dbaas
connectionDetails:
- fromConnectionSecretKey: REDIS_HOST
type: FromConnectionSecretKey
name: REDIS_HOST
- fromConnectionSecretKey: REDIS_PORT
type: FromConnectionSecretKey
name: REDIS_PORT
- fromConnectionSecretKey: REDIS_USERNAME
type: FromConnectionSecretKey
name: REDIS_USERNAME
- fromConnectionSecretKey: REDIS_PASSWORD
type: FromConnectionSecretKey
name: REDIS_PASSWORD
- fromConnectionSecretKey: REDIS_URL
type: FromConnectionSecretKey
name: REDIS_URL
- fromConnectionSecretKey: ca.crt
type: FromConnectionSecretKey
name: ca.crt
patches:
- type: PatchSet
patchSetName: annotations
- type: PatchSet
patchSetName: labels
- type: FromCompositeFieldPath
fromFieldPath: metadata.labels[crossplane.io/composite]
toFieldPath: metadata.name
- type: FromCompositeFieldPath
fromFieldPath: metadata.labels[crossplane.io/composite]
toFieldPath: spec.writeConnectionSecretToRef.name
# Set redis settings
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.service.redisSettings
toFieldPath: spec.forProvider.redisSettings
# Set zone
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.service.zone
toFieldPath: spec.forProvider.zone
# Set IP filter
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.network.ipFilter
toFieldPath: spec.forProvider.ipFilter
# Set exoscale plan
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.size.plan
toFieldPath: spec.forProvider.size.plan
# Set maintenance day of week
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.maintenance.dayOfWeek
toFieldPath: spec.forProvider.maintenance.dayOfWeek
# Set maintenance timeOfDay
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.maintenance.timeOfDay
toFieldPath: spec.forProvider.maintenance.timeOfDay

additionalResources:
provider-exoscale-secrets-redis:
apiVersion: v1
kind: Namespace
metadata:
name: ${pkg.appcat.composition.dbaas.exoscale:secretNamespaces:redis}
9 changes: 9 additions & 0 deletions packages/tests/composition-dbaas-redis-exoscale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
classes:
- ..composition.dbaas.exoscale.redis
# composition requires provider-kubernetes as dependency
- ..provider.kubernetes

parameters:
crossplane:
# This is not resolving during "commodore package compile", so we provide it explicitly
namespace: syn-crossplane
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
annotations: {}
labels:
name: syn-provider-exoscale-secrets
name: syn-provider-exoscale-secrets
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
argocd.argoproj.io/sync-wave: '10'
labels:
name: exoscale.redis.appcat.vshn.io
name: exoscale.redis.appcat.vshn.io
spec:
compositeTypeRef:
apiVersion: appcat.vshn.io/v1
kind: XExoscaleRedis
patchSets:
- name: annotations
patches:
- fromFieldPath: metadata.annotations
toFieldPath: metadata.annotations
type: FromCompositeFieldPath
- name: labels
patches:
- fromFieldPath: metadata.labels
toFieldPath: metadata.labels
type: FromCompositeFieldPath
resources:
- base:
apiVersion: exoscale.crossplane.io/v1
kind: Redis
metadata: {}
spec:
forProvider:
ipFilter: ''
maintenance:
dayOfWeek: ''
timeOfDay: ''
redisSettings: {}
size:
plan: ''
terminationProtection: false
zone: ''
providerConfigRef:
name: exoscale-dbaas
writeConnectionSecretToRef:
name: ''
namespace: syn-provider-exoscale-secrets
connectionDetails:
- fromConnectionSecretKey: REDIS_HOST
name: REDIS_HOST
type: FromConnectionSecretKey
- fromConnectionSecretKey: REDIS_PORT
name: REDIS_PORT
type: FromConnectionSecretKey
- fromConnectionSecretKey: REDIS_USERNAME
name: REDIS_USERNAME
type: FromConnectionSecretKey
- fromConnectionSecretKey: REDIS_PASSWORD
name: REDIS_PASSWORD
type: FromConnectionSecretKey
- fromConnectionSecretKey: REDIS_URL
name: REDIS_URL
type: FromConnectionSecretKey
- fromConnectionSecretKey: ca.crt
name: ca.crt
type: FromConnectionSecretKey
patches:
- patchSetName: annotations
type: PatchSet
- patchSetName: labels
type: PatchSet
- fromFieldPath: metadata.labels[crossplane.io/composite]
toFieldPath: metadata.name
type: FromCompositeFieldPath
- fromFieldPath: metadata.labels[crossplane.io/composite]
toFieldPath: spec.writeConnectionSecretToRef.name
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.service.redisSettings
toFieldPath: spec.forProvider.redisSettings
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.service.zone
toFieldPath: spec.forProvider.zone
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.network.ipFilter
toFieldPath: spec.forProvider.ipFilter
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.size.plan
toFieldPath: spec.forProvider.size.plan
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.maintenance.dayOfWeek
toFieldPath: spec.forProvider.maintenance.dayOfWeek
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.maintenance.timeOfDay
toFieldPath: spec.forProvider.maintenance.timeOfDay
type: FromCompositeFieldPath
- base:
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: Object
spec:
forProvider:
manifest:
apiVersion: v1
kind: Namespace
metadata:
name: ''
managementPolicy: Observe
providerConfigRef:
name: kubernetes
patches:
- fromFieldPath: metadata.labels[crossplane.io/claim-namespace]
toFieldPath: spec.forProvider.manifest.metadata.name
type: FromCompositeFieldPath
- fromFieldPath: status.atProvider.manifest.metadata.labels[appuio.io/organization]
toFieldPath: metadata.labels[appuio.io/organization]
type: ToCompositeFieldPath
- fromFieldPath: metadata.labels[crossplane.io/composite]
toFieldPath: metadata.name
transforms:
- string:
fmt: '%s-ns-observer'
type: Format
type: string
type: FromCompositeFieldPath
writeConnectionSecretsToNamespace: syn-crossplane
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
spec:
ignoreDifferences:
- group: rbac.authorization.k8s.io
jsonPointers:
- /rules
kind: ClusterRole
name: crossplane
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
annotations: {}
labels:
name: syn-crossplane
name: syn-crossplane
Loading

0 comments on commit 15e2709

Please sign in to comment.