Skip to content

Commit 38de4c9

Browse files
committed
Restore helm templates so I can push db_isready first
Signed-off-by: Mihai Criveti <[email protected]>
1 parent 8aaabd6 commit 38de4c9

File tree

2 files changed

+12
-107
lines changed

2 files changed

+12
-107
lines changed

charts/mcp-stack/templates/deployment-mcpgateway.yaml

Lines changed: 11 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -26,95 +26,8 @@ spec:
2626
metadata:
2727
labels:
2828
app: {{ include "mcp-stack.fullname" . }}-mcpgateway
29-
{{- include "mcp-stack.labels" . | nindent 8 }}
3029

3130
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-
################################################################
11831
containers:
11932
- name: mcp-context-forge
12033
image: "{{ .Values.mcpContextForge.image.repository }}:{{ .Values.mcpContextForge.image.tag }}"
@@ -132,11 +45,11 @@ spec:
13245
env:
13346
# ---------- POSTGRES ----------
13447
- name: POSTGRES_HOST
135-
value: {{ printf "%s-postgres" (include "mcp-stack.fullname" .) | quote }}
48+
value: {{ printf "%s-postgres" (include "mcp-stack.fullname" .) }}
13649
- name: POSTGRES_PORT
137-
value: {{ .Values.mcpContextForge.env.postgres.port | quote }}
50+
value: "{{ .Values.mcpContextForge.env.postgres.port }}"
13851
- name: POSTGRES_DB
139-
value: {{ .Values.mcpContextForge.env.postgres.db | quote }}
52+
value: "{{ .Values.mcpContextForge.env.postgres.db }}"
14053
- name: POSTGRES_USER
14154
valueFrom:
14255
secretKeyRef:
@@ -150,15 +63,16 @@ spec:
15063

15164
# ---------- REDIS ----------
15265
- name: REDIS_HOST
153-
value: {{ printf "%s-redis" (include "mcp-stack.fullname" .) | quote }}
66+
value: {{ printf "%s-redis" (include "mcp-stack.fullname" .) }}
15467
- name: REDIS_PORT
155-
value: {{ .Values.mcpContextForge.env.redis.port | quote }}
68+
value: "{{ .Values.mcpContextForge.env.redis.port }}"
15669

15770
# ---------- DERIVED URLS ----------
15871
# These MUST be placed *after* the concrete vars above so the
15972
# $(…) placeholders are expanded correctly inside the pod.
16073
- 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)
16276
- name: REDIS_URL
16377
value: "redis://$(REDIS_HOST):$(REDIS_PORT)/0"
16478

@@ -176,19 +90,19 @@ spec:
17690
################################################################
17791
{{- with .Values.mcpContextForge.probes.startup }}
17892
startupProbe:
179-
{{- include "helpers.renderProbe" (dict "probe" . "root" $) | nindent 12 }}
93+
{{- include "helpers.renderProbe" (dict "probe" . "root" $) | nindent 12 }}
18094
{{- end }}
18195

18296
{{- with .Values.mcpContextForge.probes.readiness }}
18397
readinessProbe:
184-
{{- include "helpers.renderProbe" (dict "probe" . "root" $) | nindent 12 }}
98+
{{- include "helpers.renderProbe" (dict "probe" . "root" $) | nindent 12 }}
18599
{{- end }}
186100

187101
{{- with .Values.mcpContextForge.probes.liveness }}
188102
livenessProbe:
189-
{{- include "helpers.renderProbe" (dict "probe" . "root" $) | nindent 12 }}
103+
{{- include "helpers.renderProbe" (dict "probe" . "root" $) | nindent 12 }}
190104
{{- end }}
191105

192106
# Resource requests / limits
193107
resources:
194-
{{- toYaml .Values.mcpContextForge.resources | nindent 12 }}
108+
{{- toYaml .Values.mcpContextForge.resources | nindent 12 }}

charts/mcp-stack/values.yaml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ global:
77
nameOverride: "" # short name applied to all resources (optional)
88
fullnameOverride: "" # fully-qualified name override (optional)
99

10-
########################################################################
11-
# DATABASE MIGRATION
12-
# If true, Helm inserts an initContainer that waits for Postgres and
13-
# runs `alembic upgrade head` before each mcpgateway pod starts.
14-
########################################################################
15-
dbMigration:
16-
enabled: true # ➜ set to false to skip alembic migrations
17-
1810
########################################################################
1911
# MCP CONTEXT-FORGE (Gateway / API tier)
2012
########################################################################
@@ -37,8 +29,7 @@ mcpContextForge:
3729
image:
3830
repository: ghcr.io/ibm/mcp-context-forge
3931
tag: latest # pin a specific immutable tag in production
40-
#pullPolicy: IfNotPresent
41-
pullPolicy: Always # always pull the latest image; useful for dev
32+
pullPolicy: IfNotPresent
4233

4334
# Service that fronts the gateway
4435
service:

0 commit comments

Comments
 (0)