GKE - Google Kubernetes Engine

GKE Deployment and Administration

Prepare the cluster for accessibility and management

When managing Google Kubernetes Engine (GKE) clusters, it’s essential to organize resources, enforce security policies, and streamline operations. By combining the kubectl CLI with Google Cloud labels and tags, you can simplify cluster navigation, auditing, and access control for optimal resource management.

Accessing a GKE cluster with kubectl

kubectl is the primary tool for interacting with Kubernetes resources—Deployments, Services, Pods, and more. To connect to your GKE cluster:

The image is a diagram illustrating how to access a Kubernetes cluster using kubectl, showing components like Deployments, Services, Pods, and Others.

Installation and configuration steps

  1. Install kubectl via the Google Cloud CLI
  2. Verify the kubectl client version
  3. Install the GKE authentication plugin
  4. Confirm the plugin installation
  5. Retrieve your cluster credentials
# 1. Install kubectl
gcloud components install kubectl

# 2. Verify the client version
kubectl version --client

# 3. Install GKE auth plugin
gcloud components install gke-gcloud-auth-plugin

# 4. Check plugin version
gke-gcloud-auth-plugin --version

# 5. Fetch cluster credentials
gcloud container clusters get-credentials CLUSTER_NAME \
  --region COMPUTE_REGION

Note

If you’re using Google Cloud Shell, both kubectl and the GKE auth plugin are pre-installed.

Organizing clusters with GKE labels

GKE labels are user-defined key–value pairs attached to clusters and node pools. Unlike Kubernetes resource labels, these labels serve metadata purposes such as billing, grouping, and cost tracking.

The image illustrates the use of GKE labels to organize clusters, showing a series of hexagonal icons with a label indicating key-value pairs.

Although cluster labels and Kubernetes pod labels are conceptually similar, they do not inherit from one another. They function independently to help you filter and manage Google Cloud resources.

The image illustrates how GKE labels can be used to organize clusters, showing examples with GKE and Kubernetes, and highlighting the use of arbitrary metadata for grouping and filtering.

Common use cases for cluster labels

The image is a diagram titled "Cluster Labels – Common Use Cases," listing various types of cluster labels such as team/cost center, component, environment or stage, state, and billing breakdown. It includes a section labeled "Guidelines" with icons and a star.

Use CaseDescriptionExample Label
Team or cost centerAssign ownership for budgeting and billingteam=research
ComponentIdentify hosted servicescomponent=ingress
Environment/stageDifferentiate deployment lifecycleenvironment=prod
StateTrack resource lifecycle statusstate=active
Billing breakdownAllocate costs across departmentsbilling=marketing

Guideline

Avoid creating high-cardinality labels (e.g., timestamp-based) to prevent label sprawl and maintain efficient resource filtering.

Controlling access with GKE tags

Google Cloud tags are another form of key–value metadata that apply across all GCP resources, including GKE clusters. By combining tags with IAM policies, you can enforce conditional access and uniform security configurations.

  • Define tags on clusters (for example, env=prod, env=dev).
  • Reference those tags in IAM policies to grant or restrict roles.
  • Maintain consistent access controls and simplify policy management.

The image is a slide titled "Tags in GKE" featuring the Google Cloud logo and icons representing security policy enforcement, access control management, and resource organization.

Watch Video

Watch video content

Previous
Demo Creating our First GKE cluster