From 6694f7aa00019f9fc7d0a2f93a061ea9595cef7f Mon Sep 17 00:00:00 2001 From: NEwa-05 Date: Tue, 2 May 2023 17:38:05 +0200 Subject: [PATCH] add topologySpreadConstraint to proxy deployment --- traefikee/Chart.yaml | 2 +- traefikee/templates/proxy/deployment.yaml | 7 ++++++ traefikee/tests/proxy_test.yaml | 28 ++++++++++++++++++++++- traefikee/values.yaml | 10 ++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/traefikee/Chart.yaml b/traefikee/Chart.yaml index 4039f98..8ac349e 100644 --- a/traefikee/Chart.yaml +++ b/traefikee/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: traefikee -version: 1.11.0 +version: 1.12.0 appVersion: v2.10.1 # Because of https://github.com/helm/helm/issues/3810 the pre-release version suffix has to be define. # This allows the installation on Kubernetes cluster with a pre-release version (e.g. v1.19.9-gke.1900) diff --git a/traefikee/templates/proxy/deployment.yaml b/traefikee/templates/proxy/deployment.yaml index fbbf313..20809f2 100644 --- a/traefikee/templates/proxy/deployment.yaml +++ b/traefikee/templates/proxy/deployment.yaml @@ -33,6 +33,13 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} spec: + {{- if .Values.proxy.topologySpreadConstraints }} + {{- if (semverCompare "<1.19.0-0" .Capabilities.KubeVersion.Version) }} + {{- fail "ERROR: topologySpreadConstraints are supported only on kubernetes >= v1.19" -}} + {{- end }} + topologySpreadConstraints: + {{- tpl (toYaml .Values.proxy.topologySpreadConstraints) . | nindent 8 }} + {{- end }} {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} diff --git a/traefikee/tests/proxy_test.yaml b/traefikee/tests/proxy_test.yaml index 105a38f..8bf5845 100644 --- a/traefikee/tests/proxy_test.yaml +++ b/traefikee/tests/proxy_test.yaml @@ -147,7 +147,33 @@ tests: limits: cpu: "300m" memory: "150Mi" - + - it: should not set topologySpreadConstraints by default + asserts: + - isNull: + path: spec.template.spec.topologySpreadConstraints + - it: should set topologySpreadConstraints + set: + proxy: + topologySpreadConstraints: + - labelSelector: + matchLabels: + app: traefikee + component: proxies + maxSkew: 1 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule + asserts: + - isSubset: + path: spec.template.spec + content: + topologySpreadConstraints: + - labelSelector: + matchLabels: + app: traefikee + component: proxies + maxSkew: 1 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule --- suite: proxy service test templates: diff --git a/traefikee/values.yaml b/traefikee/values.yaml index d9be1d1..26cd9f5 100644 --- a/traefikee/values.yaml +++ b/traefikee/values.yaml @@ -188,6 +188,16 @@ proxy: # minAvailable: 1 # maxUnavailable: 1 # terminationGracePeriodSeconds: 30 +# # This example topologySpreadConstraints forces the scheduler to put traefikee proxy pods +# # on nodes where no other traefikee pods are scheduled. +# topologySpreadConstraints: +# - labelSelector: +# matchLabels: +# app: traefikee +# component: proxies +# maxSkew: 1 +# topologyKey: kubernetes.io/hostname +# whenUnsatisfiable: DoNotSchedule # priorityClassName will be set on all pods. priorityClassName: ""