This page describes how to enable Backup for GKE.
Before you begin
Before you start, make sure you have performed the following tasks:
- Enable the Google Kubernetes Engine API. Enable Google Kubernetes Engine API
- If you want to use the Google Cloud CLI for this task,
install and then
initialize the
gcloud CLI. If you previously installed the gcloud CLI, get the latest
version by running
gcloud components update
.
Enable the Backup for GKE API
You must enable the Backup for GKE service in your project before you can set up backups and restores for any GKE clusters in that project. You can enable the Backup for GKE service by using the Google Cloud CLI or the Google Cloud console.
gcloud
To enable the Backup for GKE service, run the following command:
gcloud services enable gkebackup.googleapis.com
Console
In the Google Cloud console, enable the Backup for GKE API:
Terraform
Create an appropriate "google_project_service"
resource to
enable the gkebackup.googleapis.com
service:
resource "google_project_service" "my_service" {
project = "my_project"
service = "gkebackup.googleapis.com"
}
For more information, see google_project_service.
Enable Backup for GKE on a new cluster (optional)
When you create your first BackupPlan
or RestorePlan
for a Google Kubernetes Engine
cluster, the Backup for GKE
agent
will automatically be installed in that
cluster. However, you can also choose to install the agent during cluster
creation. This saves time since it is faster to create a cluster with the agent
installed than to create the cluster and then enable the agent.
gcloud
This option is only available for Standard Google Kubernetes Engine clusters.
To install the Backup for GKE agent, add the following parameter:
--addons=BackupRestore
to the Google Cloud CLI cluster creation command.
The following example shows how you can create a 1.24 cluster with the Backup for GKE agent installed:
gcloud container clusters create CLUSTER_NAME \
--project=PROJECT_ID \
--region=COMPUTE_REGION \
--cluster-version=1.24.2-gke.1900 \
--addons=BackupRestore
Replace the following:
CLUSTER_NAME
: the name of the cluster to back up.PROJECT_ID
: the ID of your Google Cloud project.COMPUTE_REGION
: the Compute Engine region for the cluster, for exampleus-central1
. For zonal clusters, use--zone=COMPUTE_ZONE
instead.
Console
This option is only available for Standard Google Kubernetes Engine clusters.
Perform the following tasks in the Google Cloud console:
Go to the Google Kubernetes Engine page in the Google Cloud console.
Click add_box Create.
In the Standard section, click Configure.
Specify a name and location for the cluster.
In the navigation menu, click Features page and then select the Enable Backup for GKE checkbox.
Click Create.
Terraform
Enable via a gke_backup_agent_config
entry in your
google_container_cluster
resource:
resources "google_container_cluster" "primary" {
name = "my_cluster"
...
gke_backup_agent_config {
enabled = true
}
}
For more information, see container_cluster gke_backup_agent_config
Verify that Backup for GKE is enabled on your cluster
You can verify that your cluster is using Backup for GKE with the gcloud CLI or the Google Cloud console.
gcloud
Describe the cluster:
gcloud container clusters describe CLUSTER_NAME \
--project=PROJECT_ID \
--region=COMPUTE_REGION
If Backup for GKE is enabled, the output of the command includes these lines:
addonsConfig:
gkeBackupAgentConfig:
enabled: true
Console
Perform the following tasks in the Google Cloud console:
Go to the Google Kubernetes Engine page in the Google Cloud console.
Click the name of the cluster that you want to inspect.
In the Features section, verify that Backup for GKE is Enabled.
Disable Backup for GKE on an existing cluster
You can disable Backup for GKE with the gcloud CLI or the Google Cloud console.
gcloud
When updating an existing cluster, specify the
--update-addons=BackupRestore=DISABLED
option in the gcloud CLI:
gcloud container clusters update CLUSTER_NAME \
--project=PROJECT_ID \
--region=COMPUTE_REGION \
--update-addons=BackupRestore=DISABLED
Console
Perform the following tasks in the Google Cloud console:
Go to the Google Kubernetes Engine page in the Google Cloud console.
Click the name of the cluster that you want to inspect.
In the Features section, click edit Edit for Backup & Restore.
Clear the Enable Backup for GKE checkbox.
Click Save Changes.
What's next
- Learn more about defining custom backups.
- Learn more about planning a set of backups.