Install Backup for GKE


This page describes how to install Backup for GKE on a cluster. Backup for GKE is a service for backing up and restoring workloads in Google Kubernetes Engine (GKE) clusters.

Before you begin

Before you start, make sure you have performed the following tasks:

  • Ensure that you have enabled the Google Kubernetes Engine API.
  • Enable Google Kubernetes Engine API
  • Ensure that you have installed the Google Cloud CLI.
  • Set up default Google Cloud CLI settings for your project by using one of the following methods:
    • Use gcloud init, if you want to be walked through setting project defaults.
    • Use gcloud config, to individually set your project ID, zone, and region.

    gcloud init

    1. Run gcloud init and follow the directions:

      gcloud init

      If you are using SSH on a remote server, use the --console-only flag to prevent the command from launching a browser:

      gcloud init --console-only
    2. Follow the instructions to authorize the gcloud CLI to use your Google Cloud account.
    3. Create a new configuration or select an existing one.
    4. Choose a Google Cloud project.
    5. Choose a default Compute Engine zone.
    6. Choose a default Compute Engine region.

    gcloud config

    1. Set your default project ID:
      gcloud config set project PROJECT_ID
    2. Set your default Compute Engine region (for example, us-central1):
      gcloud config set compute/region COMPUTE_REGION
    3. Set your default Compute Engine zone (for example, us-central1-c):
      gcloud config set compute/zone COMPUTE_ZONE
    4. Update gcloud to the latest version:
      gcloud components update

    By setting default locations, you can avoid errors in gcloud CLI like the following: One of [--zone, --region] must be supplied: Please specify location.

Enable the Backup for GKE API

You must enable the Backup for GKE service before you can set up backups and restores on your GKE clusters. 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:

Enable the API

Enable Backup for GKE on a new cluster

When you enable Backup for GKE on your cluster, the Backup for GKE agent is installed into your cluster. You can create a new cluster with Backup for GKE enabled by using the gcloud CLI or the Google Cloud console.

gcloud

When creating a new cluster, specify the following options in the gcloud CLI:

gcloud beta container clusters create CLUSTER_NAME \
    --project=PROJECT_ID  \
    --region=COMPUTE_REGION \
    --addons=BackupRestore \
    --workload-pool=PROJECT_ID.svc.id.goog

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 example us-central1. For zonal clusters, use --zone=COMPUTE_ZONE instead.

Console

Perform the following tasks in the Google Cloud console:

  1. Go to the Google Kubernetes Engine page in Google Cloud console.

    Go to Google Kubernetes Engine

  2. Click Create.

  3. In the Standard section, click Configure.

  4. Specify a name and location for the cluster.

  5. In the navigation menu, click Security and then select the Enable Workload Identity checkbox.

  6. In the navigation menu, click Features page and then select the Enable Backup for GKE checkbox.

  7. Click Create.

Enable Backup for GKE on an existing cluster

You can enable Backup for GKE on an existing cluster by using the gcloud CLI or the Google Cloud console.

gcloud

When updating a cluster, specify the following options in the gcloud CLI:

gcloud beta container clusters update CLUSTER_NAME \
   --project=PROJECT_ID  \
   --region=COMPUTE_REGION \
   --update-addons=BackupRestore=ENABLED

Console

Perform the following tasks in the Google Cloud console:

  1. Go to the Google Kubernetes Engine page in Google Cloud console.

    Go to Google Kubernetes Engine

  2. Click the name of the cluster that you want to update.

  3. In the Features section, click Edit for Backup for GKE.

  4. Select the Enable Backup for GKE checkbox.

  5. Click Save Changes.

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 beta 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:

  1. Go to the Google Kubernetes Engine page in Google Cloud console.

    Go to Google Kubernetes Engine

  2. Click the name of the cluster that you want to inspect.

  3. 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 beta 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:

  1. Go to the Google Kubernetes Engine page in Google Cloud console.

    Go to Google Kubernetes Engine

  2. Click the name of the cluster that you want to inspect.

  3. In the Features section, click Edit for Backup & Restore.

  4. Clear the Enable Backup for GKE checkbox.

  5. Click Save Changes.

What's next