LinuxCommandLibrary

gcloud-container

Manage Google Kubernetes Engine (GKE) clusters

TLDR

Register gcloud as a Docker credential helper

$ gcloud auth configure-docker
copy

Create a cluster to run GKE containers
$ gcloud container clusters create [cluster_name]
copy

List clusters for running GKE containers
$ gcloud container clusters list
copy

Update kubeconfig to get kubectl to use a GKE cluster
$ gcloud container clusters get-credentials [cluster_name]
copy

List tag and digest metadata for a container image
$ gcloud container images list-tags [image]
copy

Describe an existing cluster for running containers
$ gcloud container clusters describe [cluster_name]
copy

SYNOPSIS

gcloud container SUBCOMMAND [--zone=ZONE] [--region=REGION] [--project=PROJECT_ID] [ GLOBAL-FLAG … ]

PARAMETERS

clusters
    Create, inspect, update, or delete GKE clusters.

get-server-config
    Fetch server-side GKE configuration and valid versions.

images
    List available node images for clusters.

node-pools
    Manage node pools within clusters.

operations
    View status of long-running GKE operations.

subnetworks
    Manage subnetworks for clusters (legacy/deprecated).

--zone
    Zone for cluster resources (e.g., us-central1-a).

--region
    Region for regional clusters.

--project
    Google Cloud project ID.

--cluster
    Name of the cluster (used in subcommands).

--quiet, -q
    Disable prompts for confirmation.

--help, -h
    Show help for the command.

DESCRIPTION

gcloud container is a command group in the Google Cloud CLI (gcloud) for interacting with Google Kubernetes Engine (GKE), Google's managed Kubernetes service.

It enables users to create, list, describe, update, and delete GKE clusters, node pools, images, and operations. Common tasks include scaling clusters, configuring autoscaling, upgrading Kubernetes versions, and viewing server configurations.

Authentication is required via gcloud auth login, and commands often specify --project, --zone, or --region for targeting resources. This tool is vital for CI/CD pipelines, infrastructure as code (e.g., with Terraform), and day-to-day cluster administration.

Subcommands handle specific aspects like cluster lifecycle (clusters), node management (node-pools), and long-running tasks (operations). It integrates seamlessly with kubectl for workload deployment.

CAVEATS

Requires installed gcloud SDK (>= 100.0.0) and gcloud auth login. Needs IAM roles like Container Admin. Rate limits apply to API calls; use --log-http for debugging.

COMMON USAGE

gcloud container clusters create my-cluster --zone us-central1-a
Creates a zonal cluster.

gcloud container clusters list
Lists all clusters in the project.

AUTHENTICATION

Run gcloud auth application-default login for service account use in scripts.

HISTORY

Part of gcloud SDK since GKE beta in 2015; evolved with Kubernetes versions, adding regional clusters (2018) and Anthos support. Tracks Google Cloud infrastructure tooling growth.

SEE ALSO

gcloud(1), kubectl(1), docker(1), crictl(1)

Copied to clipboard