From 811dbeabd15a3e378905b7a6a227e17dfeb99882 Mon Sep 17 00:00:00 2001 From: Michael Goodness Date: Fri, 10 Feb 2017 21:13:15 -0600 Subject: [PATCH] [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 --- stable/aws-cluster-autoscaler/.helmignore | 21 ++++ stable/aws-cluster-autoscaler/Chart.yaml | 10 ++ stable/aws-cluster-autoscaler/README.md | 102 ++++++++++++++++++ .../templates/NOTES.txt | 3 + .../templates/_helpers.tpl | 16 +++ .../templates/deployment.yaml | 53 +++++++++ .../templates/service.yaml | 34 ++++++ stable/aws-cluster-autoscaler/values.yaml | 43 ++++++++ 8 files changed, 282 insertions(+) create mode 100644 stable/aws-cluster-autoscaler/.helmignore create mode 100644 stable/aws-cluster-autoscaler/Chart.yaml create mode 100644 stable/aws-cluster-autoscaler/README.md create mode 100644 stable/aws-cluster-autoscaler/templates/NOTES.txt create mode 100644 stable/aws-cluster-autoscaler/templates/_helpers.tpl create mode 100644 stable/aws-cluster-autoscaler/templates/deployment.yaml create mode 100644 stable/aws-cluster-autoscaler/templates/service.yaml create mode 100644 stable/aws-cluster-autoscaler/values.yaml diff --git a/stable/aws-cluster-autoscaler/.helmignore b/stable/aws-cluster-autoscaler/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/stable/aws-cluster-autoscaler/.helmignore @@ -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 diff --git a/stable/aws-cluster-autoscaler/Chart.yaml b/stable/aws-cluster-autoscaler/Chart.yaml new file mode 100644 index 0000000000..189325a734 --- /dev/null +++ b/stable/aws-cluster-autoscaler/Chart.yaml @@ -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 diff --git a/stable/aws-cluster-autoscaler/README.md b/stable/aws-cluster-autoscaler/README.md new file mode 100644 index 0000000000..7d786c59ca --- /dev/null +++ b/stable/aws-cluster-autoscaler/README.md @@ -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). diff --git a/stable/aws-cluster-autoscaler/templates/NOTES.txt b/stable/aws-cluster-autoscaler/templates/NOTES.txt new file mode 100644 index 0000000000..1452934f0d --- /dev/null +++ b/stable/aws-cluster-autoscaler/templates/NOTES.txt @@ -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 }}" diff --git a/stable/aws-cluster-autoscaler/templates/_helpers.tpl b/stable/aws-cluster-autoscaler/templates/_helpers.tpl new file mode 100644 index 0000000000..f0d83d2edb --- /dev/null +++ b/stable/aws-cluster-autoscaler/templates/_helpers.tpl @@ -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 -}} diff --git a/stable/aws-cluster-autoscaler/templates/deployment.yaml b/stable/aws-cluster-autoscaler/templates/deployment.yaml new file mode 100644 index 0000000000..0eb74c3f0a --- /dev/null +++ b/stable/aws-cluster-autoscaler/templates/deployment.yaml @@ -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 diff --git a/stable/aws-cluster-autoscaler/templates/service.yaml b/stable/aws-cluster-autoscaler/templates/service.yaml new file mode 100644 index 0000000000..a5d7183757 --- /dev/null +++ b/stable/aws-cluster-autoscaler/templates/service.yaml @@ -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 }}" diff --git a/stable/aws-cluster-autoscaler/values.yaml b/stable/aws-cluster-autoscaler/values.yaml new file mode 100644 index 0000000000..797477c6c4 --- /dev/null +++ b/stable/aws-cluster-autoscaler/values.yaml @@ -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