devops

Google Kubernetes Engine (GKE)

Create a cluster in GCP, connect kubectl, deploy the voting app, use LoadBalancer services


Google Kubernetes Engine runs a managed control plane in your GCP project. You attach node pools (Compute Engine VMs) that run your workloads.

You need a Google Cloud account and basic comfort with the console (and optionally Cloud Shell). GCP’s free programs and credits change over time—check Google Cloud Free Program for current terms.

GCP console / free program overview

Create a cluster

  1. Open the console → Kubernetes Engine → Create cluster.
  2. Pick a name, region/zone, and release channel (or pin a minor version). Defaults are fine for a lab.
  3. Choose node machine type and pool size for your budget; create the cluster and wait until it shows Running (often several minutes).

GKE create — Kubernetes Engine entry

Cluster name, location, and version

Additional cluster defaults in the wizard

Cluster provisioning in progress

When the green check appears, the control plane and default node pool are ready.

Connect kubectl

Use Connect in the cluster list; Cloud Shell (or your laptop with gcloud installed) will show a command like:

Terminal window
gcloud container clusters get-credentials CLUSTER_NAME --zone ZONE --project PROJECT_ID

Then:

Terminal window
kubectl get nodes

You should see your node pool nodes in Ready state. (Exact names and Kubernetes versions depend on what you selected.)

Cluster list with Connect

Deploy the sample voting app

Use the maintained manifests from Docker’s sample repo (same app as in the voting app note):

Terminal window
git clone https://github.com/dockersamples/example-voting-app.git --depth 1
cd example-voting-app/k8s-specifications

On GKE (and most clouds), exposing UIs with type: LoadBalancer is simpler than NodePort for quick tests—the cloud provisions an external IP.

Example pattern for the front-end services (adjust metadata/selector to match the YAML you actually apply):

apiVersion: v1
kind: Service
metadata:
name: vote
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
selector:
app: vote

Apply dependencies first (Redis, Postgres), then worker, then vote and result, or kubectl apply -f . if you have verified file order and compatibility.

Terminal window
kubectl apply -f .
kubectl get deployments,svc

Wait until EXTERNAL-IP is no longer <pending> for LoadBalancer-type Services.

Services &#x26; Ingress view in GKE

Test in the browser

Open the external IP for vote and result, cast votes, and confirm percentages change.

Vote UI — cats vs dogs

Results view

Cleanup

Delete the cluster (or the whole project) when finished so node pools and load balancers stop billing.