Skip to content

Commit 9e0af0b

Browse files
authored
docs: add multi-replica Kubernetes deployment example (#136)
1 parent 4aaca6f commit 9e0af0b

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

docs/docs/examples.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,96 @@ spec:
136136
number: 80
137137
```
138138
139+
#### Multi-Replica (High Availability)
140+
141+
By using a shared database backend (`postgres` or `mysql`) and injecting cryptographic keys via environment variables (`AUTH_HMAC_SECRET`, `JWT_PRIVATE_KEY`), replicas become fully stateless — no PVC or sticky sessions needed.
142+
143+
See [#84](https://github.com/sigbit/mcp-auth-proxy/issues/84) and [#110](https://github.com/sigbit/mcp-auth-proxy/issues/110) for background.
144+
145+
```yaml
146+
apiVersion: apps/v1
147+
kind: Deployment
148+
metadata:
149+
name: mcp-auth-proxy
150+
spec:
151+
replicas: 3
152+
selector:
153+
matchLabels:
154+
app: mcp-auth-proxy
155+
template:
156+
metadata:
157+
labels:
158+
app: mcp-auth-proxy
159+
spec:
160+
containers:
161+
- name: mcp-auth-proxy
162+
image: ghcr.io/sigbit/mcp-auth-proxy:latest
163+
ports:
164+
- containerPort: 80
165+
env:
166+
- name: EXTERNAL_URL
167+
value: "https://{your-domain}"
168+
- name: NO_AUTO_TLS
169+
value: "true"
170+
- name: REPOSITORY_BACKEND
171+
value: "postgres"
172+
- name: REPOSITORY_DSN
173+
valueFrom:
174+
secretKeyRef:
175+
name: mcp-auth-proxy-secrets
176+
key: repository-dsn
177+
- name: PASSWORD
178+
valueFrom:
179+
secretKeyRef:
180+
name: mcp-auth-proxy-secrets
181+
key: password
182+
- name: AUTH_HMAC_SECRET
183+
valueFrom:
184+
secretKeyRef:
185+
name: mcp-auth-proxy-keys
186+
key: auth-hmac-secret
187+
- name: JWT_PRIVATE_KEY
188+
valueFrom:
189+
secretKeyRef:
190+
name: mcp-auth-proxy-keys
191+
key: jwt-private-key
192+
args: ["npx", "-y", "@modelcontextprotocol/server-filesystem", "./"]
193+
---
194+
apiVersion: v1
195+
kind: Service
196+
metadata:
197+
name: mcp-auth-proxy
198+
spec:
199+
selector:
200+
app: mcp-auth-proxy
201+
ports:
202+
- port: 80
203+
targetPort: 80
204+
---
205+
apiVersion: networking.k8s.io/v1
206+
kind: Ingress
207+
metadata:
208+
name: mcp-auth-proxy
209+
annotations:
210+
cert-manager.io/cluster-issuer: letsencrypt
211+
spec:
212+
tls:
213+
- hosts:
214+
- { your-domain }
215+
secretName: mcp-auth-proxy-tls
216+
rules:
217+
- host: { your-domain }
218+
http:
219+
paths:
220+
- path: /
221+
pathType: Prefix
222+
backend:
223+
service:
224+
name: mcp-auth-proxy
225+
port:
226+
number: 80
227+
```
228+
139229
#### Sidecar Pattern
140230

141231
The sidecar pattern allows you to add authentication to any SSE-based MCP server. The auth proxy runs as a sidecar container in the same pod, authenticating requests before forwarding them to your MCP server.

0 commit comments

Comments
 (0)