Reputation: 13
I am trying to create CloudSQL Instance with Failover Replica using Deployment Manager.
I am able to create a Read Replica but couldn't create Failover Replica.
Can you please provide me a Deployment Manager Script or suggest me with the changes to the code below:
Thanks
Upvotes: 0
Views: 1279
Reputation: 2065
Here you have a tutorial on how to create a CloudSQL database with high availability (Master + Failover replica).
For this purpose the Deployment Manager doesn't really make a difference. I will go on how to create the database and replica with the gcloud SDK, if you want to use the console it's explained on the link I provided.
Create the database and replica from the Cloud Shell with this command:
gcloud sql instances create [MASTER INSTANCE NAME] --enable-bin-log --backup-start-time=00:01 --failover-replica-name=[FAILOVER INSTANCE NAME]
Check the rest of the options for gcloud sql instances create here. You need the flags --enable-bin-log enabled for this, and as you have binary logs you need to enable the backups. The "backup-start-time=" is in UTC time.
NOW, the main issue you are facing is that you want to modify that template to deploy a master and failover replica, but the template is deploying a FIRST GENERATION instance (see the "replicationType: SYNCHRONOUS" value), and the failover replica is limited to SECOND GENERATION instances.
The API request for what you are trying to accomplish would go something like this:
{
"name": "master-db",
"settings": {
"tier": "db-n1-standard-1",
"backupConfiguration": {
"binaryLogEnabled": true,
"startTime": "00:01",
"enabled": true
}
},
"failoverReplica": {
"name": "failover-db"
}
}
Check the sqladmin API explorer page to explore the different possible values easily. Afterwards converting the calls to a jinja template should be easy.
Upvotes: 1