apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "generic.fullname" . }} labels: {{- include "generic.labels" . | nindent 4 }} spec: replicas: {{ .Values.app.replicas | default 1 }} selector: matchLabels: app.kubernetes.io/name: {{ include "generic.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} template: metadata: labels: app.kubernetes.io/name: {{ include "generic.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- with .Values.app.podAnnotations }} annotations: {{- toYaml . | nindent 8 }} {{- end }} spec: serviceAccountName: {{ .Values.app.serviceAccountName | default "default" }} automountServiceAccountToken: true {{- with .Values.app.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.app.podSecurityContext }} securityContext: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.app.initContainers }} initContainers: {{- toYaml . | nindent 8 }} {{- end }} containers: # ---- 메인 컨테이너 (여기서 메인 컨테이너의 모든 속성을 끝까지 적고 닫는다) - name: {{ include "generic.name" . }} image: "{{ .Values.app.image.repository }}:{{ .Values.app.image.tag }}" imagePullPolicy: {{ .Values.app.image.pullPolicy | default "IfNotPresent" }} {{- with .Values.app.lifecycle }} lifecycle: {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.app.securityContext }} securityContext: {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.app.command }} command: {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.app.args }} args: {{- toYaml . | nindent 12 }} {{- end }} {{- if .Values.app.envFrom }} envFrom: {{- toYaml .Values.app.envFrom | nindent 12 }} {{- end }} {{- with .Values.app.env }} env: {{- toYaml . | nindent 12 }} {{- end }} {{- if .Values.app.ports }} ports: {{- range .Values.app.ports }} - name: {{ .name }} containerPort: {{ .containerPort }} {{- end }} {{- end }} {{- if or .Values.app.persistence.enabled .Values.app.extraVolumeMounts }} volumeMounts: {{- if .Values.app.persistence.enabled }} - name: data mountPath: {{ .Values.app.persistence.mountPath }} {{- end }} {{- with .Values.app.extraVolumeMounts }} {{- toYaml . | nindent 12 }} {{- end }} {{- end }} {{- with .Values.app.livenessProbe }} livenessProbe: {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.app.readinessProbe }} readinessProbe: {{- toYaml . | nindent 12 }} {{- end }} {{- with .Values.app.resources }} resources: {{- toYaml . | nindent 12 }} {{- end }} # ---- (여기서) extraContainers를 메인 컨테이너 '형제'로 렌더 {{- with .Values.app.extraContainers }} {{- toYaml . | nindent 8 }} {{- end }} {{- if or .Values.app.persistence.enabled .Values.app.extraVolumes }} volumes: {{- if .Values.app.persistence.enabled }} {{- $claim := coalesce .Values.app.persistence.existingClaim .Values.app.persistence.name (printf "%s-pvc" (include "generic.fullname" .)) }} - name: data persistentVolumeClaim: claimName: {{ $claim | quote }} {{- end }} {{- with .Values.app.extraVolumes }} {{- toYaml . | nindent 8 }} {{- end }} {{- end }} {{- with .Values.app.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.app.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.app.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.app.terminationGracePeriodSeconds }} terminationGracePeriodSeconds: {{ . }} {{- end }}