How To Enable/Disable ETCD Backup Using Qbert API

Problem

You would like to enable/disable ETCD backup on an existing cluster using Qbert API.

Environment

  • Platform9 Managed Kubernetes - All versions

  • Qbert

  • ETCD

Procedure

  1. Obtain a token for authentication purposes. Keystone Identity API: This link describes the process for getting a Keystone authentication token in order to access the PMK REST APIs.

TOK=$(openstack token issue -f value -c id)
  1. Run the following command to query the current ETCD Backup configuration.

curl -skX GET https://<DU_FQDN>/qbert/v4/<projectID>/clusters/<clusterUUID> --header "X-Auth-Token: $TOK" | jq .etcdBackup
{
"isEtcdBackupEnabled": 0,
"intervalInMins": 0,
"storageType": "",
"storageProperties": null,
"taskStatus": "",
"taskErrorDetail": ""
}
  1. Configure the ETCD Backup by running the following command.

curl -skX PUT -i https://<DU_FQDN>/qbert/v4/<projectID>/clusters/<clusterUUID> --header "X-Auth-Token: $TOK" --header "Content-Type: application/json" --data '{"etcdBackup": {"isEtcdBackupEnabled": "1", "intervalInMins": "1440", "storageType": "local", "storageProperties": {"localPath": "/etc/pf9/etcd-backup"}}}'
HTTP/1.1 200 OK
Server: nginx/1.18.0
Date: Thu, 08 Jul 2021 01:21:32 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 2
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: X-Subject-Token
X-Frame-Options: DENY
X-XSS-Protection: 1
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=3600
# kubectl get cronjob -n kube-system
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
etcd-backup */1440 * * * * False 0 <none> 16s
Info

Please configure the intervalInMins, storageType, and localPath properties as per your requirement.

  1. Validate if the ETCD Backup properties were updated in the Qbert DB.

curl -skX GET https://<DU_FQDN>/qbert/v4/<projectID>/clusters/<clusterUUID> --header "X-Auth-Token: $TOK" | jq .etcdBackup
{
"isEtcdBackupEnabled": 1,
"intervalInMins": 1440,
"storageType": "local",
"storageProperties": {
"localPath": "/etc/pf9/etcd-backup"
},
"taskStatus": "success",
"taskErrorDetail": ""
}
Success

ETCD backup has been successfully enabled on your cluster.

  1. Disable the ETCD Backup by running the following command.

curl -skX PUT -i https://<DU_FQDN>/qbert/v4/<projectID>/clusters/<clusterUUID> --header "X-Auth-Token: $TOK" --header "Content-Type: application/json" --data '{"etcdBackup": {"isEtcdBackupEnabled": "0","intervalInMins": "0", "storageType": "", "storageProperties": {"localPath": ""}}}'
  1. Validate if the ETCD Backup properties were updated in the Qbert DB.

curl -skX GET https://<DU_FQDN>/qbert/v4/<projectID>/clusters/<clusterUUID> --header "X-Auth-Token: $TOK" | jq .etcdBackup
{
"isEtcdBackupEnabled": 0,
"intervalInMins": 0,
"storageType": "",
"storageProperties": {
"localPath": ""
},
"taskStatus": "success",
"taskErrorDetail": ""
}
# kubectl get cronjob -n kube-system
No resources found in kube-system namespace.
Success

ETCD backup has been successfully disabled on the cluster.