GitOps 이전까지 쓸 배포 파이프라인과 Portal 모드 Chart를 추가한다
GitOps 저장소도 ArgoCD Application도 아직 없어, 그때까지 이 저장소가 push 방식 파이프라인(.gitea/workflows/)을 임시로 소유한다. 무엇을 포기하는지와 넘길 때 할 일은 deploy/README.md에 적었다. Chart는 portal과 bundles 두 배포 모델을 모두 렌더링한다. ADR-0013이 ADR-0007을 대체했으므로 운영은 portal이 기준이지만, bundles 경로를 언제 삭제할지는 아직 정하지 않았다. - .gitea/workflows/ci.yaml, deploy-openshift.yaml - deploy/ci/render-manifests.sh, deploy/examples/ - Chart: mode 분기, selectedDeployment/tier helper, imagePullSecrets, toolService.apiKeySecret 참조 - extension-points.md에 미결 항목 9~12 추가 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,8 +2,27 @@
|
||||
설치 대상이 실제로 존재하는지 확인하고, 없으면 읽을 수 있는 메시지로 멈춘다.
|
||||
검사를 하지 않으면 오타가 "nil pointer" 같은 내부 오류로 나타나 원인을 찾기 어렵다.
|
||||
값을 반환하지 않으므로 각 template 파일의 첫 줄에서 한 번 부른다.
|
||||
|
||||
required의 결과는 반드시 변수에 담는다. 그대로 두면 검사한 값이 렌더링 결과에 출력되어
|
||||
이름 앞에 host와 CIDR이 붙어 나온다. 검사는 통과 여부만 남기고 아무것도 출력하지 않아야 한다.
|
||||
|
||||
mode에 따라 검사 대상이 다르다. portal 모드는 route 매핑을 Portal이 소유하므로(ADR-0013)
|
||||
deploymentKey가 없고 registryUrl이 필수다. bundles 모드는 그 반대다.
|
||||
*/}}
|
||||
{{- define "mcp-server.validate" -}}
|
||||
{{- if not (has .Values.mode (list "portal" "bundles")) -}}
|
||||
{{- fail (printf "mode는 portal 또는 bundles여야 한다: %v" .Values.mode) -}}
|
||||
{{- end -}}
|
||||
{{- if eq .Values.mode "portal" -}}
|
||||
{{- $_ := required "mode=portal이면 portal.deployment.name을 지정해야 한다." .Values.portal.deployment.name -}}
|
||||
{{- $_ = required "mode=portal이면 portal.registryUrl에 Portal registry 주소를 지정해야 한다. 환경별 values-{env}.yaml이 소유한다." .Values.portal.registryUrl -}}
|
||||
{{- if not (index .Values.tiers .Values.portal.deployment.tier) -}}
|
||||
{{- fail (printf "values.yaml의 tiers에 '%s' 등급이 없다." .Values.portal.deployment.tier) -}}
|
||||
{{- end -}}
|
||||
{{- if .Values.deploymentKey -}}
|
||||
{{- fail "mode=portal에서는 deploymentKey를 쓰지 않는다. route는 /mcp/{routeKey} URI에서만 결정된다(ADR-0013)." -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $key := required "deploymentKey를 지정해야 한다. 예: --set deploymentKey=processing-critical" .Values.deploymentKey -}}
|
||||
{{- $deployment := index .Values.deployments $key -}}
|
||||
{{- if not $deployment -}}
|
||||
@@ -12,20 +31,42 @@
|
||||
{{- if not (index .Values.tiers $deployment.tier) -}}
|
||||
{{- fail (printf "values.yaml의 tiers에 '%s' 등급이 없다. deployments의 tier와 tiers의 key가 어긋났다." $deployment.tier) -}}
|
||||
{{- end -}}
|
||||
{{- required "global.mcpHost에 환경별 공개 MCP host를 지정해야 한다." .Values.global.mcpHost -}}
|
||||
{{- required "route.sourceAllowlist에 Agent Builder의 고정 egress CIDR을 지정해야 한다." .Values.route.sourceAllowlist -}}
|
||||
{{- $publicPath := required (printf "deployments.%s.publicPath를 지정해야 한다." $key) $deployment.publicPath -}}
|
||||
{{- if not (regexMatch "^/mcp/[a-z0-9-]+$" $publicPath) -}}
|
||||
{{- fail (printf "deployments.%s.publicPath는 /mcp/<영문 소문자·숫자·하이픈> 형식이어야 한다: %s" $key $publicPath) -}}
|
||||
{{- end -}}
|
||||
{{- $_ := required "global.mcpHost에 환경별 공개 MCP host를 지정해야 한다." .Values.global.mcpHost -}}
|
||||
{{- $_ = required "route.sourceAllowlist에 Agent Builder의 고정 egress CIDR을 지정해야 한다." .Values.route.sourceAllowlist -}}
|
||||
{{- $publicPath := required "선택된 배포의 publicPath를 지정해야 한다." (include "mcp-server.selectedDeployment" . | fromYaml).publicPath -}}
|
||||
{{- if not (regexMatch "^/mcp(/[a-z0-9-]+)?$" $publicPath) -}}
|
||||
{{- fail (printf "publicPath는 /mcp 또는 /mcp/<영문 소문자·숫자·하이픈> 형식이어야 한다: %s" $publicPath) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
리소스 이름. 하나의 namespace에 여러 MCP 배포가 들어가므로 배포마다 다른 이름을 쓴다.
|
||||
설치할 배포 하나를 dict로 돌려준다. mode가 그것을 어디서 읽는가의 차이만 여기서 흡수하고,
|
||||
나머지 template은 어느 모드인지 모른 채 같은 필드(name·tier·publicPath)를 쓴다.
|
||||
호출부는 `include ... | fromYaml`로 받는다. Helm helper는 문자열만 반환하기 때문이다.
|
||||
검사를 부르지 않는다. validate가 이 helper를 사용하므로 서로를 부르면 순환한다.
|
||||
*/}}
|
||||
{{- define "mcp-server.selectedDeployment" -}}
|
||||
{{- if eq .Values.mode "portal" -}}
|
||||
{{ toYaml .Values.portal.deployment }}
|
||||
{{- else -}}
|
||||
{{ toYaml (index .Values.deployments .Values.deploymentKey) }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
리소스 이름. 하나의 namespace에 여러 MCP 배포가 들어갈 수 있으므로 배포마다 다른 이름을 쓴다.
|
||||
*/}}
|
||||
{{- define "mcp-server.name" -}}
|
||||
{{- include "mcp-server.validate" . -}}
|
||||
{{- (index .Values.deployments .Values.deploymentKey).name -}}
|
||||
{{- (include "mcp-server.selectedDeployment" . | fromYaml).name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
선택된 배포의 가용성 등급 이름.
|
||||
*/}}
|
||||
{{- define "mcp-server.tier" -}}
|
||||
{{- (include "mcp-server.selectedDeployment" . | fromYaml).tier -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
@@ -38,12 +79,12 @@ Redis key namespace가 되는 식별자.
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
이 MCP가 보는 Tool Service의 host:port.
|
||||
이 MCP가 보는 Tool Service의 host:port. bundles 모드에서만 쓴다.
|
||||
MCP와 Tool Service는 같은 namespace이므로 서비스 이름만으로 FQDN이 완성된다.
|
||||
호출 대상 주소는 오직 이 설정에서만 온다(계약 v0.2 §1). 매니페스트 응답은 이 값을 바꿀 수 없다.
|
||||
portal 모드에서는 이 주소를 Portal registry가 소유하므로 이 helper를 부르지 않는다.
|
||||
*/}}
|
||||
{{- define "mcp-server.toolServiceHost" -}}
|
||||
{{- include "mcp-server.validate" . -}}
|
||||
{{- $deployment := index .Values.deployments .Values.deploymentKey -}}
|
||||
{{- printf "%s.%s.svc.cluster.local:%v" $deployment.service .Release.Namespace .Values.toolService.port -}}
|
||||
{{- end -}}
|
||||
@@ -54,7 +95,8 @@ app.kubernetes.io/name: {{ include "mcp-server.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
app.kubernetes.io/component: mcp-server
|
||||
app.kubernetes.io/part-of: ax-hub
|
||||
ax-hub/tier: {{ (index .Values.deployments .Values.deploymentKey).tier }}
|
||||
ax-hub/mode: {{ .Values.mode }}
|
||||
ax-hub/tier: {{ include "mcp-server.tier" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "mcp-server.selectorLabels" -}}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
# 배포별로 달라지는 설정만 담는다.
|
||||
# 환경과 무관한 기본값(timeout, 상한, management 포트 등)은 jar 안의 application-ocp.yml이 소유하고,
|
||||
# 이 파일이 같은 이름으로 덮어써 identity와 bundle만 배포 시점에 결정한다.
|
||||
# 이 파일이 같은 이름으로 덮어써 identity와 Tool 원천만 배포 시점에 결정한다.
|
||||
{{- include "mcp-server.validate" . }}
|
||||
{{- $deployment := index .Values.deployments .Values.deploymentKey }}
|
||||
{{- $toolServiceHost := include "mcp-server.toolServiceHost" . }}
|
||||
{{- $deployment := include "mcp-server.selectedDeployment" . | fromYaml }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
@@ -19,19 +18,41 @@ data:
|
||||
endpoint-path: {{ $deployment.publicPath | quote }}
|
||||
|
||||
registry:
|
||||
refreshIntervalSeconds: {{ .Values.mcp.refreshIntervalSeconds }}
|
||||
refreshJitterSeconds: {{ .Values.mcp.refreshJitterSeconds }}
|
||||
refresh-interval-seconds: {{ .Values.mcp.refreshIntervalSeconds }}
|
||||
refresh-jitter-seconds: {{ .Values.mcp.refreshJitterSeconds }}
|
||||
|
||||
discovery:
|
||||
# 운영 profile은 Tool Service 매니페스트만 원천으로 쓴다.
|
||||
enabled: true
|
||||
|
||||
redis:
|
||||
# Portal 조회가 실패한 cold start에서만 읽는 fallback key다.
|
||||
# 포털이 쓰는 key와 반드시 같아야 한다.
|
||||
portal-registry-key: {{ .Values.portal.registryRedisKey | quote }}
|
||||
{{- if eq .Values.mode "portal" }}
|
||||
|
||||
# route↔Tool Service 매핑의 원천은 Portal이다(ADR-0013).
|
||||
# 배포 하나가 N개 route를 서비스하고, route key는 /mcp/{routeKey} URI에서만 결정된다.
|
||||
# 매핑이 바뀌어도 이 ConfigMap을 고치지 않는다. 그것이 Portal을 원천으로 둔 이유다.
|
||||
portal:
|
||||
enabled: true
|
||||
registry-url: {{ .Values.portal.registryUrl | quote }}
|
||||
refresh-interval-seconds: {{ .Values.portal.refreshIntervalSeconds }}
|
||||
|
||||
# Portal이 주소를 소유하므로 정적 bundle을 선언하지 않는다.
|
||||
bundles: []
|
||||
{{- else }}
|
||||
|
||||
portal:
|
||||
enabled: false
|
||||
|
||||
# MCP 배포 하나는 Tool Service 하나만 본다(ADR-0007).
|
||||
# 이 목록은 항상 한 항목이며, 늘리려면 배포를 하나 더 만든다.
|
||||
# 주소는 여기서 조립한다. values에 URL을 적기 시작하면 오타가 라우팅 사고가 된다.
|
||||
bundles:
|
||||
- id: {{ .Values.deploymentKey | quote }}
|
||||
namePrefix: {{ $deployment.namePrefix | quote }}
|
||||
manifestUrl: http://{{ $toolServiceHost }}{{ .Values.toolService.manifestPath }}
|
||||
baseEndpoint: http://{{ $toolServiceHost }}{{ .Values.toolService.basePath }}
|
||||
manifestUrl: http://{{ include "mcp-server.toolServiceHost" . }}{{ .Values.toolService.manifestPath }}
|
||||
baseEndpoint: http://{{ include "mcp-server.toolServiceHost" . }}{{ .Values.toolService.basePath }}
|
||||
enabled: true
|
||||
{{- end }}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{{- include "mcp-server.validate" . }}
|
||||
{{- $tier := index .Values.tiers (index .Values.deployments .Values.deploymentKey).tier }}
|
||||
{{- $tier := index .Values.tiers (include "mcp-server.tier" .) }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
@@ -17,12 +17,17 @@ spec:
|
||||
labels:
|
||||
{{- include "mcp-server.labels" . | nindent 8 }}
|
||||
annotations:
|
||||
# ConfigMap이 바뀌면 Pod을 다시 굴린다. 이게 없으면 bundle 설정을 고쳐도
|
||||
# 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:
|
||||
@@ -57,10 +62,20 @@ spec:
|
||||
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
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{{- include "mcp-server.validate" . }}
|
||||
{{- $tier := index .Values.tiers (index .Values.deployments .Values.deploymentKey).tier }}
|
||||
{{- $tier := index .Values.tiers (include "mcp-server.tier" .) }}
|
||||
{{- if $tier.podDisruptionBudget }}
|
||||
# 중요 등급 배포가 자발적 중단(노드 drain, 클러스터 업그레이드) 중에도 최소 1개를 남기게 한다.
|
||||
#
|
||||
# replica를 2 이상으로 올려도 PDB가 없으면 노드 drain이 두 Pod을 한꺼번에 내릴 수 있다.
|
||||
# 등급을 나눈 목적이 "중요 Tool은 다운이 없어야 한다"이므로 이 둘은 함께 가야 한다(ADR-0007).
|
||||
# 등급을 나눈 목적이 "중요 Tool은 다운이 없어야 한다"이므로 이 둘은 함께 가야 한다.
|
||||
#
|
||||
# NetworkPolicy와 달리 조건이 붙는다. 저쪽은 인가의 전제라 끌 수 없지만 이것은 가용성 정책이고,
|
||||
# replica 1인 dev에서는 PDB가 오히려 노드 drain을 영구히 막는다.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
{{- include "mcp-server.validate" . }}
|
||||
{{- $deployment := index .Values.deployments .Values.deploymentKey }}
|
||||
{{- $deployment := include "mcp-server.selectedDeployment" . | fromYaml }}
|
||||
# OpenShift Route의 path는 prefix 매칭이다. portal 모드에서 path가 "/mcp"이면
|
||||
# /mcp/{routeKey} 전체가 이 Route 하나로 들어오고, route 구분은 컨테이너가 한다(ADR-0013).
|
||||
apiVersion: route.openshift.io/v1
|
||||
kind: Route
|
||||
metadata:
|
||||
|
||||
Reference in New Issue
Block a user