[NEW] AWS cluster autoscaler (#396)

* Enable multiple cluster autoscalers from one chart
* Allow pod annotations
* Added & documented flags
* Create service
* renamed annotations -> podAnnotations
* empty default autoscalingGroups
* Additions
- extraArgs
- replicaCount
- service.annotations
- service.externalIPs
- service.loadBalancerIP
- service.loadBalancerSourceRanges
This commit is contained in:
Michael Goodness
2017-02-10 21:13:15 -06:00
committed by GitHub
parent 9942a74686
commit 811dbeabd1
8 changed files with 282 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
+10
View File
@@ -0,0 +1,10 @@
apiVersion: v1
description: Scales worker nodes within autoscaling groups.
name: aws-cluster-autoscaler
version: 0.2.0
sources:
- https://github.com/kubernetes/contrib/tree/master/cluster-autoscaler/cloudprovider/aws
maintainers:
- name: Michael Goodness
email: mgoodness@gmail.com
engine: gotpl
+102
View File
@@ -0,0 +1,102 @@
# aws-cluster-autoscaler
[The cluster autoscaler on AWS](https://github.com/kubernetes/contrib/tree/master/cluster-autoscaler/cloudprovider/aws) scales worker nodes within an autoscaling group.
## TL;DR;
```console
$ helm install stable/aws-cluster-autoscaler
```
## Introduction
This chart bootstraps an aws-cluster-autoscaler deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
## Prerequisites
- Kubernetes 1.3+ with Beta APIs enabled
## Installing the Chart
To install the chart with the release name `my-release`:
```console
$ helm install stable/aws-cluster-autoscaler --name my-release
```
The command deploys aws-cluster-autoscaler on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.
> **Tip**: List all releases using `helm list`
## Uninstalling the Chart
To uninstall/delete the `my-release` deployment:
```console
$ helm delete my-release
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
## Configuration
The following tables lists the configurable parameters of the aws-cluster-autoscaler chart and their default values.
Parameter | Description | Default
--- | --- | ---
`autoscalingGroups[].name` | autoscaling group name | none
`autoscalingGroups[].maxSize` | maximum autoscaling group size | none
`autoscalingGroups[].minSize` | minimum autoscaling group size | none
`awsRegion` | AWS region | `us-east-1`
`image.repository` | Image | `gcr.io/google_containers/cluster-autoscaler`
`image.tag` | Image tag | `v0.4.0`
`image.pullPolicy` | Image pull policy | `IfNotPresent`
`extraArgs` | additional container arguments | `{}`
`podAnnotations` | annotations to add to each pod | {}
`replicaCount` | desired number of pods | `1`
`resources` | pod resource requests & limits | `limits: {cpu: 100m, memory: 300Mi}, requests: {cpu: 100m, memory: 300Mi}`
`scaleDownDelay` | time to wait between scaling operations | `10m` (10 minutes)
`service.annotations` | annotations to add to service | none
`service.clusterIP` | IP address to assign to service | `""`
`service.externalIPs` | service external IP addresses | `[]`
`service.loadBalancerIP` | IP address to assign to load balancer (if supported) | `""`
`service.loadBalancerSourceRanges` | list of IP CIDRs allowed access to load balancer (if supported) | `[]`
`service.servicePort` | service port to expose | `8085`
`service.type` | type of service to create | `ClusterIP`
`skipNodes.withLocalStorage` | don't terminate nodes running pods that use local storage | `false`
`skipNodes.withSystemPods` | don't terminate nodes running pods in the `kube-system` namespace | `true`
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```console
$ helm install stable/aws-cluster-autoscaler --name my-release \
--set awsRegion=us-west-1
```
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
```console
$ helm install stable/aws-cluster-autoscaler --name my-release -f values.yaml
```
> **Tip**: You can use the default [values.yaml](values.yaml)
## IAM Permissions
The worker running the cluster autoscaler will need access to certain resources and actions:
```
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup"
],
"Resource": "*"
}
]
}
```
Unfortunately AWS does not support ARNs for autoscaling groups yet so you must use "*" as the resource. More information [here](http://docs.aws.amazon.com/autoscaling/latest/userguide/IAM.html#UsingWithAutoScaling_Actions).
@@ -0,0 +1,3 @@
To verify that aws-cluster-autoscaler has started, run:
kubectl --namespace={{ .Release.Namespace }} get pods -l "app={{ template "name" . }},release={{ .Release.Name }}"
@@ -0,0 +1,16 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
@@ -0,0 +1,53 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
name: {{ template "fullname" . }}
spec:
replicas: {{ .Values.replicaCount }}
template:
metadata:
{{- if .Values.podAnnotations }}
annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
labels:
app: {{ template "name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ template "name" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
command:
- ./cluster-autoscaler
- --cloud-provider=aws
{{- range .Values.autoscalingGroups }}
- --nodes={{ .minSize }}:{{ .maxSize }}:{{ .name }}
{{- end }}
- --scale-down-delay={{ .Values.scaleDownDelay }}
- --skip-nodes-with-local-storage={{ .Values.skipNodes.withLocalStorage }}
- --skip-nodes-with-system-pods={{ .Values.skipNodes.withSystemPods }}
- --v=4
{{- range $key, $value := .Values.extraArgs }}
- --{{ $key }}={{ $value }}
{{- end }}
env:
- name: AWS_REGION
value: "{{ .Values.awsRegion }}"
ports:
- containerPort: 8085
resources:
{{ toYaml .Values.resources | indent 12 }}
volumeMounts:
- name: ssl-certs
mountPath: /etc/ssl/certs/ca-certificates.crt
readOnly: true
volumes:
- name: ssl-certs
hostPath:
path: /etc/ssl/certs/ca-certificates.crt
@@ -0,0 +1,34 @@
apiVersion: v1
kind: Service
metadata:
{{- if .Values.service.annotations }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
labels:
app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
name: {{ template "fullname" . }}
spec:
clusterIP: "{{ .Values.service.clusterIP }}"
{{- if .Values.service.externalIPs }}
externalIPs:
{{ toYaml .Values.service.externalIPs | indent 4 }}
{{- end }}
{{- if .Values.service.loadBalancerIP }}
loadBalancerIP: "{{ .Values.service.loadBalancerIP }}"
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }}
{{- end }}
ports:
- port: {{ .Values.service.servicePort }}
protocol: TCP
targetPort: 8085
selector:
app: {{ template "name" . }}
release: {{ .Release.Name }}
type: "{{ .Values.service.type }}"
+43
View File
@@ -0,0 +1,43 @@
autoscalingGroups: []
# - name: asg1
# maxSize: 1
# minSize: 1
awsRegion: us-east-1
image:
repository: gcr.io/google_containers/cluster-autoscaler
tag: v0.4.0
pullPolicy: IfNotPresent
extraArgs: []
podAnnotations: {}
replicaCount: 1
resources:
limits:
cpu: 100m
memory: 300Mi
requests:
cpu: 100m
memory: 300Mi
scaleDownDelay: 10m
service:
annotations: {}
clusterIP: ""
## List of IP addresses at which the service is available
## Ref: https://kubernetes.io/docs/user-guide/services/#external-ips
##
externalIPs: []
loadBalancerIP: ""
loadBalancerSourceRanges: []
servicePort: 8085
type: ClusterIP
skipNodes:
withLocalStorage: false
withSystemPods: true