Crossplane: Streamline highly available MySQL creation

Created on 20 Dec 2019  路  4Comments  路  Source: crossplane/crossplane

What problem are you facing?

I'm working on GCE and trying to create a highly available MySQL on CloudSQL. I'm aware that CloudSQL simply doesn't make it very easy to do this, but I think that Crossplane could really shine by making this user experience a lot more automated. This was discussed on Slack: https://crossplane.slack.com/archives/CEG3T90A1/p1576754003006800

How could Crossplane help solve your problem?

Currently, the suggestion on Slack to create such a setup was:

I haven't done that exactly. But I imagine the following should work: A CloudSQLInstanceClass with properties you want to have on master, create a MySQLInstance that refers to that and let it create a master CloudSQLInstance resource. Then create another CloudSQLInstance CloudSQLInstanceClass that refer to that CloudSQLInstance resource's name as master.
I know this isn't ideal. There is some work going on making this easier via introducing custom claim definitions that would enable one-to-many claim<>managed resource relation but the suggestion above should work
Oh another thing, if you don't want to do this serially, you can choose a name for your master like my-master-instance and use it in replica CloudSQLInstanceClass as master name. Then before you create MySQLInstance of master, add the following as annotation to the MySQLInstance resource "crossplane.io/external-name": "my-master-instance" . This will let you override the default naming schema. So, you can create master and replicas in parallel instead of waiting for master to be created, get name and use it in other resource class

However, if the MySQLInstance resource would have a "ha" Setting which would take care of this instead, the user experience would be a lot better.

Several suggestions were made on how to implement this:

I think the current thinking on how this will be handled is that we could have a claim that maps to multiple resources. This means you could use MySQLInstance or create your own like HAMySQLInstance that either claims an RDSInstanceClass with HA enabled or claims a set of of GCP classes that work together to provide an HA Cloud SQL instance :slightly_smiling_face:

And

I was actually thinking of a different solution where a MySQLInstance with a ha option set would claim a HACloudSQLInstanceSet or something, but I'm not a dev :wink:

enhancement services

Most helpful comment

Yes it does, this is a really nice and workable solution and way simpler than anything I suggested!

All 4 comments

I also ran into this and researched the topic a bit and as it turns out, there is a new HA type for MySQL which works similarly to what Postgres already has. I could not find anything in the documentation but the GCP console UI actually lets you create REGIONAL MySQL instances so I went looking in the logs what that API call looks like. It is exactly the same as with Postgres, you just need to set availabilityType: REGIONAL and make sure you have binlogs enabled and then it will create a HA instance for MySQL. As this field won't be filtered out it already works with the current crossplane gcp-stack:

apiVersion: database.gcp.crossplane.io/v1beta1
kind: CloudSQLInstance
metadata:
  name: ha-crossplane-1
spec:
  forProvider:
    databaseVersion: MYSQL_5_7
    region: europe-west6
    settings:
      availabilityType: REGIONAL
      tier: db-n1-standard-1
      dataDiskType: PD_SSD
      backupConfiguration:
        binaryLogEnabled: true
        enabled: true
        startTime: "00:00"
  reclaimPolicy: Delete
  providerRef:
    name: gcp-provider

@ctrox Thanks for doing the research on this! @timstoop, are you able to use this new functionality to satisfy your HA needs?

Yes it does, this is a really nice and workable solution and way simpler than anything I suggested!

That's great to hear! I'll close this issue, but let us know if you have any issues with the HA setup.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

muvaf picture muvaf  路  4Comments

turkenh picture turkenh  路  5Comments

hasheddan picture hasheddan  路  6Comments

hasheddan picture hasheddan  路  7Comments

negz picture negz  路  3Comments