Course contentsShow
← Cloud and Infrastructure
Lesson 1481 of 2,98930. Managed Kubernetes ServicesFree lesson

GKE Workload Identity

Configuring Workload Identity to securely connect Kubernetes service accounts to Google Cloud IAM service accounts.

GKE Workload Identity

What you'll learn: How to securely link Kubernetes service accounts to Google Cloud IAM service accounts using Workload Identity.

The Core Concept

GKE Workload Identity is Google's recommended way to let your pods access Google Cloud services securely. Instead of storing JSON key files in your cluster (which is risky), Workload Identity creates a trust relationship between a Kubernetes service account and a Google Cloud IAM service account.

Think of it like a diplomatic passport: your pod presents its Kubernetes service account credentials at the border, and Google Cloud recognizes it as having the authority of a specific IAM service account with certain permissions.

How It Works

When Workload Identity is enabled on your GKE cluster, pods can automatically obtain short-lived tokens from Google's metadata server. These tokens authenticate the pod as the linked IAM service account, granting access to Google Cloud APIs like Cloud Storage, BigQuery, or Pub/Sub.

The binding is explicit: you must annotate the Kubernetes service account and create an IAM policy binding. This two-way connection ensures security—neither side grants access by default.

Configuration Steps

  1. Enable Workload Identity on your GKE cluster (at creation or update)
  2. Create an IAM service account in Google Cloud with necessary permissions
  3. Create a Kubernetes service account in your namespace
  4. Bind them together using IAM policy and annotation
  5. Deploy pods that use the annotated Kubernetes service account

This approach eliminates credential files, provides automatic token rotation, and follows the principle of least privilege.

Key Takeaway: GKE Workload Identity securely connects Kubernetes service accounts to Google Cloud IAM service accounts without storing static credentials, providing automatic, short-lived access tokens for pods to interact with Google Cloud services.