Deploy containers (GKE, Distributed Cloud)

This page explains how to deploy a container image to a GKE cluster (on Google Cloud or Google Distributed Cloud) where Binary Authorization is enabled. The kubectl commands you use to deploy the image are the same as the ones you use to deploy images to clusters that don't use Binary Authorization.

Before you begin

Make sure you have the Binary Authorization API enabled in your project and a GKE cluster with Binary Authorization enabled. See setting up on Google Kubernetes Engine or setting up on Distributed Cloud.

Install kubectl for interacting with GKE.

Configure kubectl

You must update the local kubeconfig file for your kubectl installation. This provides the credentials and endpoint information required to access the cluster in GKE or Distributed Cloud.

To configure kubectl, run the following gcloud command:

GKE

gcloud container clusters get-credentials \
    --zone ZONE \
    CLUSTER_NAME

Replace the following:

  • ZONE: the name of the GKE zone where the cluster is running, for example, us-central1-a
  • CLUSTER_NAME: the name of the cluster

Distributed Cloud

gcloud container fleet memberships get-credentials \
    --location LOCATION \
    MEMBERSHIP_NAME

Replace the following:

  • LOCATION: the location of the fleet membership of the GKE cluster, for example, global
  • MEMBERSHIP_NAME: the name of the fleet membership of the GKE cluster

Deploy the container image

Deploy your container image as follows:

  1. Configure environment variables:

    POD_NAME=POD_NAME
    IMAGE_PATH=IMAGE_PATH
    IMAGE_DIGEST=IMAGE_DIGEST
    

    Replace the following:

    • POD_NAME: the name you want to use for the GKE workload
    • IMAGE_PATH: path of the image in Artifact Registry, or another registry.
    • IMAGE_DIGEST: the digest of the image manifest. Example is as follows:

      • Artifact Registry:
        • Path: us-docker.pkg.dev/google-samples/containers/gke/hello-app
        • Digest: sha256:37e5287945774f27b418ce567cd77f4bbc9ef44a1bcd1a2312369f31f9cce567

      To learn how to get the digest of an image in Artifact Registry, see Managing images.

  2. Deploy your image using the kubectl run command.