Monitoring Horizontal Pod Autoscaling in Kubernetes

Deploy Load Generator

2 min

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

Exercise Inspect and deploy the load generator

Inspect ~/workshop/k3s/loadgen.yaml:

bash
cat ~/workshop/k3s/loadgen.yaml

This manifest creates a ReplicaSet with two replicas of busybox, each sending continuous HTTP requests to apache-hpa-svc:

yaml
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:

bash
kubectl create namespace loadgen
kubectl apply -f ~/workshop/k3s/loadgen.yaml --namespace loadgen

Verify the pods are running in the loadgen namespace:

bash
kubectl get pods -n loadgen

Quick check

Which metrics in the Apache Navigator increase significantly once loadgen starts?

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.

Exercise Scale loadgen to 4 replicas

Scale the loadgen ReplicaSet to 4 replicas:

bash
kubectl scale replicaset/loadgen --replicas 4 -n loadgen

Validate the replicas are running from both the command line and Splunk Observability Cloud:

bash
kubectl get replicaset loadgen -n loadgen

ReplicaSet

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.

Last Modified ·

Report an issue