Building an XR

  • Infrastructure API requirement

    • Compliance policy provisioning should be done in us-central region

    • Architecture policy should support 2 tiers of the database

      • Small disk size 20 GB

      • Big disk size 40 GB

    • Archtecture policy:

      • Small tier's VM should be db-g1-small

      • Big tier's VM should be db-n1-standard-1

    • Product team option to choose between Postgres and MySQL

    • Product team should specify the size in the XR with 2 enums (SMALL or BIG)

    • Platform team Patch the zone in which the database is created back into the XR/claim status field for monitoring requirements

Creating the XRD

  • Api Group: alpha-beta.imarunrk.com

  • XR name: XGCPdb

  • Claim name: GCPdb

  • API version: v1

  • size as input parameter

  • zone as 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 alpha namespace

MySQL claim

img.png
  • 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.resourceRef from 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