From 164884c0a5fdf6b56d6d7e6771d2eddf6a27e110 Mon Sep 17 00:00:00 2001 From: ianarsenault Date: Tue, 27 Aug 2024 14:06:19 -0400 Subject: [PATCH] charts/service-deployment add tolerations and topologySpreadConstraints (closes #165, closes #189) --- charts/service-deployment/Chart.yaml | 2 +- charts/service-deployment/README.md | 2 ++ .../service-deployment/templates/certificate.yaml | 2 +- charts/service-deployment/templates/configmaps.yaml | 2 +- charts/service-deployment/templates/deployment.yaml | 13 +++++++++++-- charts/service-deployment/templates/hpa.yaml | 2 +- charts/service-deployment/templates/ingress.yaml | 2 +- .../service-deployment/templates/ipallowlist.yaml | 2 +- charts/service-deployment/templates/pvc.yaml | 2 +- charts/service-deployment/templates/secrets.yaml | 2 +- charts/service-deployment/templates/service.yaml | 2 +- .../templates/targetgroupbinding.yaml | 2 +- charts/service-deployment/values.yaml | 10 ++++++++++ 13 files changed, 33 insertions(+), 12 deletions(-) diff --git a/charts/service-deployment/Chart.yaml b/charts/service-deployment/Chart.yaml index 54ce7f3..88cac80 100644 --- a/charts/service-deployment/Chart.yaml +++ b/charts/service-deployment/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: service-deployment description: A Helm Chart to setup a generic deployment with optional service/hpa bindings -version: 0.19.1 +version: 0.20.0 icon: https://raw.githubusercontent.com/snowplow-devops/helm-charts/master/docs/logo/snowplow.png home: https://github.com/snowplow-devops/helm-charts sources: diff --git a/charts/service-deployment/README.md b/charts/service-deployment/README.md index 70fafb9..443e878 100644 --- a/charts/service-deployment/README.md +++ b/charts/service-deployment/README.md @@ -107,3 +107,5 @@ helm delete service-deployment | service.protocol | string | `"TCP"` | Protocol that the service leverages (note: TCP or UDP) | | service.targetPort | int | `80` | The Target Port that the actual application is being exposed on | | terminationGracePeriodSeconds | int | `60` | Grace period for termination of the service | +| tolerations | list |`[]` | Tolerations labels for pod assignment with matching taints | +| topologySpreadConstraints | object | `{}` | Topology Spread Constraints for pod assignment | diff --git a/charts/service-deployment/templates/certificate.yaml b/charts/service-deployment/templates/certificate.yaml index 3afb77e..69bf969 100644 --- a/charts/service-deployment/templates/certificate.yaml +++ b/charts/service-deployment/templates/certificate.yaml @@ -6,7 +6,7 @@ kind: Certificate metadata: name: {{ required "A valid hostname is required!" .hostname }} labels: - {{ include "snowplow.labels" $ | nindent 4 }} + {{- include "snowplow.labels" $ | nindent 4 }} spec: secretName: {{ .hostname }}-tls issuerRef: diff --git a/charts/service-deployment/templates/configmaps.yaml b/charts/service-deployment/templates/configmaps.yaml index 94dd25f..4663760 100644 --- a/charts/service-deployment/templates/configmaps.yaml +++ b/charts/service-deployment/templates/configmaps.yaml @@ -5,7 +5,7 @@ kind: ConfigMap metadata: name: {{ $v.name }} labels: - {{ include "snowplow.labels" $ | nindent 4 }} + {{- include "snowplow.labels" $ | nindent 4 }} binaryData: {{- range $f := $v.files }} {{- if $f.contentsB64 }} diff --git a/charts/service-deployment/templates/deployment.yaml b/charts/service-deployment/templates/deployment.yaml index d3effe2..567b9ea 100644 --- a/charts/service-deployment/templates/deployment.yaml +++ b/charts/service-deployment/templates/deployment.yaml @@ -3,7 +3,7 @@ kind: {{ .Values.deployment.kind }} metadata: name: {{ include "app.fullname" . }} labels: - {{ include "snowplow.labels" $ | nindent 4 }} + {{- include "snowplow.labels" $ | nindent 4 }} spec: {{- if .Values.deployment.scaleToZero }} replicas: 0 @@ -21,7 +21,7 @@ spec: template: metadata: labels: - {{ include "snowplow.labels" $ | nindent 8 }} + {{- include "snowplow.labels" $ | nindent 8 }} {{- if .Values.deployment.podLabels }} {{- toYaml .Values.deployment.podLabels | nindent 8 }} {{- end }} @@ -85,6 +85,15 @@ spec: {{- toYaml .Values.affinity | nindent 8 }} {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: - name: "{{ include "app.fullname" . }}" image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" diff --git a/charts/service-deployment/templates/hpa.yaml b/charts/service-deployment/templates/hpa.yaml index 773e4e5..2cf7064 100644 --- a/charts/service-deployment/templates/hpa.yaml +++ b/charts/service-deployment/templates/hpa.yaml @@ -4,7 +4,7 @@ kind: HorizontalPodAutoscaler metadata: name: {{ include "app.fullname" . }} labels: - {{ include "snowplow.labels" $ | nindent 4 }} + {{- include "snowplow.labels" $ | nindent 4 }} spec: scaleTargetRef: apiVersion: apps/v1 diff --git a/charts/service-deployment/templates/ingress.yaml b/charts/service-deployment/templates/ingress.yaml index 7468a77..91e7bcf 100644 --- a/charts/service-deployment/templates/ingress.yaml +++ b/charts/service-deployment/templates/ingress.yaml @@ -5,7 +5,7 @@ kind: Ingress metadata: name: {{ required "A valid hostname is required!" .hostname }} labels: - {{ include "snowplow.labels" $ | nindent 4 }} + {{- include "snowplow.labels" $ | nindent 4 }} annotations: {{- if .annotations }} {{- toYaml .annotations | nindent 4 }} diff --git a/charts/service-deployment/templates/ipallowlist.yaml b/charts/service-deployment/templates/ipallowlist.yaml index 2a11d27..acdf24b 100644 --- a/charts/service-deployment/templates/ipallowlist.yaml +++ b/charts/service-deployment/templates/ipallowlist.yaml @@ -4,7 +4,7 @@ kind: Middleware metadata: name: {{ include "app.fullname" . }}-ipallowlist labels: - {{ include "snowplow.labels" $ | nindent 4 }} + {{- include "snowplow.labels" $ | nindent 4 }} spec: ipWhiteList: sourceRange: diff --git a/charts/service-deployment/templates/pvc.yaml b/charts/service-deployment/templates/pvc.yaml index ff2cbac..816fbed 100644 --- a/charts/service-deployment/templates/pvc.yaml +++ b/charts/service-deployment/templates/pvc.yaml @@ -7,7 +7,7 @@ metadata: {{ toYaml .Values.persistentVolume.annotations | indent 4 }} {{- end }} labels: - {{ include "snowplow.labels" $ | nindent 4 }} + {{- include "snowplow.labels" $ | nindent 4 }} {{- with .Values.persistentVolume.labels }} {{- toYaml . | nindent 4 }} {{- end }} diff --git a/charts/service-deployment/templates/secrets.yaml b/charts/service-deployment/templates/secrets.yaml index 43b459b..fe1bce4 100644 --- a/charts/service-deployment/templates/secrets.yaml +++ b/charts/service-deployment/templates/secrets.yaml @@ -5,7 +5,7 @@ metadata: namespace: {{ .Release.Namespace }} name: {{ include "app.secret.fullname" . }} labels: - {{ include "snowplow.labels" $ | nindent 4 }} + {{- include "snowplow.labels" $ | nindent 4 }} type: Opaque data: {{- range $k, $v := .Values.config.secrets }} diff --git a/charts/service-deployment/templates/service.yaml b/charts/service-deployment/templates/service.yaml index 97bf4a4..06d7724 100644 --- a/charts/service-deployment/templates/service.yaml +++ b/charts/service-deployment/templates/service.yaml @@ -12,7 +12,7 @@ metadata: cloud.google.com/neg: '{"exposed_ports": {"{{ .Values.service.port }}":{"name": "{{ include "service.gcp.networkEndpointGroupName" . }}"}}}' {{- end }} labels: - {{ include "snowplow.labels" $ | nindent 4 }} + {{- include "snowplow.labels" $ | nindent 4 }} spec: type: NodePort selector: diff --git a/charts/service-deployment/templates/targetgroupbinding.yaml b/charts/service-deployment/templates/targetgroupbinding.yaml index 0f4033d..e2609b8 100644 --- a/charts/service-deployment/templates/targetgroupbinding.yaml +++ b/charts/service-deployment/templates/targetgroupbinding.yaml @@ -5,7 +5,7 @@ kind: TargetGroupBinding metadata: name: {{ include "app.fullname" . }} labels: - {{ include "snowplow.labels" $ | nindent 4 }} + {{- include "snowplow.labels" $ | nindent 4 }} spec: serviceRef: name: {{ include "app.fullname" . }} diff --git a/charts/service-deployment/values.yaml b/charts/service-deployment/values.yaml index 79edce4..43fbaf0 100644 --- a/charts/service-deployment/values.yaml +++ b/charts/service-deployment/values.yaml @@ -176,6 +176,16 @@ deployment: # -- PriorityClassName for pods priorityClassName: "" +# -- Allow the scheduler to schedule pods with matching taints +# +# more details here: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/ +tolerations: [] + +# -- topologySpreadConstraints control how Pods are spread across your cluster among failure-domains such as regions, zones, nodes, and other user-defined topology domains. +# +# more details here: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/ +topologySpreadConstraints: {} + # -- Affinity supports podAffinity, podAntiAffinity, or nodeAffinity affinity: {} # podAffinity: