terminal

Lab 04: Kubernetes Autoscaling

Cloud Architect Pro • Module 4.2

Instructions

info

Overview

In this lab, you will configure a Horizontal Pod Autoscaler (HPA) to automatically scale the number of pods in a replication controller, deployment, or replica set based on observed CPU utilization.

key PRE-REQUISITES

  • check_circleAccess to a GKE Cluster
  • check_circleKubectl configured for context 'lab-env'

Task 1: Deploy App

Execute the following command to deploy the sample php-apache application:

kubectl apply -f https://k8s.io/examples/application/php-apache.yaml

Task 2: Configure HPA

Now that the deployment is running, create the autoscaler using the following parameters:

Min Replicas

1

Max Replicas

10

Task 3: Test Scaling

Generate load to trigger the HPA. Open a new terminal tab and run:

kubectl run -i --tty load-generator --rm --image=busybox:1.28 --restart=Never -- /bin/sh -c "while sleep 0.01; do wget -q -O- http://php-apache; done"
terminalcloud-shell.sh
descriptionconfig.yaml
settings fullscreen

c2c-student@cloud-lab:~$ kubectl get pods

NameReadyStatusAge
php-apache-67c7b8d-abc121/1Running4m 20s

c2c-student@cloud-lab:~$ kubectl autoscale deployment php-apache --cpu-percent=50 --min=1 --max=10

horizontalpodautoscaler.autoscaling/php-apache autoscaled

c2c-student@cloud-lab:~$ |

CONNECTED: us-central1-a
Latency: 12ms
UTF-8 Ln 6, Col 1

Lab Progress

4 of 6 steps completed

smart_toy

Need a hint?