{{- include "mcp-server.validate" . }} {{- $tier := index .Values.tiers (include "mcp-server.tier" .) }} apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "mcp-server.name" . }} labels: {{- include "mcp-server.labels" . | nindent 4 }} spec: # replica 수는 배포가 아니라 가용성 등급이 정한다. 환경별 values의 tiers가 정본이다. replicas: {{ $tier.replicas }} selector: matchLabels: {{- include "mcp-server.selectorLabels" . | nindent 6 }} template: metadata: labels: {{- include "mcp-server.labels" . | nindent 8 }} annotations: # ConfigMap이 바뀌면 Pod을 다시 굴린다. 이게 없으면 설정을 고쳐도 # 기존 Pod이 옛 설정으로 계속 돌아 배포한 줄 알고 넘어가게 된다. checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} spec: # 진행 중인 tools/call이 잘려 부작용만 남는 것을 줄인다. terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} {{- with .Values.image.pullSecrets }} # 사내 registry가 인증을 요구할 때만 지정한다. 비워 두면 렌더링되지 않는다. imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} {{- if $tier.spreadAcrossNodes }} affinity: podAntiAffinity: # replica를 서로 다른 노드에 두려고 시도한다. required가 아니라 preferred인 이유는 # 노드가 부족할 때 Pod이 아예 뜨지 못하는 편이 같은 노드에 뜨는 것보다 나쁘기 때문이다. preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 podAffinityTerm: topologyKey: kubernetes.io/hostname labelSelector: matchLabels: {{- include "mcp-server.selectorLabels" . | nindent 20 }} {{- end }} containers: - name: mcp-server image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http containerPort: {{ .Values.ports.http }} - name: management containerPort: {{ .Values.ports.management }} env: - name: SPRING_PROFILES_ACTIVE value: ocp # ConfigMap을 jar 안의 설정보다 우선 적용한다. - name: SPRING_CONFIG_ADDITIONAL_LOCATION value: file:/opt/app/config/ - name: REDIS_HOST value: {{ .Values.redis.host | quote }} - name: REDIS_PORT value: {{ .Values.redis.port | quote }} - name: MANAGEMENT_SERVER_PORT value: {{ .Values.ports.management | quote }} {{- if .Values.toolService.apiKeySecret.name }} # Tool Service 호출용 API key. 값은 Secret이 소유하고 Chart는 이름만 안다. - name: TOOL_SERVER_API_KEY valueFrom: secretKeyRef: name: {{ .Values.toolService.apiKeySecret.name }} key: {{ .Values.toolService.apiKeySecret.key }} {{- end }} volumeMounts: - name: config mountPath: /opt/app/config readOnly: true # readiness는 첫 Tool 조회가 끝나고 usable snapshot이 있을 때만 UP이다. # 원천이 늦게 뜨는 환경에서 Pod을 죽이지 않도록 liveness에는 그 조건이 들어가지 않는다. readinessProbe: httpGet: path: /actuator/health/readiness port: management initialDelaySeconds: 10 periodSeconds: 10 livenessProbe: httpGet: path: /actuator/health/liveness port: management initialDelaySeconds: 20 periodSeconds: 20 resources: {{- toYaml .Values.resources | nindent 12 }} securityContext: allowPrivilegeEscalation: false capabilities: drop: ["ALL"] runAsNonRoot: true seccompProfile: type: RuntimeDefault volumes: - name: config configMap: name: {{ include "mcp-server.name" . }}-config