Monitoring Horizontal Pod Autoscaling in Kubernetes

Deploy Apache

2 min

1. Review Apache deployment YAML

Exercise Inspect apache-hpa.yaml

Inspect the YAML file ~/workshop/k3s/apache-hpa.yaml and validate the contents using the following command:

bash
cat ~/workshop/k3s/apache-hpa.yaml

This 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.

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

2. Deploy Apache

Exercise Create the apache namespace and deploy apache-hpa

Create an apache namespace, then deploy the Apache application to the cluster:

bash
kubectl create namespace apache
kubectl apply -f ~/workshop/k3s/apache-hpa.yaml -n apache

Verify the StatefulSet has been created:

bash
kubectl get statefulset -n apache

Check 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?

Last Modified ·

Report an issue