Monitoring Horizontal Pod Autoscaling in Kubernetes
Deploy Apache
1. Review Apache deployment YAML #
Inspect the YAML file ~/workshop/k3s/apache-hpa.yaml and validate the contents using the following command:
cat ~/workshop/k3s/apache-hpa.yamlThis file defines a StatefulSet with a single replica of the ghcr.io/splunk/apache-hpa image (a lightweight Apache httpd server with mod_status enabled and a small Go CGI endpoint that burns CPU on each request) and a Service exposing port 80.
Web servers like Apache are typically stateless (they do not need persistent storage), but deploying this workload as a StatefulSet gives each replica a predictable, numbered Pod name (apache-hpa-0, apache-hpa-1, and so on), making scaling easy to follow during the workshop.
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: apache-hpa
spec:
updateStrategy:
type: RollingUpdate
selector:
matchLabels:
run: apache-hpa
serviceName: "apache-hpa-svc"
replicas: 1
template:
metadata:
labels:
run: apache-hpa
spec:
containers:
- name: apache-hpa
image: ghcr.io/splunk/apache-hpa:latest
ports:
- containerPort: 80
resources:
limits:
cpu: "8"
memory: "4Mi"
requests:
cpu: "6"
memory: "2Mi"
---
apiVersion: v1
kind: Service
metadata:
name: apache-hpa-svc
labels:
run: apache-hpa
spec:
ports:
- port: 80
selector:
run: apache-hpa2. Deploy Apache #
Create an apache namespace, then deploy the Apache application to the cluster:
kubectl create namespace apache
kubectl apply -f ~/workshop/k3s/apache-hpa.yaml -n apacheVerify the StatefulSet has been created:
kubectl get statefulset -n apacheCheck the Apache web servers (OTel) Navigator and Log Observer in Splunk Observability Cloud. In Log Observer, filter by k8s.namespace.name = apache and k8s.cluster.name = <your_cluster>.
Quick check
Why are no metrics appearing in the Apache web servers (OTel) Navigator yet?
kubectl describe pod apache-hpa-0 -n apache) shows FailedScheduling: the pod requests 6 CPUs, which exceeds the available CPU on the workshop node, so it never starts and no Apache metrics are reported.
