Cluster autoscaling
Course: Kubernetes Part 3 (Scaling) - chapter 8
Ref - https://github.com/kubernetes/autoscaler
Cluster Autoscaler - a component that automatically adjusts the size of a Kubernetes Cluster so that all pods have a place to run and there are no unneeded nodes. Supports several public cloud providers. Version 1.0 (GA) was released with kubernetes 1.8.
Underprovisioned resources
Section titled “Underprovisioned resources”In the last slide, we saw that we didn’t have enough resources to schedule a pod on.

Let’s make our node pool dynamic and add a min and max nodes.

Restart the deployment
Section titled “Restart the deployment”kubectl delete deployment cpu-deploymentkubectl apply -f deployment.ymlNotice a new node gets deployed

Logs of the cluster autoscaler
Section titled “Logs of the cluster autoscaler”kubectl get pods -n kube-system | grep cluster-autoscaler

Try downscaling
Section titled “Try downscaling”apiVersion: apps/v1kind: Deploymentmetadata: name: cpu-deploymentspec: replicas: 10 selector: matchLabels: app: cpu-app template: metadata: labels: app: cpu-app spec: containers: - name: cpu-app image: 100xdevs/week-28:latest ports: - containerPort: 3000 resources: limits: cpu: "1000m" requests: cpu: "1000m"Notice the number of server goes down to 2 again
Good things to learn after this -
Section titled “Good things to learn after this -”- Gitops (ArgoCD)
- Custom metrics based scaling, event based autoscaling - https://www.giffgaff.io/tech/event-driven-autoscaling
- Deploying prometheus in a k8s cluster, scaling based on custom metrics from prometheus