[stable] Add a Helm chart for k8s-spot-rescheduler (#4826)

* Initial commit

* If statement for rbac enabled fix

* Add readme file

* Readme update

* Add a home variable

* Add NOTES.txt

* Add OWNERS

* Change the way how cmd options are read

* Use RBAC best practices

* Move to stable channel

* Add a NOTES message

* Change order
This commit is contained in:
Alen Komljen
2018-05-02 13:26:17 -07:00
committed by k8s-ci-robot
parent cd1879797e
commit fe979a2a9e
11 changed files with 307 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
+14
View File
@@ -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
+4
View File
@@ -0,0 +1,4 @@
approvers:
- komljen
reviewers:
- komljen
+28
View File
@@ -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).
@@ -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 }}"
@@ -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 -}}
@@ -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 }}
@@ -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 }}
@@ -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 }}
@@ -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 }}
+44
View File
@@ -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: