How to Use Kubernetes for Autoscaling

Kubernetes and Autoscaling to The Rescue

Setting Up the HPA

apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: testingHPA
spec:
scaleTargetRef:
apiVersion: apps/v1beta1
kind: Deployment
name: awesome_app
minReplicas: 3
maxReplicas: 5
targetCPUUtilizationPercentage: 85
kubectl get hpa -n testing-ns

Detour: Resources — Limits and Requests

name: container1
image: busybox
resources:
requests:
memory: “32Mi”
cpu: “200m”
limits:
memory: “64Mi”
cpu: “250m”

Back to Our Problem

resources:
limits:
cpu: 2000m
requests:
cpu: 1000m
kubectl get hpa -n testing-ns

Time to Test

kubectl get deployment -n testing-ns
docker run --rm loadimpact/loadgentest-wrk -c 600 -t 600 -d 15m https://fun-service.test.com/fun_index=7
kubectl get deployment -n testing-ns

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store