Skip to content

Commit

Permalink
Merge pull request #75 from casavo/SRE-164-avoid-pod-of-the-same-serv…
Browse files Browse the repository at this point in the history
…ice-stay-in-same-node

chore(k8s): add topologySpreadConstraints
  • Loading branch information
AlessandroLorenzi authored Feb 7, 2024
2 parents 5f6d25f + 33cd9b3 commit b9a778b
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/be-multisvc/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type: application
name: be-multisvc
description: Generic multi service BE application

version: 0.17.1
version: 0.17.2
kubeVersion: ">=1.23.0-0"

home: https://github.com/Casavo/charts
Expand Down
9 changes: 9 additions & 0 deletions charts/be-multisvc/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ spec:
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.spreadContainersAccrossNodes }}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
{{- include "app.selectorLabels" . | nindent 14 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
{{- with .Values.command }}
Expand Down
2 changes: 2 additions & 0 deletions charts/be-multisvc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ podDisruptionBudget: {}
# minAvailable: 1
# maxUnavailable: 1

spreadContainersAccrossNodes: false

## See `kubectl explain deployment.spec.strategy` for more
## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy
deploymentStrategy:
Expand Down
2 changes: 1 addition & 1 deletion charts/be-web/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type: application
name: be-web
description: Generic web BE application

version: 0.20.1
version: 0.20.2
kubeVersion: ">=1.23.0-0"

home: https://github.com/Casavo/charts
Expand Down
9 changes: 9 additions & 0 deletions charts/be-web/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ spec:
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.spreadContainersAccrossNodes }}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
{{- include "app.selectorLabels" . | nindent 14 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
{{- with .Values.securityContext }}
Expand Down
2 changes: 2 additions & 0 deletions charts/be-web/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ podDisruptionBudget: {}
# minAvailable: 1
# maxUnavailable: 1

spreadContainersAccrossNodes: false

## See `kubectl explain deployment.spec.strategy` for more
## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy
deploymentStrategy:
Expand Down
2 changes: 1 addition & 1 deletion charts/fe-nextjs/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type: application
name: fe-nextjs
description: Generic FE NextJS application

version: 0.5.1
version: 0.5.2
kubeVersion: ">=1.23.0-0"

home: https://github.com/Casavo/charts
Expand Down
9 changes: 9 additions & 0 deletions charts/fe-nextjs/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ spec:
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.spreadContainersAccrossNodes }}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
{{- include "app.selectorLabels" . | nindent 14 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
{{- with .Values.securityContext }}
Expand Down
2 changes: 2 additions & 0 deletions charts/fe-nextjs/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ podDisruptionBudget: {}
# minAvailable: 1
# maxUnavailable: 1

spreadContainersAccrossNodes: false

## See `kubectl explain deployment.spec.strategy` for more
## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy
deploymentStrategy:
Expand Down
2 changes: 1 addition & 1 deletion charts/fe-static/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type: application
name: fe-static
description: Generic FE static application

version: 0.4.1
version: 0.4.2
kubeVersion: ">=1.23.0-0"

home: https://github.com/Casavo/charts
Expand Down
9 changes: 9 additions & 0 deletions charts/fe-static/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ spec:
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.spreadContainersAccrossNodes }}
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
{{- include "app.selectorLabels" . | nindent 14 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
{{- with .Values.securityContext }}
Expand Down
2 changes: 2 additions & 0 deletions charts/fe-static/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ podDisruptionBudget: {}
# minAvailable: 1
# maxUnavailable: 1

spreadContainersAccrossNodes: false

## See `kubectl explain deployment.spec.strategy` for more
## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy
deploymentStrategy:
Expand Down

0 comments on commit b9a778b

Please sign in to comment.