Skip to content
Expert CloudLesson 13 of 13 3 min read

Google Kubernetes Engine (GKE)

Autopilot versus Standard clusters, how each is billed, and connecting kubectl with get-credentials.

On this page6 sections

GKE is Google Cloud's managed Kubernetes. Google runs the control plane (API server, scheduler, etcd) for you. How much of the rest you manage depends on the cluster's mode. If Kubernetes itself is new to you, the Containers & Kubernetes track covers Pods, Deployments, and Services first.

Autopilot versus Standard

AutopilotStandard
NodesGoogle provisions, scales, patches, and secures themYou create and manage node pools
BillingFor your Pods' CPU and memory requestsFor the whole VMs, used or not
LocationRegional (spread across zones)Zonal or regional
Best forMost workloadsSpecial hardware or node-level tuning

Google's documentation calls Autopilot the recommended way to use GKE. You describe workloads, and Google makes sure there is capacity for them. Because you pay for what Pods request rather than for idle nodes, right-sizing your requests directly lowers the bill.

Creating a cluster

bash
gcloud services enable container.googleapis.com

gcloud container clusters create-auto demo-cluster --location=us-central1

--location takes a region for a regional cluster (Autopilot always is) or a zone for a zonal Standard cluster. A Standard cluster is created with gcloud container clusters create instead, and you choose node counts and machine types yourself.

Connecting kubectl

bash
gcloud container clusters get-credentials demo-cluster --location=us-central1
kubectl get nodes

get-credentials writes an entry into your kubeconfig (~/.kube/config) and switches kubectl's current context to the new cluster. kubectl authenticates through the gke-gcloud-auth-plugin, which you install with gcloud components install gke-gcloud-auth-plugin if it is missing.

Running workloads securely

  • Give Pods Google Cloud access through Workload Identity Federation for GKE. It maps a Kubernetes service account to IAM, so you never mount service account keys into Pods. Autopilot clusters have it enabled by default.
  • Always set CPU and memory requests. In Autopilot they decide both scheduling and price.
  • Prefer regional clusters for production, so a single zone outage doesn't take the control plane or all your nodes with it.

Try it

Run these in the practice terminal (opens in a new tab). It opens in a new tab, so you keep your place here.
bash
gcloud container clusters create-auto demo-cluster --location=us-central1-a
gcloud container clusters create-auto demo-cluster --location=us-central1
gcloud container clusters list
gcloud container clusters get-credentials demo-cluster --location=us-central1
cat ~/.kube/config

The first command fails on purpose: Autopilot clusters are regional, so a zone is rejected.

When you're ready, hit Mark complete. That completes the Google Cloud lessons.

Further reading

Challenge

Create an Autopilot cluster named demo-cluster in the us-central1 region.

Want to experiment first? Try things in the practice terminal (opens in a new tab), then enter the command that solves the task here.

Quiz

Lock in the concepts. Score at least 80% to mark the lesson complete.

0 of 3 answered

Done with this one?

Skipped the challenge? You can mark the lesson complete by hand.

Your notes

Kept on this browser only.