Composition
SQL
The following resources are composed to implement the referenced Composite Resource Definition (XRD).
DatabaseInstance
User
ProviderConfig
ProviderConfig
Database
Object
kind: Composition
apiVersion: apiextensions.crossplane.io/v1
metadata:
name: google-postgresql-official
creationTimestamp: null
labels:
db: postgresql
provider: google-official
spec:
compositeTypeRef:
apiVersion: devopstoolkitseries.com/v1alpha1
kind: SQL
patchSets:
- name: metadata
patches:
- fromFieldPath: metadata.labels
resources:
- name: sql
base:
apiVersion: sql.gcp.upbound.io/v1beta1
kind: DatabaseInstance
spec:
forProvider:
deletionProtection: false
region: us-east1
rootPasswordSecretRef:
key: password
namespace: crossplane-system
settings:
- availabilityType: REGIONAL
backupConfiguration:
- binaryLogEnabled: false
enabled: true
ipConfiguration:
- authorizedNetworks:
- name: all
value: 0.0.0.0/0
ipv4Enabled: true
tier: db-custom-1-3840
writeConnectionSecretToRef:
namespace: crossplane-system
patches:
- fromFieldPath: spec.id
toFieldPath: metadata.name
- fromFieldPath: spec.parameters.version
toFieldPath: spec.forProvider.databaseVersion
transforms:
- type: string
string:
fmt: POSTGRES_%s
- fromFieldPath: spec.parameters.size
toFieldPath: spec.settings.tier
transforms:
- type: map
map:
large: db-custom-64-245760
medium: db-custom-16-61440
small: db-custom-1-3840
- fromFieldPath: spec.id
toFieldPath: spec.writeConnectionSecretToRef.name
- fromFieldPath: spec.id
toFieldPath: spec.forProvider.rootPasswordSecretRef.name
transforms:
- type: string
string:
fmt: "%s-password"
- fromFieldPath: spec.claimRef.namespace
toFieldPath: spec.forProvider.rootPasswordSecretRef.namespace
- name: user
base:
apiVersion: sql.gcp.upbound.io/v1beta1
kind: User
spec:
forProvider:
instanceSelector:
matchControllerRef: true
passwordSecretRef:
key: password
patches:
- fromFieldPath: spec.id
toFieldPath: metadata.name
- fromFieldPath: spec.id
toFieldPath: spec.forProvider.passwordSecretRef.name
transforms:
- type: string
string:
fmt: "%s-password"
- fromFieldPath: spec.claimRef.namespace
toFieldPath: spec.forProvider.passwordSecretRef.namespace
- name: kubernetes
base:
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: ProviderConfig
spec:
credentials:
source: InjectedIdentity
patches:
- fromFieldPath: spec.id
toFieldPath: metadata.name
transforms:
- type: string
string:
fmt: "%s-sql"
readinessChecks:
- type: None
- name: sql-config
base:
apiVersion: postgresql.sql.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
name: default
spec:
credentials:
connectionSecretRef:
namespace: crossplane-system
source: PostgreSQLConnectionSecret
sslMode: require
patches:
- fromFieldPath: spec.id
toFieldPath: metadata.name
- fromFieldPath: spec.id
toFieldPath: spec.credentials.connectionSecretRef.name
- fromFieldPath: spec.claimRef.namespace
toFieldPath: spec.credentials.connectionSecretRef.namespace
readinessChecks:
- type: None
- name: sql-db
base:
apiVersion: postgresql.sql.crossplane.io/v1alpha1
kind: Database
spec:
forProvider: {}
patches:
- fromFieldPath: spec.id
toFieldPath: metadata.name
- fromFieldPath: spec.id
toFieldPath: spec.providerConfigRef.name
readinessChecks:
- type: None
- name: sql-secret
base:
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: Object
metadata:
name: sql-secret
spec:
forProvider:
manifest:
apiVersion: v1
data:
port: NTQzMg==
kind: Secret
metadata:
namespace: crossplane-system
references:
- patchesFrom:
apiVersion: sql.gcp.upbound.io/v1beta1
fieldPath: metadata.name
kind: User
namespace: crossplane-system
toFieldPath: stringData.username
- patchesFrom:
apiVersion: v1
fieldPath: data.password
kind: Secret
namespace: crossplane-system
toFieldPath: data.password
- patchesFrom:
apiVersion: v1
fieldPath: data.publicIP
kind: Secret
namespace: crossplane-system
toFieldPath: data.endpoint
patches:
- fromFieldPath: spec.id
toFieldPath: metadata.name
- fromFieldPath: spec.id
toFieldPath: spec.references[0].patchesFrom.name
- fromFieldPath: spec.id
toFieldPath: spec.references[1].patchesFrom.name
transforms:
- type: string
string:
fmt: "%s-password"
- fromFieldPath: spec.claimRef.namespace
toFieldPath: spec.references[1].patchesFrom.namespace
- fromFieldPath: spec.id
toFieldPath: spec.references[2].patchesFrom.name
- fromFieldPath: spec.id
toFieldPath: spec.forProvider.manifest.metadata.name
- fromFieldPath: spec.id
toFieldPath: spec.providerConfigRef.name
transforms:
- type: string
string:
fmt: "%s-sql"
- fromFieldPath: spec.claimRef.namespace
toFieldPath: spec.forProvider.manifest.metadata.namespace
writeConnectionSecretsToNamespace: crossplane-system