From 4d67fb64f974609418fa1db2a35187b9126bfe1d Mon Sep 17 00:00:00 2001 From: Mayne0213 Date: Thu, 8 Jan 2026 13:25:46 +0900 Subject: [PATCH] FEAT(web-apps): enable HA with replica 2 and soft anti-affinity - Add replicaCount: 2 to all web applications - Add soft pod anti-affinity for node distribution - Update chart template to handle affinity correctly - Configure affinity for todo, portfolio, jovies, jotion, joossam, joossam-dev, jaejadle, jaejadle-dev --- charts/web-app/templates/deployment.yaml | 13 +++++++++++++ charts/web-app/values.yaml | 11 ++++++++--- jaejadle-dev/helm-values.yaml | 10 +++++++++- jaejadle/helm-values.yaml | 10 +++++++++- joossam-dev/helm-values.yaml | 10 +++++++++- joossam/helm-values.yaml | 10 +++++++++- jotion/helm-values.yaml | 10 +++++++++- jovies/helm-values.yaml | 10 +++++++++- portfolio/helm-values.yaml | 10 +++++++++- todo/helm-values.yaml | 10 +++++++++- 10 files changed, 93 insertions(+), 11 deletions(-) diff --git a/charts/web-app/templates/deployment.yaml b/charts/web-app/templates/deployment.yaml index b470b7b..3683ef9 100644 --- a/charts/web-app/templates/deployment.yaml +++ b/charts/web-app/templates/deployment.yaml @@ -76,7 +76,20 @@ spec: {{- end }} {{- with .Values.affinity }} affinity: + {{- if and .podAntiAffinity .podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution }} + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + {{- range .podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution }} + - weight: {{ .weight }} + podAffinityTerm: + labelSelector: + matchLabels: + app: {{ include "web-app.fullname" $ }} + topologyKey: {{ .podAffinityTerm.topologyKey }} + {{- end }} + {{- else }} {{- toYaml . | nindent 8 }} + {{- end }} {{- end }} {{- with .Values.tolerations }} tolerations: diff --git a/charts/web-app/values.yaml b/charts/web-app/values.yaml index d11f9a9..414813a 100644 --- a/charts/web-app/values.yaml +++ b/charts/web-app/values.yaml @@ -15,7 +15,7 @@ imagePullSecrets: - name: ghcr-secret # Replicas -replicaCount: 1 +replicaCount: 2 # Container port containerPort: 3000 @@ -106,5 +106,10 @@ nodeSelector: {} # Tolerations tolerations: [] -# Affinity -affinity: {} +# Affinity - Soft Anti-Affinity to spread pods across nodes +affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + topologyKey: kubernetes.io/hostname diff --git a/jaejadle-dev/helm-values.yaml b/jaejadle-dev/helm-values.yaml index c240e7a..19af749 100644 --- a/jaejadle-dev/helm-values.yaml +++ b/jaejadle-dev/helm-values.yaml @@ -11,7 +11,7 @@ image: imagePullSecrets: - name: ghcr-secret -replicaCount: 1 +replicaCount: 2 containerPort: 3000 service: @@ -100,3 +100,11 @@ externalSecret: remoteRef: key: jaejadle-dev property: CODE + +# Affinity - Soft Anti-Affinity to spread pods across nodes +affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + topologyKey: kubernetes.io/hostname diff --git a/jaejadle/helm-values.yaml b/jaejadle/helm-values.yaml index 58ba879..048bcb4 100644 --- a/jaejadle/helm-values.yaml +++ b/jaejadle/helm-values.yaml @@ -11,7 +11,7 @@ image: imagePullSecrets: - name: ghcr-secret -replicaCount: 1 +replicaCount: 2 containerPort: 3000 service: @@ -100,3 +100,11 @@ externalSecret: remoteRef: key: jaejadle property: CODE + +# Affinity - Soft Anti-Affinity to spread pods across nodes +affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + topologyKey: kubernetes.io/hostname diff --git a/joossam-dev/helm-values.yaml b/joossam-dev/helm-values.yaml index daf1fe6..60692d5 100644 --- a/joossam-dev/helm-values.yaml +++ b/joossam-dev/helm-values.yaml @@ -11,7 +11,7 @@ image: imagePullSecrets: - name: ghcr-secret -replicaCount: 1 +replicaCount: 2 containerPort: 8000 service: @@ -56,3 +56,11 @@ healthCheck: externalSecret: enabled: false + +# Affinity - Soft Anti-Affinity to spread pods across nodes +affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + topologyKey: kubernetes.io/hostname diff --git a/joossam/helm-values.yaml b/joossam/helm-values.yaml index 0bd6880..cc42ecd 100644 --- a/joossam/helm-values.yaml +++ b/joossam/helm-values.yaml @@ -11,7 +11,7 @@ image: imagePullSecrets: - name: ghcr-secret -replicaCount: 1 +replicaCount: 2 containerPort: 8000 service: @@ -56,3 +56,11 @@ healthCheck: externalSecret: enabled: false + +# Affinity - Soft Anti-Affinity to spread pods across nodes +affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + topologyKey: kubernetes.io/hostname diff --git a/jotion/helm-values.yaml b/jotion/helm-values.yaml index b5c6edc..c29055f 100644 --- a/jotion/helm-values.yaml +++ b/jotion/helm-values.yaml @@ -11,7 +11,7 @@ image: imagePullSecrets: - name: ghcr-secret -replicaCount: 1 +replicaCount: 2 containerPort: 3000 service: @@ -82,3 +82,11 @@ externalSecret: remoteRef: key: jotion property: DATABASE_URL + +# Affinity - Soft Anti-Affinity to spread pods across nodes +affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + topologyKey: kubernetes.io/hostname diff --git a/jovies/helm-values.yaml b/jovies/helm-values.yaml index 4538028..790baf8 100644 --- a/jovies/helm-values.yaml +++ b/jovies/helm-values.yaml @@ -8,7 +8,7 @@ image: tag: latest # Updated by ArgoCD Image Updater pullPolicy: Always -replicaCount: 1 +replicaCount: 2 containerPort: 3000 service: @@ -62,3 +62,11 @@ env: externalSecret: enabled: false + +# Affinity - Soft Anti-Affinity to spread pods across nodes +affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + topologyKey: kubernetes.io/hostname diff --git a/portfolio/helm-values.yaml b/portfolio/helm-values.yaml index 1b31ddf..2488160 100644 --- a/portfolio/helm-values.yaml +++ b/portfolio/helm-values.yaml @@ -10,7 +10,7 @@ image: imagePullSecrets: [] -replicaCount: 1 +replicaCount: 2 containerPort: 3000 service: @@ -66,3 +66,11 @@ env: externalSecret: enabled: false + +# Affinity - Soft Anti-Affinity to spread pods across nodes +affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + topologyKey: kubernetes.io/hostname diff --git a/todo/helm-values.yaml b/todo/helm-values.yaml index 886c2c1..2a7b352 100644 --- a/todo/helm-values.yaml +++ b/todo/helm-values.yaml @@ -11,7 +11,7 @@ image: # No imagePullSecrets needed (public or already configured) imagePullSecrets: [] -replicaCount: 1 +replicaCount: 2 containerPort: 3000 service: @@ -82,3 +82,11 @@ externalSecret: remoteRef: key: todo property: DATABASE_URL + +# Affinity - Soft Anti-Affinity to spread pods across nodes +affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + topologyKey: kubernetes.io/hostname