Initial commit

This commit is contained in:
2026-08-05 15:54:25 +09:00
commit a4eb5a580f
168 changed files with 12057 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
apiVersion: v2
name: mcp-server
description: AX HUB MCP Server - Agent Builder와 Tool Service 사이의 stateless 실행 계층
type: application
# Chart 자체의 버전. 애플리케이션 버전과 따로 올린다.
version: 0.1.0
# 기본 이미지 tag. 배포 시 values의 image.tag가 덮어쓴다.
appVersion: "0.1.0"

View File

@@ -0,0 +1,62 @@
{{/*
, .
"nil pointer" .
template .
*/}}
{{- define "mcp-server.validate" -}}
{{- $key := required "deploymentKey를 지정해야 한다. 예: --set deploymentKey=processing-critical" .Values.deploymentKey -}}
{{- $deployment := index .Values.deployments $key -}}
{{- if not $deployment -}}
{{- fail (printf "values.yaml의 deployments에 '%s'가 없다. 오타이거나 아직 토폴로지에 추가하지 않은 배포다." $key) -}}
{{- end -}}
{{- 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 -}}
{{- end -}}
{{/*
. namespace에 MCP .
*/}}
{{- define "mcp-server.name" -}}
{{- include "mcp-server.validate" . -}}
{{- (index .Values.deployments .Values.deploymentKey).name -}}
{{- end -}}
{{/*
Redis key namespace가 .
. values에 dev/test/prod가
, Tool snapshot을 .
*/}}
{{- define "mcp-server.identity" -}}
{{- printf "%s-%s" (include "mcp-server.name" .) .Values.global.env -}}
{{- end -}}
{{/*
MCP가 Tool Service의 host:port.
MCP와 Tool Service는 namespace이므로 FQDN이 .
( v0.2 §1). .
*/}}
{{- 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 -}}
{{- define "mcp-server.labels" -}}
app: {{ include "mcp-server.name" . }}
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 }}
{{- end -}}
{{- define "mcp-server.selectorLabels" -}}
app: {{ include "mcp-server.name" . }}
{{- end -}}

View File

@@ -0,0 +1,37 @@
# 배포별로 달라지는 설정만 담는다.
# 환경과 무관한 기본값(timeout, 상한, management 포트 등)은 jar 안의 application-ocp.yml이 소유하고,
# 이 파일이 같은 이름으로 덮어써 identity와 bundle만 배포 시점에 결정한다.
{{- include "mcp-server.validate" . }}
{{- $deployment := index .Values.deployments .Values.deploymentKey }}
{{- $toolServiceHost := include "mcp-server.toolServiceHost" . }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "mcp-server.name" . }}-config
labels:
{{- include "mcp-server.labels" . | nindent 4 }}
data:
application-ocp.yml: |
mcp:
# "{배포 이름}-{global.env}"로 조립된다. 환경끼리 Redis key가 겹치지 않는다.
identity: {{ include "mcp-server.identity" . }}
# Agent Builder에 등록한 공개 path를 컨테이너가 그대로 처리한다. Route rewrite는 사용하지 않는다.
endpoint-path: {{ $deployment.publicPath | quote }}
registry:
refreshIntervalSeconds: {{ .Values.mcp.refreshIntervalSeconds }}
refreshJitterSeconds: {{ .Values.mcp.refreshJitterSeconds }}
discovery:
# 운영 profile은 Tool Service 매니페스트만 원천으로 쓴다.
enabled: true
# 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 }}
enabled: true

View File

@@ -0,0 +1,88 @@
{{- include "mcp-server.validate" . }}
{{- $tier := index .Values.tiers (index .Values.deployments .Values.deploymentKey).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을 다시 굴린다. 이게 없으면 bundle 설정을 고쳐도
# 기존 Pod이 옛 설정으로 계속 돌아 배포한 줄 알고 넘어가게 된다.
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
spec:
# 진행 중인 tools/call이 잘려 부작용만 남는 것을 줄인다.
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
{{- 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 }}
volumeMounts:
- name: config
mountPath: /opt/app/config
readOnly: true
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

View File

@@ -0,0 +1,42 @@
# 이 서버는 인증·인가를 하지 않는다(ADR-0006). 호출자를 제한하는 것은 이 정책이며,
# 이것이 빠지면 클러스터 안의 어떤 Pod이든 /mcp로 Tool을 실행할 수 있다.
# 선택적 강화가 아니라 ADR-0006의 성립 조건이므로 비활성화 스위치를 두지 않는다.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "mcp-server.name" . }}-ingress
labels:
{{- include "mcp-server.labels" . | nindent 4 }}
spec:
podSelector:
matchLabels:
{{- include "mcp-server.selectorLabels" . | nindent 6 }}
policyTypes:
- Ingress
ingress:
# 공개 Route를 거친 요청은 OpenShift Ingress Controller에서 들어온다.
- from:
- namespaceSelector:
matchLabels:
policy-group.network.openshift.io/ingress: ""
ports:
- protocol: TCP
port: {{ .Values.ports.http }}
# 업무 포트는 Agent Builder namespace에서만 받는다.
# namespaceSelector가 참조하는 label은 대상 namespace에 실제로 붙어 있어야 한다.
# OpenShift가 자동으로 넣어 주는 kubernetes.io/metadata.name을 사용한다.
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: {{ .Values.global.agentBuilderNamespace }}
ports:
- protocol: TCP
port: {{ .Values.ports.http }}
# management 포트는 관제만 접근한다. 외부로 노출하지 않는다.
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: {{ .Values.global.monitoringNamespace }}
ports:
- protocol: TCP
port: {{ .Values.ports.management }}

View File

@@ -0,0 +1,24 @@
{{- include "mcp-server.validate" . }}
{{- $tier := index .Values.tiers (index .Values.deployments .Values.deploymentKey).tier }}
{{- if $tier.podDisruptionBudget }}
# 중요 등급 배포가 자발적 중단(노드 drain, 클러스터 업그레이드) 중에도 최소 1개를 남기게 한다.
#
# replica를 2 이상으로 올려도 PDB가 없으면 노드 drain이 두 Pod을 한꺼번에 내릴 수 있다.
# 등급을 나눈 목적이 "중요 Tool은 다운이 없어야 한다"이므로 이 둘은 함께 가야 한다(ADR-0007).
#
# NetworkPolicy와 달리 조건이 붙는다. 저쪽은 인가의 전제라 끌 수 없지만 이것은 가용성 정책이고,
# replica 1인 dev에서는 PDB가 오히려 노드 drain을 영구히 막는다.
# 조건이 거짓이면 이 파일은 주석까지 포함해 아무것도 렌더링하지 않는다.
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ include "mcp-server.name" . }}
labels:
{{- include "mcp-server.labels" . | nindent 4 }}
spec:
# minAvailable을 replica 수와 같게 두면 drain이 영원히 막힌다. 1을 남기는 것으로 충분하다.
minAvailable: 1
selector:
matchLabels:
{{- include "mcp-server.selectorLabels" . | nindent 6 }}
{{- end }}

View File

@@ -0,0 +1,24 @@
{{- include "mcp-server.validate" . }}
{{- $deployment := index .Values.deployments .Values.deploymentKey }}
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: {{ include "mcp-server.name" . }}
labels:
{{- include "mcp-server.labels" . | nindent 4 }}
annotations:
haproxy.router.openshift.io/timeout: {{ .Values.route.timeout }}
haproxy.router.openshift.io/ip_allowlist: {{ .Values.route.sourceAllowlist | quote }}
spec:
host: {{ .Values.global.mcpHost | quote }}
path: {{ $deployment.publicPath | quote }}
to:
kind: Service
name: {{ include "mcp-server.name" . }}
weight: 100
port:
targetPort: http
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
wildcardPolicy: None

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "mcp-server.name" . }}
labels:
{{- include "mcp-server.labels" . | nindent 4 }}
spec:
selector:
{{- include "mcp-server.selectorLabels" . | nindent 4 }}
ports:
- name: http
port: {{ .Values.ports.http }}
targetPort: http

View File

@@ -0,0 +1,27 @@
# dev 환경. 배포마다 Pod 1개로 구성한다.
#
# dev에서는 중요 등급도 replica 1이다. rolling update 중 수십 초 공백이 생기지만
# dev는 가용성 목표 대상이 아니다. 중요 등급의 replica 하한과 PDB는 prod에서만 강제하며
# HelmDeploymentContractTest가 그 사실을 고정한다.
#
# 어느 배포를 설치할지는 이 파일이 정하지 않는다. --set deploymentKey=<key>로 고른다.
# TODO: namespace가 확정되면 agentBuilderNamespace를 교체한다.
global:
env: dev
agentBuilderNamespace: ax-hub-agentbuilder-dev
mcpHost: mcp-dev.apps.example.internal
route:
# TODO: Agent Builder의 실제 고정 egress CIDR로 교체한다.
sourceAllowlist: 192.0.2.0/24
tiers:
critical:
replicas: 1
podDisruptionBudget: false
spreadAcrossNodes: false
standard:
replicas: 1
podDisruptionBudget: false
spreadAcrossNodes: false

View File

@@ -0,0 +1,41 @@
# prod 환경.
#
# replica는 배포 하나가 받는 트래픽 기준으로 잡는다. 업무 × 등급으로 나뉘어 있으므로
# 배포 하나가 받는 몫은 전체를 하나로 묶었을 때의 일부다. 등급별 기준은 아래가 정본이다.
#
# 조회 부하 = replica 수 / 주기. 1:1이라 bundle 수는 항상 1이다(ADR-0007).
# 중요 등급 3 replica / 30초 = 배포당 초당 0.1회. Tool Service 한 대가 받는 몫이 그대로 이 값이다.
#
# 중요 등급은 replica 2 이상과 PodDisruptionBudget이 필수다.
# 1이면 rolling update 중 반드시 공백이 생기고, PDB가 없으면 노드 drain이 마지막 Pod을 내린다.
# HelmDeploymentContractTest가 replica·PDB·노드 분산 values를 정적으로 검사한다.
#
# 어느 배포를 설치할지는 이 파일이 정하지 않는다. --set deploymentKey=<key>로 고른다.
# TODO: namespace가 확정되면 agentBuilderNamespace를 교체한다.
global:
env: prod
agentBuilderNamespace: ax-hub-agentbuilder-prod
mcpHost: mcp.apps.example.internal
route:
# TODO: Agent Builder의 실제 고정 egress CIDR로 교체한다.
sourceAllowlist: 192.0.2.0/24
tiers:
critical:
replicas: 3
podDisruptionBudget: true
spreadAcrossNodes: true
standard:
replicas: 2
podDisruptionBudget: false
spreadAcrossNodes: false
resources:
requests:
cpu: 500m
memory: 1Gi
limits:
cpu: "2"
memory: 2Gi

View File

@@ -0,0 +1,26 @@
# test 환경. 운영계에 앞서 중요 등급의 가용성 설정을 검증하는 단계다.
#
# 중요 등급을 prod와 같은 방식(replica 2 + PDB)으로 먼저 검증하는 자리다.
# 여기서 확인하지 않으면 prod 배포 때 처음 겪게 된다.
#
# 어느 배포를 설치할지는 이 파일이 정하지 않는다. --set deploymentKey=<key>로 고른다.
# TODO: namespace가 확정되면 agentBuilderNamespace를 교체한다.
global:
env: test
agentBuilderNamespace: ax-hub-agentbuilder-test
mcpHost: mcp-test.apps.example.internal
route:
# TODO: Agent Builder의 실제 고정 egress CIDR로 교체한다.
sourceAllowlist: 192.0.2.0/24
tiers:
critical:
replicas: 2
podDisruptionBudget: true
spreadAcrossNodes: true
standard:
replicas: 1
podDisruptionBudget: false
spreadAcrossNodes: false

View File

@@ -0,0 +1,157 @@
# 환경 공통 기본값과 배포 토폴로지. 환경별 차이는 values-{env}.yaml이 덮어쓴다.
#
# 이 Chart의 설계 원칙:
# 1. MCP 배포 하나는 Tool Service 하나만 본다(ADR-0007).
# bundle 목록은 항상 한 항목이며 template이 만든다.
# 2. 배포 대상 전체를 아래 deployments 한 곳에 적는다.
# 설치할 때 --set deploymentKey=<key>로 하나를 고른다.
# 배포가 10개든 20개든 파일 수가 늘지 않고, 전체 매핑을 한 화면에서 검토할 수 있다.
# 3. 환경 축(namespace·이미지·등급별 replica)과 배포 축(어느 Tool Service를 보는가)을 섞지 않는다.
# values-{env}.yaml에는 deployments가 없고, deployments에는 환경 정보가 없다.
# 4. identity는 "{배포 이름}-{global.env}"로 조립한다.
# Redis key namespace이므로 환경끼리 겹치면 서로 Tool snapshot을 덮어쓴다.
# 사람이 손으로 적지 않게 해 실수를 구조적으로 막는다.
# 5. 외부에서는 환경별 한 host 아래 publicPath로 구분한다. Route는 Service만 선택하고
# 컨테이너가 같은 path를 직접 처리하므로 Registry의 1:1 경계는 바뀌지 않는다(ADR-0009).
# 설치할 배포를 고르는 key. 반드시 --set으로 지정한다.
# 기본값을 두지 않는 이유는, 지정을 빠뜨렸을 때 엉뚱한 배포가 조용히 설치되는 것보다
# 렌더링 실패가 낫기 때문이다.
deploymentKey: ""
global:
# 배포 환경. identity 접미사와 NetworkPolicy 판단에 쓰인다.
env: dev
# Agent Builder가 있는 namespace. Route를 우회한 Pod 직접 호출을 이 namespace로 제한한다.
# MCP와 Tool Service는 같은 namespace이므로 여기 적지 않는다.
# TODO: 실제 namespace 확정 시 교체한다.
agentBuilderNamespace: ax-hub-agentbuilder-dev
# Actuator management 포트에 접근할 관제 namespace.
monitoringNamespace: openshift-monitoring
# 환경별 공개 MCP host. 실제 OpenShift apps domain으로 교체한다.
mcpHost: mcp-dev.apps.example.internal
# 배포 대상 전체. map의 key가 곧 bundle id가 된다.
#
# name Deployment/Service/ConfigMap/NetworkPolicy 이름. 같은 namespace에서 유일해야 한다
# service 이 MCP가 보는 Tool Service의 Kubernetes Service 이름. 주소는 template이 조립한다
# namePrefix 이 Tool Service가 쓰는 Tool 이름 접두사. 업무 단위이며 등급을 넣지 않는다
# tier 가용성 등급. 아래 tiers의 key여야 한다
# publicPath Agent Builder가 등록할 외부 MCP path. 전체 topology에서 유일해야 한다
#
# 같은 업무의 두 등급이 같은 namePrefix를 공유하는 것은 의도된 구성이다(ADR-0007).
# 등급을 이름에 넣으면 Tool 재분류가 Tool name 변경이 되어 Agent Builder 재등록을 부른다.
# 그 안에서 Tool 이름이 겹치지 않게 하는 것은 Tool Service 책임이다.
#
# TODO: Tool 목록이 확정되면 실제 Tool Service 이름으로 교체하고, 없는 배포는 삭제한다.
deployments:
processing-critical:
name: processing-critical-mcp
service: processing-critical-tools
namePrefix: "processing."
tier: critical
publicPath: /mcp/processing-critical
processing-standard:
name: processing-standard-mcp
service: processing-standard-tools
namePrefix: "processing."
tier: standard
publicPath: /mcp/processing-standard
swring-critical:
name: swring-critical-mcp
service: swring-critical-tools
namePrefix: "swring."
tier: critical
publicPath: /mcp/swring-critical
swring-standard:
name: swring-standard-mcp
service: swring-standard-tools
namePrefix: "swring."
tier: standard
publicPath: /mcp/swring-standard
information-critical:
name: information-critical-mcp
service: information-critical-tools
namePrefix: "information."
tier: critical
publicPath: /mcp/information-critical
information-standard:
name: information-standard-mcp
service: information-standard-tools
namePrefix: "information."
tier: standard
publicPath: /mcp/information-standard
hr-critical:
name: hr-critical-mcp
service: hr-critical-tools
namePrefix: "hr."
tier: critical
publicPath: /mcp/hr-critical
hr-standard:
name: hr-standard-mcp
service: hr-standard-tools
namePrefix: "hr."
tier: standard
publicPath: /mcp/hr-standard
# OpenShift Router와 MCP 컨테이너가 같은 publicPath를 사용한다. rewrite하지 않는다.
route:
# Agent Builder 최대 대기 시간과 맞춘 공개 HTTP 연결 timeout이다.
timeout: 300s
# 문서용 TEST-NET이다. 실제 환경에서는 Agent Builder의 고정 egress CIDR로 교체한다.
sourceAllowlist: 192.0.2.0/24
# 등급별 가용성 기준. 환경별 values가 덮어쓴다.
#
# 배포를 등급으로 나누는 목적이 여기에 있다. 나뉘어 있어야 중요 등급에만 비용을 쓸 수 있다.
# 다만 나누는 것만으로 가용성이 생기지는 않는다. 같은 노드 배치, namespace 쿼터,
# 공통 Redis·클러스터 장애는 분할로 막히지 않는다(ADR-0007).
tiers:
critical:
replicas: 2
# 배포·노드 drain 중에도 최소 1개를 남긴다.
podDisruptionBudget: true
# replica를 서로 다른 노드에 두려고 시도한다. 노드가 부족하면 그대로 배치한다.
spreadAcrossNodes: true
standard:
replicas: 1
podDisruptionBudget: false
spreadAcrossNodes: false
image:
# TODO: 사내 컨테이너 registry 경로 확정 시 교체한다.
repository: image-registry.openshift-image-registry.svc:5000/ax-hub/ax-hub-mcp-server
tag: "0.1.0"
pullPolicy: IfNotPresent
mcp:
# Tool Service 매니페스트 조회 주기(초).
# 1:1이라 bundle 수가 항상 1이므로 조회 부하는 (replica 수 / 주기)다.
refreshIntervalSeconds: 30
refreshJitterSeconds: 5
toolService:
# MCP와 같은 namespace에 있으므로 서비스 이름 + 아래 값으로 주소가 완성된다.
port: 8080
manifestPath: /tool-manifest
basePath: /mcp
redis:
host: redis
port: 6379
ports:
http: 8080
management: 9090
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: "1"
memory: 1Gi
# 진행 중인 tools/call은 Tool timeout 상한(30초) + 응답 쓰기만큼 걸릴 수 있다.
# Spring drain(40초)보다 길어야 drain이 끝나기 전에 Pod이 죽지 않는다.
terminationGracePeriodSeconds: 45