Skip to content

Commit 25284a4

Browse files
committed
Helm chart redis fix
Signed-off-by: Mihai Criveti <[email protected]>
1 parent 69b270e commit 25284a4

File tree

12 files changed

+353
-81
lines changed

12 files changed

+353
-81
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
gateway_service_leader.lock
12
docs/docs/test/
23
tmp
34
*.tgz

charts/mcp-stack/Chart.yaml

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,49 @@
1+
# --------------------------------------------------------------------
2+
# CHART METADATA — Helm reads this file to identify and display the
3+
# chart in registries such as Artifact Hub or ChartMuseum.
4+
# --------------------------------------------------------------------
15
apiVersion: v2
26
name: mcp-stack
7+
38
description: |
4-
A complete Helm chart for MCP Gateway stack (Context Forge) including:
5-
* MCP Application
6-
* PostgreSQL database with persistence
7-
* Redis cache
8-
* Optional PgAdmin & Redis Commander UIs
9+
A full-stack Helm chart for IBM's **Model Context Protocol (MCP) Gateway
10+
& Registry — Context-Forge**. It bundles:
11+
• MCP Gateway application (HTTP / WebSocket server)
12+
• PostgreSQL database with persistent storage
13+
• Redis cache for sessions & completions
14+
• Optional PgAdmin and Redis-Commander web UIs
15+
916
type: application
10-
version: 0.1.1
11-
appVersion: "0.1.1"
17+
18+
# --------------------------------------------------------------------
19+
# Versioning
20+
# * version — chart package version (SemVer). Bump on *any* chart
21+
# change, even if the app container tag is the same.
22+
# * appVersion — upstream application version; shown in UIs but not
23+
# used for upgrade logic.
24+
# --------------------------------------------------------------------
25+
version: 0.2.0
26+
appVersion: "0.2.0"
27+
28+
# Icon shown by registries / dashboards (must be an http(s) URL).
29+
icon: https://raw.githubusercontent.com/IBM/mcp-context-forge/main/docs/theme/logo.png
30+
31+
# Optional but useful metadata
32+
keywords:
33+
- mcp
34+
- gateway
35+
- postgres
36+
- redis
37+
- llm
38+
- context-forge
39+
home: https://github.com/IBM/mcp-context-forge
40+
41+
sources:
42+
- https://github.com/IBM/mcp-context-forge
43+
44+
maintainers:
45+
- name: Mihai Criveti
46+
url: https://github.com/IBM
47+
48+
# Require Kubernetes ≥1.21 for networking v1 and recent securityContext fields
49+
kubeVersion: ">=1.21.0"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{/* -------------------------------------------------------------------
2+
CONFIGMAP — Gateway Plain-Text Configuration
3+
-------------------------------------------------------------------
4+
• Renders a ConfigMap named <release>-mcp-stack-gateway-config
5+
• Each key/value in values.yaml → mcpContextForge.config
6+
becomes an environment variable.
7+
• Use ONLY for non-secret data (anything you don't mind in plain text).
8+
• The matching Secret template handles sensitive keys.
9+
------------------------------------------------------------------- */}}
10+
11+
{{- if .Values.mcpContextForge.config }}
12+
apiVersion: v1
13+
kind: ConfigMap
14+
metadata:
15+
name: {{ include "mcp-stack.fullname" . }}-gateway-config
16+
labels:
17+
{{- include "mcp-stack.labels" . | nindent 4 }}
18+
app.kubernetes.io/component: gateway
19+
data:
20+
{{- /* Iterate over every key in mcpContextForge.config */}}
21+
{{- range $key, $val := .Values.mcpContextForge.config }}
22+
{{ $key }}: {{ $val | quote }}
23+
{{- end }}
24+
{{- end }}
Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,51 @@
1+
########################################################################
2+
# DEPLOYMENT — MCP Context-Forge (Gateway)
3+
#
4+
# • Spins up the HTTP / WebSocket gateway pods.
5+
# • Injects release-scoped hosts for Postgres & Redis.
6+
# • Pulls ALL other environment variables from the dedicated
7+
# ConfigMap + Secret via envFrom (mounted later in this file).
8+
# • DATABASE_URL and REDIS_URL are declared LAST so that every
9+
# $(POSTGRES_*) / $(REDIS_*) placeholder is already defined.
10+
########################################################################
111
apiVersion: apps/v1
212
kind: Deployment
313
metadata:
14+
# <release>-mcp-stack-app
415
name: {{ include "mcp-stack.fullname" . }}-app
516
labels:
617
{{- include "mcp-stack.labels" . | nindent 4 }}
718
spec:
819
replicas: {{ .Values.mcpContextForge.replicaCount }}
20+
921
selector:
1022
matchLabels:
1123
app: {{ include "mcp-stack.fullname" . }}-app
24+
1225
template:
1326
metadata:
1427
labels:
1528
app: {{ include "mcp-stack.fullname" . }}-app
29+
1630
spec:
1731
containers:
1832
- name: mcp-context-forge
1933
image: "{{ .Values.mcpContextForge.image.repository }}:{{ .Values.mcpContextForge.image.tag }}"
2034
imagePullPolicy: {{ .Values.mcpContextForge.image.pullPolicy }}
35+
36+
# Gateway's internal port
2137
ports:
2238
- containerPort: {{ .Values.mcpContextForge.containerPort }}
39+
40+
################################################################
41+
# EXPLICIT ENV-VARS
42+
# • DB/cache endpoints must be set here so they can be used as
43+
# placeholders in the derived URL variables declared below.
44+
################################################################
2345
env:
24-
# ── core settings ────────────────────────────────────────────
25-
- name: HOST
26-
value: "{{ .Values.mcpContextForge.env.host }}"
46+
# ---------- POSTGRES ----------
2747
- name: POSTGRES_HOST
28-
value: "{{ .Values.mcpContextForge.env.postgres.host }}"
48+
value: {{ printf "%s-postgres" (include "mcp-stack.fullname" .) }}
2949
- name: POSTGRES_PORT
3050
value: "{{ .Values.mcpContextForge.env.postgres.port }}"
3151
- name: POSTGRES_DB
@@ -40,17 +60,31 @@ spec:
4060
secretKeyRef:
4161
name: {{ include "mcp-stack.postgresSecretName" . | trim }}
4262
key: POSTGRES_PASSWORD
63+
64+
# ---------- REDIS ----------
4365
- name: REDIS_HOST
44-
value: "{{ .Values.mcpContextForge.env.redis.host }}"
66+
value: {{ printf "%s-redis" (include "mcp-stack.fullname" .) }}
4567
- name: REDIS_PORT
4668
value: "{{ .Values.mcpContextForge.env.redis.port }}"
4769

48-
# ── extras injected via values.yaml (DATABASE_URL, etc.) ─────
49-
{{- if .Values.mcpContextForge.env.extras }}
50-
{{- range .Values.mcpContextForge.env.extras }}
51-
- name: {{ .name }}
52-
value: {{ .value | quote }}
53-
{{- end }}
54-
{{- end }}
70+
# ---------- DERIVED URLS ----------
71+
# These MUST be placed *after* the concrete vars above so the
72+
# $(…) placeholders are expanded correctly inside the pod.
73+
- name: DATABASE_URL
74+
value: >-
75+
postgresql://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(POSTGRES_HOST):$(POSTGRES_PORT)/$(POSTGRES_DB)
76+
- name: REDIS_URL
77+
value: "redis://$(REDIS_HOST):$(REDIS_PORT)/0"
78+
79+
################################################################
80+
# BULK ENV-VARS — pulled from ConfigMap + Secret
81+
################################################################
82+
envFrom:
83+
- secretRef:
84+
name: {{ include "mcp-stack.fullname" . }}-gateway-secret
85+
- configMapRef:
86+
name: {{ include "mcp-stack.fullname" . }}-gateway-config
87+
88+
# Resource requests / limits
5589
resources:
5690
{{- toYaml .Values.mcpContextForge.resources | nindent 12 }}
Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,51 @@
1+
{{/* -------------------------------------------------------------------
2+
DEPLOYMENT — Postgres
3+
-------------------------------------------------------------------
4+
• Pods are labelled <release>-mcp-stack-postgres so the Service
5+
selector (also templated) matches correctly.
6+
------------------------------------------------------------------- */}}
7+
18
{{- if .Values.postgres.enabled }}
29
apiVersion: apps/v1
310
kind: Deployment
411
metadata:
5-
name: postgres
12+
# <release>-mcp-stack-postgres
13+
name: {{ include "mcp-stack.fullname" . }}-postgres
614
labels:
7-
app: postgres
15+
{{- include "mcp-stack.labels" . | nindent 4 }}
16+
app: {{ include "mcp-stack.fullname" . }}-postgres
817
spec:
9-
replicas: 1
18+
replicas: 1 # one DB pod; use StatefulSet if you ever scale
1019
selector:
1120
matchLabels:
12-
app: postgres
21+
app: {{ include "mcp-stack.fullname" . }}-postgres
1322
template:
1423
metadata:
1524
labels:
16-
app: postgres
25+
app: {{ include "mcp-stack.fullname" . }}-postgres
1726
spec:
1827
containers:
1928
- name: postgres
2029
image: "{{ .Values.postgres.image.repository }}:{{ .Values.postgres.image.tag }}"
2130
imagePullPolicy: "{{ .Values.postgres.image.pullPolicy }}"
2231
ports:
2332
- containerPort: {{ .Values.postgres.service.port }}
33+
34+
# ConfigMap holds non-secret tuning (postgresql.conf, etc.)
35+
# Secret stores POSTGRES_USER / POSTGRES_PASSWORD.
2436
envFrom:
2537
- configMapRef:
2638
name: postgres-config
2739
- secretRef:
2840
name: {{ include "mcp-stack.postgresSecretName" . | trim | quote }}
41+
42+
# Mount PVC for data durability
2943
volumeMounts:
3044
- name: postgredb
3145
mountPath: /var/lib/postgresql/data
46+
3247
volumes:
3348
- name: postgredb
3449
persistentVolumeClaim:
35-
claimName: postgres-pv-claim
50+
claimName: postgres-pv-claim # keep aligned with templates/postgres-pvc.yaml
3651
{{- end }}

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
{{- /*
2-
Redis Deployment
3-
Enabled when .Values.redis.enabled = true
4-
*/ -}}
1+
{{/* -------------------------------------------------------------------
2+
DEPLOYMENT — Redis
3+
-------------------------------------------------------------------
4+
• Name + labels templated with <release>-mcp-stack-redis.
5+
• Keeps a single replica; if you need HA, swap for a StatefulSet
6+
or an external Redis cluster.
7+
------------------------------------------------------------------- */}}
8+
59
{{- if .Values.redis.enabled }}
610
apiVersion: apps/v1
711
kind: Deployment
812
metadata:
913
name: {{ include "mcp-stack.fullname" . }}-redis
1014
labels:
1115
{{- include "mcp-stack.labels" . | nindent 4 }}
12-
app: redis
16+
app: {{ include "mcp-stack.fullname" . }}-redis
1317
spec:
1418
replicas: 1
1519
selector:
1620
matchLabels:
17-
app: redis
18-
release: {{ .Release.Name }}
21+
app: {{ include "mcp-stack.fullname" . }}-redis
1922
template:
2023
metadata:
2124
labels:
22-
app: redis
23-
release: {{ .Release.Name }}
25+
app: {{ include "mcp-stack.fullname" . }}-redis
2426
spec:
2527
containers:
2628
- name: redis
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{/* -------------------------------------------------------------------
2+
SECRET — Gateway Sensitive Configuration
3+
-------------------------------------------------------------------
4+
• Renders a Secret named <release>-mcp-stack-gateway-secret
5+
• Keys come from values.yaml → mcpContextForge.secret
6+
• Uses stringData so you can keep readable values in your values.yaml;
7+
Kubernetes will base64-encode them on creation.
8+
• Put ONLY sensitive credentials or tokens here.
9+
------------------------------------------------------------------- */}}
10+
11+
{{- if .Values.mcpContextForge.secret }}
12+
apiVersion: v1
13+
kind: Secret
14+
metadata:
15+
name: {{ include "mcp-stack.fullname" . }}-gateway-secret
16+
labels:
17+
{{- include "mcp-stack.labels" . | nindent 4 }}
18+
app.kubernetes.io/component: gateway
19+
type: Opaque
20+
stringData:
21+
{{- /* Iterate over every key in mcpContextForge.secret */}}
22+
{{- range $key, $val := .Values.mcpContextForge.secret }}
23+
{{ $key }}: {{ $val | quote }}
24+
{{- end }}
25+
{{- end }}

charts/mcp-stack/templates/service-postgres.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
apiVersion: v1
33
kind: Service
44
metadata:
5-
name: postgres
5+
name: {{ include "mcp-stack.fullname" . }}-postgres
66
labels:
7-
app: postgres
7+
{{- include "mcp-stack.labels" . | nindent 4 }}
88
spec:
99
type: {{ .Values.postgres.service.type }}
1010
ports:
11-
- port: {{ .Values.postgres.service.port }}
11+
- name: postgres
12+
port: {{ .Values.postgres.service.port }}
13+
targetPort: {{ .Values.postgres.service.targetPort | default .Values.postgres.service.port }}
1214
selector:
13-
app: postgres
15+
app: {{ include "mcp-stack.fullname" . }}-postgres
1416
{{- end }}
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
{{- /*
2-
Redis Service
3-
*/ -}}
1+
{{/* -------------------------------------------------------------------
2+
SERVICE — Redis
3+
-------------------------------------------------------------------
4+
• Exposes port 6379 (or whatever you set in values.yaml).
5+
• Selector now matches the app label from the Deployment above.
6+
------------------------------------------------------------------- */}}
7+
48
{{- if .Values.redis.enabled }}
59
apiVersion: v1
610
kind: Service
711
metadata:
812
name: {{ include "mcp-stack.fullname" . }}-redis
913
labels:
1014
{{- include "mcp-stack.labels" . | nindent 4 }}
11-
app: redis
15+
app: {{ include "mcp-stack.fullname" . }}-redis
1216
spec:
1317
type: {{ .Values.redis.service.type }}
14-
selector:
15-
app: redis
16-
release: {{ .Release.Name }}
1718
ports:
1819
- name: redis
1920
port: {{ .Values.redis.service.port }}
20-
targetPort: redis
21+
selector:
22+
app: {{ include "mcp-stack.fullname" . }}-redis
2123
{{- end }}

0 commit comments

Comments
 (0)