Building an XR
Infrastructure API requirement
Compliance policyprovisioning should be done inus-centralregionArchitecture policyshould support 2 tiers of the databaseSmalldisk size 20 GBBigdisk size 40 GB
Archtecture policy:Smalltier's VM should bedb-g1-smallBigtier's VM should bedb-n1-standard-1
Product teamoption to choose betweenPostgresandMySQLProduct teamshould specify the size in the XR with 2 enums (SMALLorBIG)Platform teamPatch the zone in which the database is created back into theXR/claimstatus field for monitoring requirements
Creating the XRD
Api Group:alpha-beta.imarunrk.comXRname:XGCPdbClaimname:GCPdbAPIversion:v1sizeas input parameterzoneas response status attribute
ESTABLISHED and OFFERED flags in the screenshot are True
This means that the XRD is created correctly
If these statuses are not True, use kubectl to describe the details of the XRD and look for an error
Providing implementation
Provide an API implementation (provide composition configuration)
Polymorphic behavior - will create 2 compositions one for Postgres and MySQL
The following are the steps to remember when we build the composition YAML:
Refer to the v1 XRD API version with the CompositeTypeRef configuration.
Define the CloudSQLInstance configuration under the resource base.
Hardcode the region to us-central1 to meet the compliance requirement.
The database tier and disk size will hold default values, but the patch configuration will overlay them using the FromCompositeFieldPath patch type.
Use the Map transformation to convert the SMALL tier size to the db-g1-small machine tier. Use the Map and Convert transformations to map the SMALL tier size to the 20 GB disk size.
Similar mapping will be done for the BIG configuration.
Patch the GceZone attribute from the MR status to the XR/claim for monitoring. We can achieve this using the ToCompositeFieldPath patch type.
Provide a mapping between the MR connection secret key to the XR/claim keys with the ConnectionDetails configuration.
Postgres Composition
MySQL Composition
Provisioning the resources with a claim
With help of compositions we can provision GCP database with an XR or a claim
Claims are namespace resources, will provision it in
alphanamespace
MySQL claim

The debugging order will be claim, then XR, and then each composing resource. We should start with a claimed object.
If we cannot locate the issue, we go deep into the XR and then the composing resources.
spec.resourceReffrom the claim description can help us to identify the XR name.Again, the same attribute can be used to find the composing resources from the XR.
Cleanup
Last updated