I am trying out Openshift Origin version 3 (using Docker and Kubernetes) and I can't find how to automate horizontal pod scaling. I know vertical scaling is automated and horizontal scaling is possible (ex: oc scale test frontend --replicas=3)
What I want is additionnal replicas (pod) being created when the application load is going up and these replicas being terminated when the load is going down.
Anyone knows how to do that?
It's not there yet - the initial work is being done in Kubernetes now (https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/proposals/autoscaling.md and https://github.com/GoogleCloudPlatform/kubernetes/pull/9612).
now horizontal auto scaling is supported from OC v 3.1
requirments: 1- need to start horizontal auto-scale HorizontalPodAutoscaler object 2- enable metrics through Heapster
the auto-scale uses CPU utilization currently to decide if the pods needs to be scaled-up or down. to create an auto-scale object we need a yaml file like the following:
apiVersion: extensions/v1beta1
kind: HorizontalPodAutoscaler
metadata:
name: frontend-scaler
spec:
scaleRef:
kind: DeploymentConfig
name: welcome-php
apiVersion: v1
subresource: scale
minReplicas: 1
maxReplicas: 10
cpuUtilization:
targetPercentage: 70
in the example above the target percentage is set to 70% CPU utilization and if the pod reaches this limit then the horizontal auto-scale will spin up a new pod. the next step is to create the object:
$ oc create -f scaler.yaml
horizontalpodautoscaler "frontend-scaler" created