Backup for GKE - Part 2 - backup & restore plan
Spencer Bischof
Product Manager, GKE
Hakim Graia
Customer Engineer
Google Kubernetes Engine (GKE) is a powerful tool for running containerized applications. But what happens if your GKE cluster crashes? Or if your application data is corrupted? Backup for GKE is a new feature that can help you protect your GKE clusters and applications.
In part two of this series, we will demonstrate how to create a backup plan for your GKE stateful workloads.
Why are Backups for GKE plans useful?
Backup plans are a useful tool for managing & maintaining GKE environments. They can be used for disaster recovery, compliance and audit, CI/CD pipelines, cloning workloads, and upgrade scenarios.
Disaster recovery: Backup plans can be used to restore GKE clusters in the event of a disaster. This can be done by restoring the cluster from a backup or by creating a new cluster from a backup.
Compliance and audit: Backup plans can be used to meet compliance and audit requirements. This can be done by storing backups in a secure location or by providing access to backups to authorized users.
CI/CD pipelines: Backup plans can be used in CI/CD pipelines to create and restore GKE clusters. This can be done by using the backup plan to create a new cluster or by using the backup plan to restore a cluster to a specific point in time.
Cloning workloads: Backup plans can be used to clone workloads. This can be done by using the backup plan to create a new cluster or by using the backup plan to restore a cluster to a specific point in time.
Upgrade scenarios: Backup plans can be used in upgrade scenarios. This can be done by using the backup plan to create a new cluster or by using the backup plan to restore a cluster to a specific point in time.
With the above in mind, let’s walk through how to set up a backup plan. The steps below take you through setting up a GKE Autopilot cluster, enabling backups, deploying an example StatefulSet and creating a backup plan.
Setting up Backup for GKE[1]
Prerequisites - In my case, I made a VPC named gke-vpc, subnet gke-vpc and an automatic subnet
Project Created - name gke-backup[2]
VPC(gke-vpc), subnet(gke-vpc) and firewall rules[3]
GKE-Autopilot Creation[4]


Enable Backups[5]




Stateful set[6]
Deploy the below statefulset yaml to your cluster.
If in terminal, run below commands:
touch statefulset.yaml
vi statefulset.yaml
copy/paste
enter :wq
kubectl create -f statefulset.yaml


Backup Plan[7]






Setting up Backup for GKE
Restore plans can be used to restore a cluster to a specific point in time, or to a specific version of GKE. This can be helpful if you need to recover from a data loss or if you need to roll back to a previous version of GKE.
Restore plans can also be used to restore a cluster to a different environment such as a different region. This can be helpful if you need to move your cluster to a new environment or if you need to follow new regulations.
Overall, GKE restore plans are a useful tool for managing clusters. They can help you to automate the process of restoring a cluster, restoring a cluster to a specific point in time or version, or restoring a cluster to a different environment.
The below takes you through setting up creating a restore plan and running it.
Creating your Restore Plan[8]


Restoring your GKE backup[9]




There you have it! You now have a backup-plan for your stateful cluster in the default namespace. Next, get started with GKE Network Policies this quick tutorial.
Reference:
[1] GKE-Backup-Concepts
[2] Project Creation
[3] VPC, Subnets and Firewall rules
[2] GKE-AutoPilot
[3] GKE-Backup-Enable
[4] GKE-Statefulset-example
[5] GKE-Backup-Planning-Backup
[6] GKE Restore Plan
[7] GKE Restore Backup