From ae044b2ada14eaafaf6d4f8fcb786777b02a87f4 Mon Sep 17 00:00:00 2001 From: Steve Hipwell Date: Tue, 26 May 2020 12:00:03 +0100 Subject: [PATCH] Add Descheduler chart (#21) * Add Descheduler chart * Update Confluence --- .gitignore | 1 - README.md | 3 +- charts/confluence-server/Chart.yaml | 2 +- charts/confluence-server/templates/pvc.yaml | 2 +- charts/descheduler/.helmignore | 22 ++++++++ charts/descheduler/Chart.yaml | 16 ++++++ charts/descheduler/templates/NOTES.txt | 1 + charts/descheduler/templates/_helpers.tpl | 56 +++++++++++++++++++ charts/descheduler/templates/clusterrole.yaml | 21 +++++++ .../templates/clusterrolebinding.yaml | 16 ++++++ charts/descheduler/templates/configmap.yaml | 11 ++++ charts/descheduler/templates/cronjob.yaml | 51 +++++++++++++++++ .../descheduler/templates/serviceaccount.yaml | 8 +++ charts/descheduler/values.yaml | 49 ++++++++++++++++ 14 files changed, 254 insertions(+), 5 deletions(-) create mode 100644 charts/descheduler/.helmignore create mode 100644 charts/descheduler/Chart.yaml create mode 100644 charts/descheduler/templates/NOTES.txt create mode 100644 charts/descheduler/templates/_helpers.tpl create mode 100644 charts/descheduler/templates/clusterrole.yaml create mode 100644 charts/descheduler/templates/clusterrolebinding.yaml create mode 100644 charts/descheduler/templates/configmap.yaml create mode 100644 charts/descheduler/templates/cronjob.yaml create mode 100644 charts/descheduler/templates/serviceaccount.yaml create mode 100644 charts/descheduler/values.yaml diff --git a/.gitignore b/.gitignore index 95f53f4e..f050df3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -charts/ **/test-values.y*ml diff --git a/README.md b/README.md index 35f92b38..75a0b03a 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ These charts are provided as-is with no warranties. ## Usage -[Helm](https://helm.sh) must be installed to use the charts. -Please refer to Helm's [documentation](https://helm.sh/docs/) to get started. +[Helm](https://helm.sh) must be installed to use the charts, please refer to Helm's [documentation](https://helm.sh/docs/) to get started. Once Helm is set up properly, add the repo as follows: diff --git a/charts/confluence-server/Chart.yaml b/charts/confluence-server/Chart.yaml index 2641ee36..3c012adb 100644 --- a/charts/confluence-server/Chart.yaml +++ b/charts/confluence-server/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: confluence-server -version: 2.2.0 +version: 2.2.1 appVersion: 7.5.0 description: Atlassian Confluence Server is where you create, organise and discuss work with your team. Capture the knowledge that's too often lost in email inboxes and shared network drives in Confluence - where it's easy to find, use, and update. Give every team, project, or department its own space to create the things they need, whether it's meeting notes, product requirements, file lists, or project plans, you can get more done in Confluence. keywords: diff --git a/charts/confluence-server/templates/pvc.yaml b/charts/confluence-server/templates/pvc.yaml index 8ad5eb80..cf00316a 100644 --- a/charts/confluence-server/templates/pvc.yaml +++ b/charts/confluence-server/templates/pvc.yaml @@ -10,7 +10,7 @@ metadata: app.kubernetes.io/managed-by: {{ .Release.Service }} {{- with .Values.persistence.annotations }} annotations: - {{ . | toYaml | trim | nindent 4 }} + {{- . | toYaml | trim | nindent 4 }} {{- end }} spec: accessModes: diff --git a/charts/descheduler/.helmignore b/charts/descheduler/.helmignore new file mode 100644 index 00000000..50af0317 --- /dev/null +++ b/charts/descheduler/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/charts/descheduler/Chart.yaml b/charts/descheduler/Chart.yaml new file mode 100644 index 00000000..5330615e --- /dev/null +++ b/charts/descheduler/Chart.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +name: descheduler +version: 1.0.0 +appVersion: 0.9.0 +description: A Helm chart for the Kubernetes Descheduler. +keywords: +- kubernetes +- descheduler +- kube-scheduler +home: https://github.com/kubernetes-sigs/descheduler +icon: https://kubernetes.io/images/favicon.png +sources: +- https://github.com/kubernetes-sigs/descheduler +maintainers: +- name: stevehipwell + email: steve.hipwell@github.com diff --git a/charts/descheduler/templates/NOTES.txt b/charts/descheduler/templates/NOTES.txt new file mode 100644 index 00000000..f43d29ed --- /dev/null +++ b/charts/descheduler/templates/NOTES.txt @@ -0,0 +1 @@ +Descheduler installed as a cron job. diff --git a/charts/descheduler/templates/_helpers.tpl b/charts/descheduler/templates/_helpers.tpl new file mode 100644 index 00000000..68df7d3f --- /dev/null +++ b/charts/descheduler/templates/_helpers.tpl @@ -0,0 +1,56 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "descheduler.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 "descheduler.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 "descheduler.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "descheduler.labels" -}} +app.kubernetes.io/name: {{ include "descheduler.name" . }} +helm.sh/chart: {{ include "descheduler.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "descheduler.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "descheduler.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/descheduler/templates/clusterrole.yaml b/charts/descheduler/templates/clusterrole.yaml new file mode 100644 index 00000000..b63ef308 --- /dev/null +++ b/charts/descheduler/templates/clusterrole.yaml @@ -0,0 +1,21 @@ +{{- if .Values.rbac.create -}} +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ template "descheduler.fullname" . }} + labels: + {{- include "descheduler.labels" . | nindent 4 }} +rules: +- apiGroups: [""] + resources: ["events"] + verbs: ["create", "update"] +- apiGroups: [""] + resources: ["nodes"] + verbs: ["get", "watch", "list"] +- apiGroups: [""] + resources: ["pods"] + verbs: ["get", "watch", "list", "delete"] +- apiGroups: [""] + resources: ["pods/eviction"] + verbs: ["create"] +{{- end -}} diff --git a/charts/descheduler/templates/clusterrolebinding.yaml b/charts/descheduler/templates/clusterrolebinding.yaml new file mode 100644 index 00000000..6cbc6200 --- /dev/null +++ b/charts/descheduler/templates/clusterrolebinding.yaml @@ -0,0 +1,16 @@ +{{- if .Values.rbac.create -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ template "descheduler.fullname" . }} + labels: + {{- include "descheduler.labels" . | nindent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ template "descheduler.fullname" . }} +subjects: + - kind: ServiceAccount + name: {{ template "descheduler.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} +{{- end -}} diff --git a/charts/descheduler/templates/configmap.yaml b/charts/descheduler/templates/configmap.yaml new file mode 100644 index 00000000..a8b620a8 --- /dev/null +++ b/charts/descheduler/templates/configmap.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "descheduler.fullname" . }} + labels: + {{- include "descheduler.labels" . | nindent 4 }} +data: + policy.yaml: | + apiVersion: "descheduler/v1alpha1" + kind: "DeschedulerPolicy" +{{ toYaml .Values.deschedulerPolicy | trim | indent 4 }} diff --git a/charts/descheduler/templates/cronjob.yaml b/charts/descheduler/templates/cronjob.yaml new file mode 100644 index 00000000..1eca099a --- /dev/null +++ b/charts/descheduler/templates/cronjob.yaml @@ -0,0 +1,51 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: {{ template "descheduler.fullname" . }} + labels: + {{- include "descheduler.labels" . | nindent 4 }} +spec: + schedule: {{ .Values.schedule | quote }} + concurrencyPolicy: "Forbid" + jobTemplate: + spec: + template: + metadata: + name: {{ template "descheduler.fullname" . }} + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + {{- if .Values.podAnnotations }} + {{- .Values.podAnnotations | toYaml | nindent 12 }} + {{- end }} + labels: + app.kubernetes.io/name: {{ include "descheduler.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + {{- if .Values.podLabels }} + {{- .Values.podLabels | toYaml | nindent 12 }} + {{- end }} + spec: + priorityClassName: system-cluster-critical + serviceAccountName: {{ template "descheduler.serviceAccountName" . }} + restartPolicy: "Never" + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - "/bin/descheduler" + args: + - "--policy-config-file" + - "/policy-dir/policy.yaml" + {{- range $key, $value := .Values.cmdOptions }} + - {{ printf "--%s" $key | quote }} + {{- if $value }} + - {{ $value | quote }} + {{- end }} + {{- end }} + volumeMounts: + - mountPath: /policy-dir + name: policy-volume + volumes: + - name: policy-volume + configMap: + name: {{ template "descheduler.fullname" . }} diff --git a/charts/descheduler/templates/serviceaccount.yaml b/charts/descheduler/templates/serviceaccount.yaml new file mode 100644 index 00000000..8149ce07 --- /dev/null +++ b/charts/descheduler/templates/serviceaccount.yaml @@ -0,0 +1,8 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "descheduler.serviceAccountName" . }} + labels: + {{- include "descheduler.labels" . | nindent 4 }} +{{- end -}} diff --git a/charts/descheduler/values.yaml b/charts/descheduler/values.yaml new file mode 100644 index 00000000..acec68e0 --- /dev/null +++ b/charts/descheduler/values.yaml @@ -0,0 +1,49 @@ +# Default values for descheduler. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +image: + repository: aveshagarwal/descheduler + tag: 0.9.0 + pullPolicy: IfNotPresent + +nameOverride: "" +fullnameOverride: "" + +schedule: "*/2 * * * *" + +cmdOptions: + v: 3 + # evict-local-storage-pods: + # max-pods-to-evict-per-node: 10 + # node-selector: "key1=value1,key2=value2" + +deschedulerPolicy: + strategies: + RemoveDuplicates: + enabled: true + RemovePodsViolatingInterPodAntiAffinity: + enabled: true + LowNodeUtilization: + enabled: true + params: + nodeResourceUtilizationThresholds: + thresholds: + cpu: 20 + memory: 20 + pods: 20 + targetThresholds: + cpu: 50 + memory: 50 + pods: 50 + +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: