Composition
SQL
The following resources are composed to implement the referenced Composite Resource Definition (XRD).
CloudSQLInstance
ProviderConfig
Database
kind: Composition
apiVersion: apiextensions.crossplane.io/v1
metadata:
name: google-postgresql
creationTimestamp: null
labels:
db: postgresql
provider: google
spec:
compositeTypeRef:
apiVersion: devopstoolkitseries.com/v1alpha1
kind: SQL
patchSets:
- name: metadata
patches:
- fromFieldPath: metadata.labels
resources:
- name: sql
base:
apiVersion: database.gcp.crossplane.io/v1beta1
kind: CloudSQLInstance
spec:
forProvider:
instanceType: CLOUD_SQL_INSTANCE
region: us-east1
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
transforms:
- type: string
string:
fmt: "%s-sql"
connectionDetails:
- fromConnectionSecretKey: username
- fromConnectionSecretKey: password
- fromConnectionSecretKey: endpoint
- name: port
type: FromValue
value: "5432"
readinessChecks:
- type: MatchString
fieldPath: status.atProvider.state
matchString: RUNNABLE
- 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
writeConnectionSecretsToNamespace: crossplane-system