diff --git a/stable/k8s-spot-rescheduler/.helmignore b/stable/k8s-spot-rescheduler/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/stable/k8s-spot-rescheduler/.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-rescheduler/Chart.yaml b/stable/k8s-spot-rescheduler/Chart.yaml new file mode 100644 index 0000000000..f7e502bddb --- /dev/null +++ b/stable/k8s-spot-rescheduler/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +appVersion: "v0.1.1" +description: A k8s-spot-rescheduler Helm chart for Kubernetes +name: k8s-spot-rescheduler +version: 0.1.0 +keywords: + - spot + - rescheduler +home: https://github.com/pusher/k8s-spot-rescheduler +sources: + - https://github.com/pusher/k8s-spot-rescheduler +maintainers: + - name: komljen + email: alen.komljen@live.com diff --git a/stable/k8s-spot-rescheduler/OWNERS b/stable/k8s-spot-rescheduler/OWNERS new file mode 100644 index 0000000000..05497764bb --- /dev/null +++ b/stable/k8s-spot-rescheduler/OWNERS @@ -0,0 +1,4 @@ +approvers: +- komljen +reviewers: +- komljen diff --git a/stable/k8s-spot-rescheduler/README.md b/stable/k8s-spot-rescheduler/README.md new file mode 100644 index 0000000000..fde31a9f84 --- /dev/null +++ b/stable/k8s-spot-rescheduler/README.md @@ -0,0 +1,28 @@ +# Kubernetes AWS EC2 Spot Rescheduler + +This chart installs the [k8s-spot-rescheduler](https://github.com/pusher/k8s-spot-rescheduler). + +## Purpose + +Spot rescheduler will reschedule pods that are already running on on-demand instances. Based on worker labels it will move pods to spot instances. It can work together with [Cluster Autoscaler](https://github.com/kubernetes/charts/tree/master/stable/cluster-autoscaler) if you want to scale on-demand instances back to zero. + +## Installation + +You should install this chart into the `kube-system` namespace: +``` +helm install \ + --namespace kube-system \ + incubator/k8s-spot-rescheduler +``` + +If your cluster has RBAC enabled, run this command: +``` +helm install \ + --namespace kube-system \ + --set rbac.enabled=true \ + incubator/k8s-spot-rescheduler +``` + +## Configuration + +Add the parameters to `cmdOptions` which you want to use. Here is [the full list of available options](https://github.com/pusher/k8s-spot-rescheduler#flags). diff --git a/stable/k8s-spot-rescheduler/templates/NOTES.txt b/stable/k8s-spot-rescheduler/templates/NOTES.txt new file mode 100644 index 0000000000..2490275dcb --- /dev/null +++ b/stable/k8s-spot-rescheduler/templates/NOTES.txt @@ -0,0 +1,3 @@ +To verify that k8s-spot-rescheduler has started, run: + + kubectl --namespace={{ .Release.Namespace }} get pods -l "app={{ template "k8s-spot-rescheduler.name" . }},release={{ .Release.Name }}" \ No newline at end of file diff --git a/stable/k8s-spot-rescheduler/templates/_helpers.tpl b/stable/k8s-spot-rescheduler/templates/_helpers.tpl new file mode 100644 index 0000000000..4c61df895b --- /dev/null +++ b/stable/k8s-spot-rescheduler/templates/_helpers.tpl @@ -0,0 +1,43 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "k8s-spot-rescheduler.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-rescheduler.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-rescheduler.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-rescheduler.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "k8s-spot-rescheduler.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/stable/k8s-spot-rescheduler/templates/clusterrole.yaml b/stable/k8s-spot-rescheduler/templates/clusterrole.yaml new file mode 100644 index 0000000000..0ca939b047 --- /dev/null +++ b/stable/k8s-spot-rescheduler/templates/clusterrole.yaml @@ -0,0 +1,83 @@ +{{- if .Values.rbac.create }} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ template "k8s-spot-rescheduler.fullname" . }} + labels: + app: {{ template "k8s-spot-rescheduler.name" . }} + chart: {{ template "k8s-spot-rescheduler.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +rules: + # For leader election + - apiGroups: + - "" + resources: + - endpoints + verbs: + - get + - update + - create + - apiGroups: + - "" + resources: + - events + verbs: + - create + + # For listing and watching items + - apiGroups: + - "" + resources: + - nodes + - pods + - replicasets + - replicationcontrollers + - services + - statefulsets + - poddisruptionbudgets + - persistentvolumes + - persistentvolumeclaims + verbs: + - list + - get + - watch + - apiGroups: + - apps + resources: + - statefulsets + verbs: + - list + - get + - watch + - apiGroups: + - extensions + resources: + - replicasets + verbs: + - list + - get + - watch + - apiGroups: + - policy + resources: + - poddisruptionbudgets + verbs: + - list + - get + - watch + + # For rescheduling pods + - apiGroups: + - "" + resources: + - nodes + verbs: + - update + - apiGroups: + - "" + resources: + - pods/eviction + verbs: + - create +{{- end }} diff --git a/stable/k8s-spot-rescheduler/templates/clusterrolebinding.yaml b/stable/k8s-spot-rescheduler/templates/clusterrolebinding.yaml new file mode 100644 index 0000000000..c0305d7805 --- /dev/null +++ b/stable/k8s-spot-rescheduler/templates/clusterrolebinding.yaml @@ -0,0 +1,19 @@ +{{- if .Values.rbac.create }} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ template "k8s-spot-rescheduler.fullname" . }} + labels: + app: {{ template "k8s-spot-rescheduler.name" . }} + chart: {{ template "k8s-spot-rescheduler.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ template "k8s-spot-rescheduler.fullname" . }} +subjects: +- kind: ServiceAccount + name: {{ template "k8s-spot-rescheduler.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} +{{- end }} diff --git a/stable/k8s-spot-rescheduler/templates/deployment.yaml b/stable/k8s-spot-rescheduler/templates/deployment.yaml new file mode 100644 index 0000000000..d435c19361 --- /dev/null +++ b/stable/k8s-spot-rescheduler/templates/deployment.yaml @@ -0,0 +1,37 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "k8s-spot-rescheduler.fullname" . }} + labels: + app: {{ template "k8s-spot-rescheduler.name" . }} + chart: {{ template "k8s-spot-rescheduler.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "k8s-spot-rescheduler.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "k8s-spot-rescheduler.name" . }} + release: {{ .Release.Name }} + spec: + serviceAccountName: {{ template "k8s-spot-rescheduler.serviceAccountName" . }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - rescheduler + - --namespace={{ .Release.Namespace }} + {{- range $key, $value := .Values.cmdOptions }} + - --{{ $key }}{{ if $value }}={{ $value }}{{ end }} + {{- end }} + ports: + - name: http + containerPort: 9235 + resources: +{{ toYaml .Values.resources | indent 12 }} diff --git a/stable/k8s-spot-rescheduler/templates/serviceaccount.yaml b/stable/k8s-spot-rescheduler/templates/serviceaccount.yaml new file mode 100644 index 0000000000..328346035e --- /dev/null +++ b/stable/k8s-spot-rescheduler/templates/serviceaccount.yaml @@ -0,0 +1,11 @@ +{{- if .Values.serviceAccount.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "k8s-spot-rescheduler.serviceAccountName" . }} + labels: + app: {{ template "k8s-spot-rescheduler.name" . }} + chart: {{ template "k8s-spot-rescheduler.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- end }} diff --git a/stable/k8s-spot-rescheduler/values.yaml b/stable/k8s-spot-rescheduler/values.yaml new file mode 100644 index 0000000000..b02802803a --- /dev/null +++ b/stable/k8s-spot-rescheduler/values.yaml @@ -0,0 +1,44 @@ +# Default values for k8s-spot-rescheduler. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 + +image: + repository: quay.io/pusher/k8s-spot-rescheduler + tag: v0.1.1 + pullPolicy: IfNotPresent + +# The full list of available options https://github.com/pusher/k8s-spot-rescheduler#flags +cmdOptions: + v: 2 + running-in-cluster: true + housekeeping-interval: 10s + node-drain-delay: 10m + pod-eviction-timeout: 2m + max-graceful-termination: 2m + listen-address: 0.0.0.0:9235 + on-demand-node-label: node-role.kubernetes.io/worker + spot-node-label: node-role.kubernetes.io/spot-worker + +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:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +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: