Monitoring Horizontal Pod Autoscaling in Kubernetes
Deploy Load Generator
Now let’s apply load against the apache-hpa pod. To do this, you will start a separate Pod to act as a client, running an infinite loop of HTTP GET requests to the apache-hpa-svc Service.
1. Review loadgen YAML #
Inspect ~/workshop/k3s/loadgen.yaml:
cat ~/workshop/k3s/loadgen.yamlThis manifest creates a ReplicaSet with two replicas of busybox, each sending continuous HTTP requests to apache-hpa-svc:
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: loadgen
labels:
app: loadgen
spec:
replicas: 2
selector:
matchLabels:
app: loadgen
template:
metadata:
name: loadgen
labels:
app: loadgen
spec:
containers:
- name: infinite-calls
image: busybox
command:
- /bin/sh
- -c
- "while true; do wget -q -O- http://apache-hpa-svc.apache.svc.cluster.local; done"Create a loadgen namespace and deploy the load generator:
kubectl create namespace loadgen
kubectl apply -f ~/workshop/k3s/loadgen.yaml --namespace loadgenVerify the pods are running in the loadgen namespace:
kubectl get pods -n loadgenQuick check
Which metrics in the Apache Navigator increase significantly once loadgen starts?
GET / request triggers the CPU-burn CGI handler in apache-hpa, driving up request throughput, busy workers, and container CPU usage.2. Scale the load generator #
A ReplicaSet maintains a specified number of identical Pod replicas at all times. It creates new Pods if one fails, scales up when you increase the desired count, and scales down when you reduce it.
Scale the loadgen ReplicaSet to 4 replicas:
kubectl scale replicaset/loadgen --replicas 4 -n loadgenValidate the replicas are running from both the command line and Splunk Observability Cloud:
kubectl get replicaset loadgen -n loadgen
Let the load generator run for 2–3 minutes and observe the impact on CPU and request metrics in the Kubernetes Navigator and Apache Navigator.
