Skip to content

Commit

Permalink
add topology spread constraints so ditto services spread equally amon…
Browse files Browse the repository at this point in the history
…g cluster nodes

Signed-off-by: Vladica Obojevic <obojevic@gmail.com>
  • Loading branch information
vladica committed Sep 6, 2023
1 parent 5eec13f commit 93a94bb
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 0 deletions.
7 changes: 7 additions & 0 deletions deployment/helm/ditto/templates/connectivity-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ spec:
- name: ditto-log-files-directory
mountPath: /var/log/ditto
{{- end }}
topologySpreadConstraints:
- maxSkew: {{ .Values.connectivity.topologySpreadConstraints.maxSkew }}
topologyKey: {{ .Values.connectivity.topologySpreadConstraints.topologyKey }}
whenUnsatisfiable: {{ .Values.connectivity.topologySpreadConstraints.whenUnsatisfiable }}
labelSelector:
matchLabels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-connectivity
containers:
- name: {{ .Chart.Name }}-connectivity
image: {{ printf "%s:%s" .Values.connectivity.image.repository ( default .Chart.AppVersion ( default .Values.dittoTag .Values.connectivity.image.tag ) ) }}
Expand Down
7 changes: 7 additions & 0 deletions deployment/helm/ditto/templates/dittoui-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
topologySpreadConstraints:
- maxSkew: {{ .Values.dittoui.topologySpreadConstraints.maxSkew }}
topologyKey: {{ .Values.dittoui.topologySpreadConstraints.topologyKey }}
whenUnsatisfiable: {{ .Values.dittoui.topologySpreadConstraints.whenUnsatisfiable }}
labelSelector:
matchLabels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-dittoui
containers:
- name: {{ .Chart.Name }}-dittoui
image: {{ printf "%s:%s" .Values.dittoui.image.repository ( default .Chart.AppVersion ( default .Values.dittoTag .Values.dittoui.image.tag ) ) }}
Expand Down
7 changes: 7 additions & 0 deletions deployment/helm/ditto/templates/gateway-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ spec:
- name: ditto-log-files-directory
mountPath: /var/log/ditto
{{- end }}
topologySpreadConstraints:
- maxSkew: {{ .Values.gateway.topologySpreadConstraints.maxSkew }}
topologyKey: {{ .Values.gateway.topologySpreadConstraints.topologyKey }}
whenUnsatisfiable: {{ .Values.gateway.topologySpreadConstraints.whenUnsatisfiable }}
labelSelector:
matchLabels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-gateway
containers:
- name: {{ .Chart.Name }}-gateway
image: {{ printf "%s:%s" .Values.gateway.image.repository ( default .Chart.AppVersion ( default .Values.dittoTag .Values.gateway.image.tag ) ) }}
Expand Down
7 changes: 7 additions & 0 deletions deployment/helm/ditto/templates/nginx-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ spec:
sleep 1;
done
{{- end }}
topologySpreadConstraints:
- maxSkew: {{ .Values.nginx.topologySpreadConstraints.maxSkew }}
topologyKey: {{ .Values.nginx.topologySpreadConstraints.topologyKey }}
whenUnsatisfiable: {{ .Values.nginx.topologySpreadConstraints.whenUnsatisfiable }}
labelSelector:
matchLabels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-nginx
containers:
- name: {{ .Chart.Name }}-nginx
image: "{{ .Values.nginx.image.repository }}:{{ .Values.nginx.image.tag }}"
Expand Down
7 changes: 7 additions & 0 deletions deployment/helm/ditto/templates/nginx-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,13 @@ spec:
supplementalGroups: [101]
seccompProfile:
type: RuntimeDefault
topologySpreadConstraints:
- maxSkew: {{ .Values.ingress.controller.topologySpreadConstraints.maxSkew }}
topologyKey: {{ .Values.ingress.controller.topologySpreadConstraints.topologyKey }}
whenUnsatisfiable: {{ .Values.ingress.controller.topologySpreadConstraints.whenUnsatisfiable }}
labelSelector:
matchLabels:
app.kubernetes.io/name: "{{ .Values.ingress.controller.namespace }}"
containers:
- name: nginx-node-health-check
image: docker.io/library/nginx:{{ .Values.ingress.controller.nginxVersion }}
Expand Down
7 changes: 7 additions & 0 deletions deployment/helm/ditto/templates/policies-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ spec:
- name: ditto-log-files-directory
mountPath: /var/log/ditto
{{- end }}
topologySpreadConstraints:
- maxSkew: {{ .Values.policies.topologySpreadConstraints.maxSkew }}
topologyKey: {{ .Values.policies.topologySpreadConstraints.topologyKey }}
whenUnsatisfiable: {{ .Values.policies.topologySpreadConstraints.whenUnsatisfiable }}
labelSelector:
matchLabels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-policies
containers:
- name: {{ .Chart.Name }}-policies
image: {{ printf "%s:%s" .Values.policies.image.repository ( default .Chart.AppVersion ( default .Values.dittoTag .Values.policies.image.tag ) ) }}
Expand Down
7 changes: 7 additions & 0 deletions deployment/helm/ditto/templates/swaggerui-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ spec:
volumeMounts:
- name: swagger-ui-init-config
mountPath: /init-config
topologySpreadConstraints:
- maxSkew: {{ .Values.swaggerui.topologySpreadConstraints.maxSkew }}
topologyKey: {{ .Values.swaggerui.topologySpreadConstraints.topologyKey }}
whenUnsatisfiable: {{ .Values.swaggerui.topologySpreadConstraints.whenUnsatisfiable }}
labelSelector:
matchLabels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-swaggerui
containers:
- name: {{ .Chart.Name }}-swaggerui
image: "{{ .Values.swaggerui.image.repository }}:{{ .Values.swaggerui.image.tag }}"
Expand Down
7 changes: 7 additions & 0 deletions deployment/helm/ditto/templates/things-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ spec:
- name: ditto-log-files-directory
mountPath: /var/log/ditto
{{- end }}
topologySpreadConstraints:
- maxSkew: {{ .Values.things.topologySpreadConstraints.maxSkew }}
topologyKey: {{ .Values.things.topologySpreadConstraints.topologyKey }}
whenUnsatisfiable: {{ .Values.things.topologySpreadConstraints.whenUnsatisfiable }}
labelSelector:
matchLabels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-things
containers:
- name: {{ .Chart.Name }}-things
image: {{ printf "%s:%s" .Values.things.image.repository ( default .Chart.AppVersion ( default .Values.dittoTag .Values.things.image.tag ) ) }}
Expand Down
7 changes: 7 additions & 0 deletions deployment/helm/ditto/templates/thingssearch-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ spec:
- name: ditto-log-files-directory
mountPath: /var/log/ditto
{{- end }}
topologySpreadConstraints:
- maxSkew: {{ .Values.thingsSearch.topologySpreadConstraints.maxSkew }}
topologyKey: {{ .Values.thingsSearch.topologySpreadConstraints.topologyKey }}
whenUnsatisfiable: {{ .Values.thingsSearch.topologySpreadConstraints.whenUnsatisfiable }}
labelSelector:
matchLabels:
app.kubernetes.io/name: {{ include "ditto.name" . }}-thingssearch
containers:
- name: {{ .Chart.Name }}-thingssearch
image: {{ printf "%s:%s" .Values.thingsSearch.image.repository ( default .Chart.AppVersion ( default .Values.dittoTag .Values.thingsSearch.image.tag ) ) }}
Expand Down
54 changes: 54 additions & 0 deletions deployment/helm/ditto/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ ingress:
nginxIngressVersion: "v1.8.0"
# Nginx Version. Check Supported Versions table from https://github.com/kubernetes/ingress-nginx to match k8s version.
nginxVersion: "1.21.6"
# Pod topology spread constraints for nginx-ingress controller
# ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
topologySpreadConstraints:
maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
annotations:
nginx.ingress.kubernetes.io/service-upstream: "true"
nginx.ingress.kubernetes.io/server-snippet: |
Expand Down Expand Up @@ -469,6 +475,12 @@ policies:
# affinity configuration for policies
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
affinity: {}
# Pod topology spread constraints for policies
# ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
topologySpreadConstraints:
maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
# podMonitor configuration for policies
podMonitor:
# enabled configures whether Pod Monitor is enabled, then a resource to scrape policies metrics will be created
Expand Down Expand Up @@ -663,6 +675,12 @@ things:
# affinity configuration for things
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
affinity: {}
# Pod topology spread constraints for things
# ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
topologySpreadConstraints:
maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
# podMonitor configuration for things
podMonitor:
# enabled configures whether Pod Monitor is enabled, then a resource to scrape things metrics will be created
Expand Down Expand Up @@ -879,6 +897,12 @@ thingsSearch:
# affinity configuration for things-search
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
affinity: {}
# Pod topology spread constraints for things-search
# ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
topologySpreadConstraints:
maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
# podMonitor configuration for things-search
podMonitor:
# enabled configures whether Pod Monitor is enabled, then a resource to scrape things search metrics will be created
Expand Down Expand Up @@ -1055,6 +1079,12 @@ connectivity:
# affinity configuration for connectivity
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
affinity: {}
# Pod topology spread constraints for connectivity
# ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
topologySpreadConstraints:
maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
# podMonitor configuration for connectivity
podMonitor:
# enabled configures whether Pod Monitor is enabled, then a resource to scrape connectivity metrics will be created
Expand Down Expand Up @@ -1314,6 +1344,12 @@ gateway:
# affinity configuration for gateway
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
affinity: {}
# Pod topology spread constraints for gateway
# ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
topologySpreadConstraints:
maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
# podMonitor configuration for gateway
podMonitor:
# enabled configures whether Pod Monitor is enabled, then a resource to scrape gateway metrics will be created
Expand Down Expand Up @@ -1471,6 +1507,12 @@ nginx:
# affinity configuration for nginx
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
affinity: {}
# Pod topology spread constraints for nginx
# ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
topologySpreadConstraints:
maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
# init containers for nginx
initContainers:
waitForGateway:
Expand Down Expand Up @@ -1517,6 +1559,12 @@ dittoui:
cpu: 0.1
# memoryMi defines the memory in mebibyte (MiB) used as "required" and "limit" in k8s
memoryMi: 64
# Pod topology spread constraints for Ditto UI
# ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
topologySpreadConstraints:
maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
# podDisruptionBudget ref: https://kubernetes.io/docs/tasks/run-application/configure-pdb/
podDisruptionBudget:
# enabled controls whether Ditto UI related PodDisruptionBudget should be created
Expand Down Expand Up @@ -1563,6 +1611,12 @@ swaggerui:
cpu: 0.1
# memoryMi defines the memory in mebibyte (MiB) used as "required" and "limit" in k8s
memoryMi: 64
# Pod topology spread constraints for the swagger ui
# ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/
topologySpreadConstraints:
maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
# podDisruptionBudget ref: https://kubernetes.io/docs/tasks/run-application/configure-pdb/
podDisruptionBudget:
# enabled controls whether swagger ui related PodDisruptionBudget should be created
Expand Down

0 comments on commit 93a94bb

Please sign in to comment.