wbuchwalter / Kubernetes-acs-engine-autoscaler

[Deprecated] Node-level autoscaler for Kubernetes clusters created with acs-engine.
Other
71 stars 22 forks source link

Deprecated! Use Cluster Autoscaler instead.

CircleCI

:star2: This project is a fork of OpenAI's Kubernetes-ec2-autoscaler

:warning: ACS is not supported, this autoscaler is for acs-engine only

:information_source: If you need autoscaling for VMSS, check out OpenAI/kubernetes-ec2-autoscaler:azure or cluster-autoscaler

kubernetes-acs-engine-autoscaler

kubernetes-acs-engine-autoscaler is a node-level autoscaler for Kubernetes for clusters created with acs-engine.
Kubernetes is a container orchestration framework that schedules Docker containers on a cluster, and kubernetes-acs-autoscaler can scale based on the pending job queue.

Architecture

Architecture Diagram

Setup

The autoscaler can be run anywhere as long as it can access the Azure and Kubernetes APIs, but the recommended way is to set it up as a Kubernetes Pod.

Credentials

You need to provide a Service Principal to the autoscaler and your subscription id. You can create a service principal using Azure CLI:
az ad sp create-for-rbac

You also need to provide the clientPrivateKey and caPrivateKey. You can find these values in the azuredeploy.parameters.json that you generated by acs-engine. For cluster created with acs-engine >= 0.12.0 you will also need to provide etcdClientPrivateKey and etcdServerPrivateKey.

Installing the autoscaler

The simplest way to install the autoscaler is using Helm. Fill in the values in values.yaml and then install the chart with:

helm install helm-chart

If you created your cluster with acs-engine >= 0.12.0 rbac.install need to be set to true.

NOTE: If you provided a custom deployment name when deploying the kubernetes cluster, You need to provide this value in values.yaml to acsdeployment. Otherwise, it will look for the default azuredeploy deployment.

You should then be able to inspect the pod's status and logs:

$ kubectl get pods -l app=autoscaler
NAME               READY     STATUS    RESTARTS   AGE
autoscaler-opnax   1/1       Running   0          3s

$ kubectl logs autoscaler-opnax 
2016-08-25 20:36:45,985 - autoscaler.cluster - DEBUG - Using kube service account
2016-08-25 20:36:45,987 - autoscaler.cluster - INFO - ++++++++++++++ Running Scaling Loop ++++++++++++++++
2016-08-25 20:37:04,221 - autoscaler.cluster - INFO - ++++++++++++++ Scaling Up Begins ++++++++++++++++
...

Running locally

$ docker build -t autoscaler .
$ ./devenvh.sh
#in the container
$ python main.py --resource-group k8s --service-principal-app-id 'XXXXXXXXX' --service-principal-secret 'XXXXXXXXXXXXX' service-principal-tenant-id 'XXXXXX' -vvv --kubeconfig /root/.kube/config --kubeconfig-private-key 'XXXX' --client-private-key 'XXXX'

Full List of Options

$ python main.py [options]

Windows Machine Pools

Currently node pools with Windows machines are not supported. If a Windows pool is part of the deployment the autoscaler will fail even for scaling Linux-based node pools.