GCP Google Kubernetes Engine Horizontal Pod Autoscaling
Step-00: Pre-requisites¶
- Verify if GKE Cluster is created
- Verify if kubeconfig for kubectl is configured in your local terminal
Step-01: Introduction¶
- Implement a Sample Demo with Horizontal Pod Autoscaler
Step-02: Review Kubernetes Manifests¶
- Primarily review
HorizontalPodAutoscalerResource in file03-kubernetes-hpa.yaml - 01-kubernetes-deployment.yaml
- 02-kubernetes-cip-service.yaml
- 03-kubernetes-hpa.yaml
Step-03: Deploy Sample App and Verify using kubectl¶
# Deploy Sample
kubectl apply -f kube-manifests
# List Pods
kubectl get pods
Observation:
1. Currently only 1 pod is running
# List HPA
kubectl get hpa
# Run Load Test (New Terminal)
kubectl run -i --tty load-generator --rm --image=busybox --restart=Never -- /bin/sh -c "while sleep 0.01; do wget -q -O- http://myapp1-cip-service; done"
# List Pods (SCALE UP EVENT)
kubectl get pods
Observation:
1. New pods will be created to reduce the CPU spikes
# List HPA (after few mins - approx 10 mins)
kubectl get hpa
# List Pods (SCALE IN EVENT)
kubectl get pods
Observation:
1. Only 1 pod should be running
Step-04: Clean-Up¶
# Delete Load Generator Pod which is in Error State
kubectl delete pod load-generator
# Delete Sample App
kubectl delete -f kube-manifests
🎉 New Course
Ultimate DevOps Real-World Project Implementation on AWS
$15.99
$84.99
81% OFF
DEVOPS2026FEB
Enroll Now on Udemy
🎉 Offer