GKE – Google Kubernetes Engine Guide

Step 0: Install Google Cloud SDK (gcloud)

To work with GKE, install the Google Cloud SDK and Kubernetes CLI (kubectl).

# Install kubectl
gcloud components install kubectl
  • Run gcloud auth login
  • Select your project: gcloud config set project PROJECT_ID
Step 1: Enable Required APIs
gcloud services enable \
  container.googleapis.com \
  compute.googleapis.com
Step 2: Create a GKE Cluster

Using the CLI:

gcloud container clusters create my-cluster \
  --zone=europe-west1-b \
  --machine-type=e2-medium \
  --num-nodes=3

Using the Console:

  • Go to Kubernetes Engine → Clusters
  • Click “Create” → Standard
  • Select Compute type, node pool size, autoscaling…
Step 3: Connect to the Cluster
gcloud container clusters get-credentials my-cluster \
  --zone=europe-west1-b

You can now run Kubernetes commands:

kubectl get nodes
kubectl get pods
Step 4: Deploy Your First App
kubectl create deployment hello-app \
  --image=gcr.io/google-samples/hello-app:1.0

Expose it to the internet:

kubectl expose deployment hello-app \
  --type=LoadBalancer \
  --port=80 \
  --target-port=8080

Check the external IP:

kubectl get service hello-app
Step 5: Scaling Applications
kubectl scale deployment hello-app --replicas=5
Step 6: Autoscaling Node Pools
gcloud container clusters update my-cluster \
  --enable-autoscaling \
  --min-nodes=2 \
  --max-nodes=10 \
  --zone=europe-west1-b
Step 7: GKE IAM & RBAC

Two layers manage security:

  • GCP IAM → Who can access the cluster
  • Kubernetes RBAC → What they can do inside the cluster

Add a user as a GKE admin:

gcloud projects add-iam-policy-binding PROJECT_ID \
  --member="user:[email protected]" \
  --role="roles/container.admin"

Create a Kubernetes RBAC role:

kubectl create role pod-reader \
  --verb=get --verb=list --verb=watch \
  --resource=pods -n default

Bind it to a user:

kubectl create rolebinding read-pods \
  --role=pod-reader \
  [email protected] \
  -n default
Step 8: Monitoring & Logging

GKE integrates natively with Cloud Monitoring and Cloud Logging.

  • Go to “Kubernetes Engine → Workloads → Logs”
  • Use kubectl logs for pod logs
  • Use Cloud Monitoring dashboards
Step 9: Best Practices
  • Use Autopilot for simplified operations
  • Use Workload Identity → Best for IAM-secure pods
  • Enable auto-upgrades for nodes
  • Use Ingress + Cloud Load Balancing for production services
  • Separate workloads using namespaces