This guide provides step-by-step instructions to set up a Kubernetes (K8s) playground for testing the PID HPA operator. The setup includes:
- A
kind
K8s cluster - Kafka with a
test
topic containing 24 partitions - Consumer and producer deployments
- PID HPA operator with our CRD
- VictoriaMetrics monitoring stack with Grafana
Ensure you have the following tools installed:
kind create cluster --name pidhpa --config kind-cluster.yaml
kubectl create namespace kafka
kubectl create -f 'https://strimzi.io/install/latest?namespace=kafka' -n kafka
kubectl apply -f kafka-topic.yaml -n kafka
wait until operator is ready:
kubectl apply -f https://strimzi.io/examples/latest/kafka/kraft/kafka-single-node.yaml -n kafka
kubectl exec pod/my-cluster-dual-role-0 -n kafka -it -- \
/opt/kafka/bin/kafka-topics.sh --alter --topic test --partitions 24 --bootstrap-server 0.0.0.0:9092
kubectl exec pod/my-cluster-dual-role-0 -n kafka -it -- \
/opt/kafka/bin/kafka-topics.sh --describe --topic test --bootstrap-server 0.0.0.0:9092
kubectl apply -f producer-deployment.yaml -n default
kubectl apply -f consumer-deployment.yaml -n default
Note: One consumer pod processes approximately 10 messages per second.
From the project root directory:
helm install pidhpa-operator ./helm --namespace default
kubectl apply -f pidscaler.yaml -n default
Install VictoriaMetrics monitoring stack using Helm:
helm repo add vm https://victoriametrics.github.io/helm-charts/
helm repo update
helm install vmks vm/victoria-metrics-k8s-stack -f vmstack-values.yaml -n vm --create-namespace
kubectl apply -f static-scrape.yaml -n vm
kubectl port-forward deployment.apps/kafka-producer 5000:500
python3 ingest.py
Note: The ingestion script sends approximately 50 messages per second.
kubectl get secret --namespace vm vmks-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
kubectl port-forward service/vmks-grafana 3000:80 -n vm
Now, open http://localhost:3000 in your browser and log in to Grafana using the retrieved password.
You can import the pid-hpa-test-dashboard.json
file into Grafana for monitoring.
To delete the playground environment:
kind delete cluster --name pidhpa
This guide ensures a quick and reproducible setup for testing the PID HPA operator with Kafka and VictoriaMetrics in a local Kubernetes environment.