Composition
SQL
The following resources are composed to implement the referenced Composite Resource Definition (XRD).
DatabaseInstance
ProviderConfig
Database
kind: Composition
apiVersion: apiextensions.crossplane.io/v1
metadata:
name: google-mysql
creationTimestamp: null
labels:
db: mysql
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: DatabaseInstance
spec:
forProvider:
instanceType: CLOUD_SQL_INSTANCE
region: us-east1
settings:
availabilityType: REGIONAL
backupConfiguration:
binaryLogEnabled: true
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: MYSQL_%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: "3306"
readinessChecks:
- type: MatchString
fieldPath: status.atProvider.state
matchString: RUNNABLE
- name: sql-config
base:
apiVersion: mysql.sql.crossplane.io/v1alpha1
kind: ProviderConfig
spec:
credentials:
source: MySQLConnectionSecret
patches:
- fromFieldPath: spec.id
toFieldPath: metadata.name
- fromFieldPath: spec.writeConnectionSecretToRef.name
toFieldPath: spec.credentials.connectionSecretRef.name
- fromFieldPath: spec.claimRef.namespace
toFieldPath: spec.credentials.connectionSecretRef.namespace
readinessChecks:
- type: None
- name: sql-db
base:
apiVersion: mysql.sql.crossplane.io/v1alpha1
kind: Database
metadata:
name: dot
spec: {}
patches:
- fromFieldPath: spec.id
toFieldPath: metadata.name
- fromFieldPath: spec.id
toFieldPath: spec.providerConfigRef.name
readinessChecks:
- type: None
writeConnectionSecretsToNamespace: crossplane-system