Skip to content

Commit

Permalink
Update deployment template to allow requiredDuringSchedulingIgnoredDu…
Browse files Browse the repository at this point in the history
…ringExecution in podAntiAffinity (#59)

Signed-off-by: salvadorcruz <[email protected]>
  • Loading branch information
salgum10 authored Jan 24, 2025
1 parent 465b4bf commit 6d155ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions charts/monochart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v1
description: A declarative helm chart for deploying common types of services on Kubernetes
name: monochart
version: 1.0.10
appVersion: 1.0.10
version: 1.0.11
appVersion: 1.0.11
home: https://github.com/Lowess/charts/tree/master/charts/monochart
icon: https://raw.githubusercontent.com/cloudposse/charts/master/incubator/monochart/logo.png
maintainers:
Expand Down
7 changes: 2 additions & 5 deletions charts/monochart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,12 @@ spec:
{{- if .Values.deployment.affinity }}
affinity:
{{- if or .Values.deployment.affinity.podAntiAffinity (eq .Values.deployment.affinity.affinityRule "ShouldBeOnDifferentNode") }}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
podAntiAffinity:
{{- if .Values.deployment.affinity.podAntiAffinity }}
{{- if .Values.deployment.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution }}
{{- with .Values.deployment.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution }}
{{- with .Values.deployment.affinity.podAntiAffinity }}
{{ toYaml . | indent 10 }}
{{- end }}
{{- end }}
{{- end }}
{{- if eq .Values.deployment.affinity.affinityRule "ShouldBeOnDifferentNode" }}
{{- include "monochart.affinityRule.ShouldBeOnDifferentNode" . | nindent 10 }}
{{- end }}
Expand Down
14 changes: 14 additions & 0 deletions charts/monochart/values.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@ deployment:
values:
- "postgresql"
topologyKey: "kubernetes.io/hostname"
# podAntiAffinity to deploy one pod per node (Example for squid)
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
release: squid-proxy
topologyKey: "kubernetes.io/hostname"
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
release: squid-proxy # Match pods with this label
topologyKey: "kubernetes.io/hostname" # Spread pods across nodes
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
Expand Down

0 comments on commit 6d155ec

Please sign in to comment.