Kubernetes Autoscaling Containers Kubernetes Autoscaling Containers kubernetes kubernetes

Kubernetes Autoscaling Containers


Autoscaling of containers is not yet supported and is not part of the near term 1.0 roadmap for Kubernetes (meaning that the core team isn't going to add it soon but external contributions are certainly welcome).


You can use horizontal pod auto-scaling in kubernetes 1.3 onwards. kubernetes blog provides detailed information on the functionality.

http://blog.kubernetes.io/2016/07/autoscaling-in-kubernetes.html

but the above article mainly focus on GKE. so the below would be more informative.

https://kubernetes.io/docs/user-guide/horizontal-pod-autoscaling/

how to use kubectl for pod autoscaling is described here.

 kubectl autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu-percent=CPU] [flags]

Examples

# Auto scale a deployment "foo", with the number of pods between 2 and 10, target CPU utilization specified so a default autoscaling policy will be used:  kubectl autoscale deployment foo --min=2 --max=10  # Auto scale a replication controller "foo", with the number of pods between 1 and 5, target CPU utilization at 80%:  kubectl autoscale rc foo --max=5 --cpu-percent=80


Since Kubernetes 1.2 autoscaling is part of the stable API. It's done based on CPU usage or based on metrics provided from the container itself.

It can be used for deployments or replication controllers like this:

# Auto scale a deployment "foo", with the number of pods between 2 and 10, target CPU utilization specified so a default autoscaling policy will be used:kubectl autoscale deployment foo --min=2 --max=10# Auto scale a replication controller "foo", with the number of pods between 1 and 5, target CPU utilization at 80%:kubectl autoscale rc foo --max=5 --cpu-percent=80

Further details can be found in the official documentation within the Horizontal scaling description, in the kubectl autoscale documentation and within the official blog.