26
26
metadata :
27
27
labels :
28
28
app : {{ include "mcp-stack.fullname" . }}-mcpgateway
29
- {{- include "mcp-stack.labels" . | nindent 8 }}
30
29
31
30
spec :
32
- # ###############################################################
33
- # INIT CONTAINER — Alembic database migration
34
- #
35
- # • Enabled via .Values.dbMigration.enabled (toggle in values.yaml)
36
- # • Uses the exact same image & env as the main container so no
37
- # duplicate config.
38
- #
39
- # Step 1: Wait for Postgres by actually opening a connection with
40
- # Python + psycopg2 (acts like a portable pg_isready).
41
- # Step 2: Run Alembic; retry both steps for ~60 s to cover slow
42
- # cold starts.
43
- # ###############################################################
44
- {{- if .Values.dbMigration.enabled }}
45
- initContainers :
46
- - name : {{ include "mcp-stack.fullname" . }}-db-migrate
47
- image : " {{ .Values.mcpContextForge.image.repository }}:{{ .Values.mcpContextForge.image.tag }}"
48
- imagePullPolicy : {{ .Values.mcpContextForge.image.pullPolicy }}
49
-
50
- env :
51
- - name : PYTHONUNBUFFERED # live logs
52
- value : " 1"
53
- # ---------- POSTGRES ----------
54
- - name : POSTGRES_HOST
55
- value : {{ printf "%s-postgres" (include "mcp-stack.fullname" .) | quote }}
56
- - name : POSTGRES_PORT
57
- value : {{ .Values.mcpContextForge.env.postgres.port | quote }}
58
- - name : POSTGRES_DB
59
- value : {{ .Values.mcpContextForge.env.postgres.db | quote }}
60
- - name : POSTGRES_USER
61
- valueFrom :
62
- secretKeyRef :
63
- name : {{ include "mcp-stack.postgresSecretName" . | trim }}
64
- key : POSTGRES_USER
65
- - name : POSTGRES_PASSWORD
66
- valueFrom :
67
- secretKeyRef :
68
- name : {{ include "mcp-stack.postgresSecretName" . | trim }}
69
- key : POSTGRES_PASSWORD
70
-
71
- envFrom :
72
- - secretRef :
73
- name : {{ include "mcp-stack.fullname" . }}-gateway-secret
74
- - configMapRef :
75
- name : {{ include "mcp-stack.fullname" . }}-gateway-config
76
-
77
- command :
78
- - sh
79
- - -c
80
- - |
81
- set -e
82
-
83
- echo '▶ waiting for Postgres via psycopg2…'
84
- python - <<'PY'
85
- import os, sys, time, psycopg2
86
- dsn = "dbname={db} user={user} password={pwd} host={host} port={port}".format(
87
- db=os.environ["POSTGRES_DB"],
88
- user=os.environ["POSTGRES_USER"],
89
- pwd=os.environ["POSTGRES_PASSWORD"],
90
- host=os.environ["POSTGRES_HOST"],
91
- port=os.environ["POSTGRES_PORT"],
92
- )
93
- for attempt in range(30):
94
- try:
95
- psycopg2.connect(dsn, connect_timeout=2).close()
96
- print("✅ Postgres is ready"); sys.exit(0)
97
- except Exception as e:
98
- print(f"⏳ waiting for Postgres… ({attempt+1}/30) — {e}")
99
- time.sleep(2)
100
- print("❌ Postgres not ready after 60 s"); sys.exit(1)
101
- PY
102
-
103
- echo '▶ running `alembic --version` to check the Alembic CLI…'
104
- alembic --version
105
- echo '▶ running Alembic migrations…'
106
- for i in $(seq 1 30); do
107
- /app/.venv/bin/alembic upgrade head && exit 0
108
- echo '⏳ Alembic failed — retrying in 2 s'
109
- sleep 2
110
- done
111
- echo '❌ Alembic failed after multiple attempts'
112
- exit 1
113
- {{- end }}
114
-
115
- # ###############################################################
116
- # MAIN CONTAINER — MCP Context-Forge
117
- # ###############################################################
118
31
containers :
119
32
- name : mcp-context-forge
120
33
image : " {{ .Values.mcpContextForge.image.repository }}:{{ .Values.mcpContextForge.image.tag }}"
@@ -132,11 +45,11 @@ spec:
132
45
env :
133
46
# ---------- POSTGRES ----------
134
47
- name : POSTGRES_HOST
135
- value : {{ printf "%s-postgres" (include "mcp-stack.fullname" .) | quote }}
48
+ value : {{ printf "%s-postgres" (include "mcp-stack.fullname" .) }}
136
49
- name : POSTGRES_PORT
137
- value : {{ .Values.mcpContextForge.env.postgres.port | quote }}
50
+ value : " {{ .Values.mcpContextForge.env.postgres.port }} "
138
51
- name : POSTGRES_DB
139
- value : {{ .Values.mcpContextForge.env.postgres.db | quote }}
52
+ value : " {{ .Values.mcpContextForge.env.postgres.db }} "
140
53
- name : POSTGRES_USER
141
54
valueFrom :
142
55
secretKeyRef :
@@ -150,15 +63,16 @@ spec:
150
63
151
64
# ---------- REDIS ----------
152
65
- name : REDIS_HOST
153
- value : {{ printf "%s-redis" (include "mcp-stack.fullname" .) | quote }}
66
+ value : {{ printf "%s-redis" (include "mcp-stack.fullname" .) }}
154
67
- name : REDIS_PORT
155
- value : {{ .Values.mcpContextForge.env.redis.port | quote }}
68
+ value : " {{ .Values.mcpContextForge.env.redis.port }} "
156
69
157
70
# ---------- DERIVED URLS ----------
158
71
# These MUST be placed *after* the concrete vars above so the
159
72
# $(…) placeholders are expanded correctly inside the pod.
160
73
- name : DATABASE_URL
161
- value : " postgresql://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(POSTGRES_HOST):$(POSTGRES_PORT)/$(POSTGRES_DB)"
74
+ value : >-
75
+ postgresql://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(POSTGRES_HOST):$(POSTGRES_PORT)/$(POSTGRES_DB)
162
76
- name : REDIS_URL
163
77
value : " redis://$(REDIS_HOST):$(REDIS_PORT)/0"
164
78
@@ -176,19 +90,19 @@ spec:
176
90
# ###############################################################
177
91
{{- with .Values.mcpContextForge.probes.startup }}
178
92
startupProbe :
179
- {{- include "helpers.renderProbe" (dict "probe" . "root" $) | nindent 12 }}
93
+ {{- include "helpers.renderProbe" (dict "probe" . "root" $) | nindent 12 }}
180
94
{{- end }}
181
95
182
96
{{- with .Values.mcpContextForge.probes.readiness }}
183
97
readinessProbe :
184
- {{- include "helpers.renderProbe" (dict "probe" . "root" $) | nindent 12 }}
98
+ {{- include "helpers.renderProbe" (dict "probe" . "root" $) | nindent 12 }}
185
99
{{- end }}
186
100
187
101
{{- with .Values.mcpContextForge.probes.liveness }}
188
102
livenessProbe :
189
- {{- include "helpers.renderProbe" (dict "probe" . "root" $) | nindent 12 }}
103
+ {{- include "helpers.renderProbe" (dict "probe" . "root" $) | nindent 12 }}
190
104
{{- end }}
191
105
192
106
# Resource requests / limits
193
107
resources :
194
- {{- toYaml .Values.mcpContextForge.resources | nindent 12 }}
108
+ {{- toYaml .Values.mcpContextForge.resources | nindent 12 }}
0 commit comments