diff --git a/stable/k8s-spot-termination-handler/.helmignore b/stable/k8s-spot-termination-handler/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/stable/k8s-spot-termination-handler/.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/k8s-spot-termination-handler/Chart.yaml b/stable/k8s-spot-termination-handler/Chart.yaml new file mode 100644 index 0000000000..34124bfdc2 --- /dev/null +++ b/stable/k8s-spot-termination-handler/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +appVersion: "0.1.0" +description: The K8s Spot Termination handler handles draining AWS Spot Instances in response to termination requests. +name: k8s-spot-termination-handler +version: 0.1.0 +keywords: + - spot + - termination +home: https://github.com/pusher/k8s-spot-termination-handler +sources: + - https://github.com/pusher/k8s-spot-termination-handler +maintainers: + - name: kierranm + email: kierranm@gmail.com diff --git a/stable/k8s-spot-termination-handler/templates/NOTES.txt b/stable/k8s-spot-termination-handler/templates/NOTES.txt new file mode 100644 index 0000000000..3b258f154d --- /dev/null +++ b/stable/k8s-spot-termination-handler/templates/NOTES.txt @@ -0,0 +1,3 @@ +To verify that k8s-spot-termination-handler has started, run: + + kubectl --namespace={{ .Release.Namespace }} get pods -l "app={{ template "k8s-spot-termination-handler.name" . }},release={{ .Release.Name }}" \ No newline at end of file diff --git a/stable/k8s-spot-termination-handler/templates/_helpers.tpl b/stable/k8s-spot-termination-handler/templates/_helpers.tpl new file mode 100644 index 0000000000..f3d23d8550 --- /dev/null +++ b/stable/k8s-spot-termination-handler/templates/_helpers.tpl @@ -0,0 +1,43 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "k8s-spot-termination-handler.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). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "k8s-spot-termination-handler.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "k8s-spot-termination-handler.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "k8s-spot-termination-handler.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "k8s-spot-termination-handler.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/stable/k8s-spot-termination-handler/templates/clusterrole.yaml b/stable/k8s-spot-termination-handler/templates/clusterrole.yaml new file mode 100644 index 0000000000..d730d886c6 --- /dev/null +++ b/stable/k8s-spot-termination-handler/templates/clusterrole.yaml @@ -0,0 +1,39 @@ +{{- if .Values.rbac.create }} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ template "k8s-spot-termination-handler.fullname" . }} + labels: + app: {{ template "k8s-spot-termination-handler.name" . }} + chart: {{ template "k8s-spot-termination-handler.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +rules: + # For draining nodes + - apiGroups: + - "" + resources: + - nodes + verbs: + - get + - update + - apiGroups: + - "" + resources: + - pods + verbs: + - list + - apiGroups: + - extensions + resources: + - replicasets + - daemonsets + verbs: + - get + - apiGroups: + - "" + resources: + - pods/eviction + verbs: + - create +{{- end}} \ No newline at end of file diff --git a/stable/k8s-spot-termination-handler/templates/clusterrolebinding.yaml b/stable/k8s-spot-termination-handler/templates/clusterrolebinding.yaml new file mode 100644 index 0000000000..5cd0942b0b --- /dev/null +++ b/stable/k8s-spot-termination-handler/templates/clusterrolebinding.yaml @@ -0,0 +1,19 @@ +{{- if .Values.rbac.create }} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ template "k8s-spot-termination-handler.fullname" . }} + labels: + app: {{ template "k8s-spot-termination-handler.name" . }} + chart: {{ template "k8s-spot-termination-handler.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ template "k8s-spot-termination-handler.fullname" . }} +subjects: +- kind: ServiceAccount + name: {{ template "k8s-spot-termination-handler.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} +{{- end}} \ No newline at end of file diff --git a/stable/k8s-spot-termination-handler/templates/daemonset.yaml b/stable/k8s-spot-termination-handler/templates/daemonset.yaml new file mode 100644 index 0000000000..7abc119c34 --- /dev/null +++ b/stable/k8s-spot-termination-handler/templates/daemonset.yaml @@ -0,0 +1,39 @@ +apiVersion: extensions/v1beta1 +kind: DaemonSet +metadata: + name: {{ include "k8s-spot-termination-handler.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "k8s-spot-termination-handler.name" . }} + helm.sh/chart: {{ include "k8s-spot-termination-handler.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "k8s-spot-termination-handler.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} diff --git a/stable/k8s-spot-termination-handler/templates/serviceaccount.yaml b/stable/k8s-spot-termination-handler/templates/serviceaccount.yaml new file mode 100644 index 0000000000..3ebc059bc5 --- /dev/null +++ b/stable/k8s-spot-termination-handler/templates/serviceaccount.yaml @@ -0,0 +1,11 @@ +{{- if .Values.serviceAccount.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "k8s-spot-termination-handler.serviceAccountName" . }} + labels: + app: {{ template "k8s-spot-termination-handler.name" . }} + chart: {{ template "k8s-spot-termination-handler.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- end }} \ No newline at end of file diff --git a/stable/k8s-spot-termination-handler/values.yaml b/stable/k8s-spot-termination-handler/values.yaml new file mode 100644 index 0000000000..ca6a71f989 --- /dev/null +++ b/stable/k8s-spot-termination-handler/values.yaml @@ -0,0 +1,38 @@ +# Default values for k8s-spot-termination-handler. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +rbac: + # Specifies whether RBAC resources should be created + create: true + +serviceAccount: + # Specifies whether a ServiceAccount should be created + create: true + # The name of the ServiceAccount to use. + # If not set and create is true, a name is generated using the fullname template + name: + +image: + repository: quay.io/pusher/k8s-spot-termination-handler + tag: v0.1.0 + pullPolicy: IfNotPresent + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # requests: + # cpu: 5m + # memory: 20Mi + # limits: + # cpu: 100m + # memory: 100Mi + +# By default, schedule only on spot workers +nodeSelector: + "node-role.kubernetes.io/spot-worker": "true" + +tolerations: [] + +affinity: {}