Files
web-apps/charts/web-app/templates/deployment.yaml
Mayne0213 4d67fb64f9 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
2026-01-08 13:25:46 +09:00

98 lines
3.5 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "web-app.fullname" . }}
labels:
{{- include "web-app.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "web-app.selectorLabels" . | nindent 6 }}
strategy:
type: {{ .Values.strategy.type }}
{{- if eq .Values.strategy.type "RollingUpdate" }}
rollingUpdate:
maxUnavailable: {{ .Values.strategy.rollingUpdate.maxUnavailable }}
maxSurge: {{ .Values.strategy.rollingUpdate.maxSurge }}
{{- end }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
template:
metadata:
labels:
{{- include "web-app.selectorLabels" . | nindent 8 }}
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ include "web-app.fullname" . }}
image: {{ include "web-app.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.containerPort }}
protocol: TCP
{{- with .Values.env }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.envFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if .Values.healthCheck.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.healthCheck.path }}
port: {{ .Values.containerPort }}
initialDelaySeconds: {{ .Values.healthCheck.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.healthCheck.livenessProbe.periodSeconds }}
readinessProbe:
httpGet:
path: {{ .Values.healthCheck.path }}
port: {{ .Values.containerPort }}
initialDelaySeconds: {{ .Values.healthCheck.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.healthCheck.readinessProbe.periodSeconds }}
{{- if .Values.healthCheck.startupProbe }}
startupProbe:
httpGet:
path: {{ .Values.healthCheck.path }}
port: {{ .Values.containerPort }}
periodSeconds: {{ .Values.healthCheck.startupProbe.periodSeconds | default 10 }}
failureThreshold: {{ .Values.healthCheck.startupProbe.failureThreshold | default 30 }}
{{- end }}
{{- end }}
restartPolicy: Always
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- 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:
{{- toYaml . | nindent 8 }}
{{- end }}