This repository contains a version of the Kubernetes Cluster AutoScaler component that works with AutoScalr to reduce the cost of running your k8s cluster by 50%-75% by changing one yaml file.
If you have a working kubernetes/autoscaler deployment all you have to do enable AutoScalr and start saving money is to update 3 items in your existing yaml file:
- container image to: autoscalr/k8s_autoscalr
- cloud-provider to: autoscalr
- set desired parameter(s) in env section of yaml file
To illustrate, here are the changes in diff format required to the 1 ASG example yaml provided here
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: cluster-autoscaler
namespace: kube-system
labels:
app: cluster-autoscaler
spec:
replicas: 1
selector:
matchLabels:
app: cluster-autoscaler
template:
metadata:
labels:
app: cluster-autoscaler
spec:
containers:
- - image: gcr.io/google_containers/cluster-autoscaler:v0.6.0
+ - image: autoscalr/k8s_autoscalr:v0.3.1
name: cluster-autoscaler
resources:
limits:
cpu: 100m
memory: 300Mi
requests:
cpu: 100m
memory: 300Mi
command:
- ./cluster-autoscaler
- --v=4
- --stderrthreshold=info
- - --cloud-provider=aws
+ - --cloud-provider=autoscalr
- --skip-nodes-with-local-storage=false
- --nodes=1:10:k8s-worker-asg-1
env:
- name: AWS_REGION
value: us-east-1
+ - name: AUTOSCALR_API_KEY
+ value: myApiKeyFromAutoScalr
+ - name: DISPLAY_NAME
+ value: nameToDisplayInUI
+ - name: INSTANCE_TYPES
+ value: m4.large,c4.large,r4.large
+ - name: MAX_SPOT_PERCENT_TOTAL
+ value: 90
+ - name: MAX_SPOT_PERCENT_ONE_MARKET
+ value: 20
volumeMounts:
- name: ssl-certs
mountPath: /etc/ssl/certs/ca-certificates.crt
readOnly: true
imagePullPolicy: "Always"
volumes:
- name: ssl-certs
hostPath:
path: "/etc/ssl/certs/ca-certificates.crt"
If have an AutoScalr account, you can login at autoscalr.com to get your api key.
If you do not have an AutoScalr account, you can signup for a free 14 day trial here.
The following environment variables are supported:
AWS_REGION
- (Required) AWS Region the k8s cluster is running inAUTOSCALR_API_KEY
- (Required) The api key provided by AutoScalr when you signupDISPLAY_NAME
- (Required) Short name to be used in AutoScalr web UI displayINSTANCE_TYPES
- (Required) Comma delimited list of instance types to useMAX_HOURS_INSTANCE_AGE
- (Optional, Default: off) When set, AutoScalr will schedule instance replacement if an instance's age exceeds this settingMAX_SPOT_PERCENT_TOTAL
- (Optional, Default: 80) Maximum percentage of capacity to allow in Spot instancesMAX_SPOT_PERCENT_ONE_MARKET
- (Optional, Default: 20) Maximum percentage of capacity to allow in a single Spot marketOS_FAMILY
- (Optional, Default: Linux/UNIX) Options: Linux/Unix, SUSE Linux, WindowsTARGET_SPARE_CPU_PERCENT
- (Optional, Default: 20) Target spare cpu percentage to scale to, e.g. 20% spare capacity = 80% cpu utilizationTARGET_SPARE_MEMORY_PERCENT
- (Optional, Default: 20) Target spare memory percentage to scale to, e.g. 20% spare capacity = 80% memory utilization
The referenced image is built against Kubernetes 1.10, and has been tested against 1.7, 1.8, and 1.9.
For use with other versions, a rebuild of the image from source may be required.
Contact us if you need assistance with another version.
or via chat interface on website: www.autoscalr.com