Skip to content

Instantly share code, notes, and snippets.

@ruanbekker
Created February 25, 2020 10:33
Show Gist options
  • Save ruanbekker/ef6e5c5ebea3038c3ac4aed8f86ee677 to your computer and use it in GitHub Desktop.
Save ruanbekker/ef6e5c5ebea3038c3ac4aed8f86ee677 to your computer and use it in GitHub Desktop.
Pod Autoscaling with k3d Kubernetes

Pod Autoscaling with K3d

> k3d create --name "test" --publish "80:80" --api-port 6443 --workers 2
> export KUBECONFIG="$(k3d get-kubeconfig --name='test')"
> kubectl apply -f https://raw.githubusercontent.com/ruanbekker/kubernetesfiles/master/blogpost-demos/k3d-autoscaling/php-apache-cpu-intensive.yml
> kubectl apply -f https://raw.githubusercontent.com/ruanbekker/kubernetesfiles/master/blogpost-demos/k3d-autoscaling/hpa.yml
> kubectl get hpa
NAME         REFERENCE               TARGETS   MINPODS   MAXPODS   REPLICAS   AGE
php-apache   Deployment/php-apache   0%/50%    1         10        1          80s
> kubectl run --generator=run-pod/v1 -it --rm load-generator --image=busybox /bin/sh
while true; do wget -q -O- http://php-apache.default.svc.cluster.local; done
> kubectl get hpa -o wide
NAME         REFERENCE               TARGETS    MINPODS   MAXPODS   REPLICAS   AGE
php-apache   Deployment/php-apache   474%/50%   1         10        10         8m27s
> kubectl get deployment -o wide
NAME         READY   UP-TO-DATE   AVAILABLE   AGE    CONTAINERS   IMAGES                        SELECTOR
php-apache   1/10    10           1           9m9s   php-apache   ruanbekker/php-cpu-itensive   run=php-apache

stop the traffic

> kubectl get hpa -o wide
NAME         REFERENCE               TARGETS   MINPODS   MAXPODS   REPLICAS   AGE
php-apache   Deployment/php-apache   0%/50%    1         10        10         9m25s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment