Implemented support for topology spread constraints

This commit is contained in:
Ellis Tarn 2021-09-17 16:30:49 -07:00
parent cd2059147d
commit 18f8db05d9
4 changed files with 41 additions and 0 deletions

View file

@ -248,6 +248,37 @@ Sets the injector affinity for pod placement
{{ end }} {{ end }}
{{- end -}} {{- end -}}
{{/*
Sets the topologySpreadConstraints when running in standalone and HA modes.
*/}}
{{- define "vault.topologySpreadConstraints" -}}
{{- if and (ne .mode "dev") .Values.server.topologySpreadConstraints }}
topologySpreadConstraints:
{{ $tp := typeOf .Values.server.topologySpreadConstraints }}
{{- if eq $tp "string" }}
{{- tpl .Values.server.topologySpreadConstraints . | nindent 8 | trim }}
{{- else }}
{{- toYaml .Values.server.topologySpreadConstraints | nindent 8 }}
{{- end }}
{{ end }}
{{- end -}}
{{/*
Sets the injector topologySpreadConstraints for pod placement
*/}}
{{- define "injector.topologySpreadConstraints" -}}
{{- if .Values.injector.topologySpreadConstraints }}
topologySpreadConstraints:
{{ $tp := typeOf .Values.injector.topologySpreadConstraints }}
{{- if eq $tp "string" }}
{{- tpl .Values.injector.topologySpreadConstraints . | nindent 8 | trim }}
{{- else }}
{{- toYaml .Values.injector.topologySpreadConstraints | nindent 8 }}
{{- end }}
{{ end }}
{{- end -}}
{{/* {{/*
Sets the toleration for pod placement when running in standalone and HA modes. Sets the toleration for pod placement when running in standalone and HA modes.
*/}} */}}

View file

@ -29,6 +29,7 @@ spec:
{{ template "injector.annotations" . }} {{ template "injector.annotations" . }}
spec: spec:
{{ template "injector.affinity" . }} {{ template "injector.affinity" . }}
{{ template "injector.topologySpreadConstraints" . }}
{{ template "injector.tolerations" . }} {{ template "injector.tolerations" . }}
{{ template "injector.nodeselector" . }} {{ template "injector.nodeselector" . }}
{{- if .Values.injector.priorityClassName }} {{- if .Values.injector.priorityClassName }}

View file

@ -36,6 +36,7 @@ spec:
{{ template "vault.annotations" . }} {{ template "vault.annotations" . }}
spec: spec:
{{ template "vault.affinity" . }} {{ template "vault.affinity" . }}
{{ template "vault.topologySpreadConstraints" . }}
{{ template "vault.tolerations" . }} {{ template "vault.tolerations" . }}
{{ template "vault.nodeselector" . }} {{ template "vault.nodeselector" . }}
{{- if .Values.server.priorityClassName }} {{- if .Values.server.priorityClassName }}

View file

@ -175,6 +175,10 @@ injector:
component: webhook component: webhook
topologyKey: kubernetes.io/hostname topologyKey: kubernetes.io/hostname
# Topology settings for injector pods
# ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/
topologySpreadConstraints: []
# Toleration Settings for injector pods # Toleration Settings for injector pods
# This should be either a multi-line string or YAML matching the Toleration array # This should be either a multi-line string or YAML matching the Toleration array
# in a PodSpec. # in a PodSpec.
@ -430,6 +434,10 @@ server:
component: server component: server
topologyKey: kubernetes.io/hostname topologyKey: kubernetes.io/hostname
# Topology settings for server pods
# ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/
topologySpreadConstraints: []
# Toleration Settings for server pods # Toleration Settings for server pods
# This should be either a multi-line string or YAML matching the Toleration array # This should be either a multi-line string or YAML matching the Toleration array
# in a PodSpec. # in a PodSpec.