Deploy MCP on Kubernetes
Run MCP servers on Kubernetes with deployments, secrets, ingress, scaling, probes, and observability.
Quick Answer / TL;DR
Kubernetes fits MCP platforms that need multiple services, strict isolation, custom networking, autoscaling, secret management, and mature observability.
Key Takeaways
- Use probes.
- Separate namespaces by environment.
- Centralize logs and policies.
- Externalize secrets rather than storing them in plain Kubernetes Secret manifests.
Minimal deployment
Kubernetes is powerful but operationally heavier. Use it when the organization already runs clusters or needs strong multi-service orchestration.
apiVersion: apps/v1
kind: Deployment
metadata:
name: payments-mcp
spec:
replicas: 2
selector:
matchLabels:
app: payments-mcp
template:
metadata:
labels:
app: payments-mcp
spec:
containers:
- name: server
image: registry.example.in/payments-mcp:1.0.0
ports:
- containerPort: 8080Multi-stage Docker build
Build with a multi-stage Dockerfile so the production image ships only compiled output and production dependencies, not the TypeScript toolchain, and run the process as a non-root user.
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
USER node
EXPOSE 3000
CMD ["node", "dist/index.js"]Autoscaling and externalized secrets
Scale on both CPU and memory utilization rather than CPU alone, since MCP tool handlers that buffer large tool outputs can be memory-bound before they are CPU-bound. Pull secrets from a manager such as AWS Secrets Manager or Vault instead of committing them as plain Kubernetes Secret manifests.
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: mcp-server-hpa
spec:
scaleTargetRef: { apiVersion: apps/v1, kind: Deployment, name: mcp-server }
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource: { name: cpu, target: { type: Utilization, averageUtilization: 70 } }
- type: Resource
resource: { name: memory, target: { type: Utilization, averageUtilization: 80 } }Deploy MCP on Kubernetes FAQs
Direct answers for developers, operators, and Indian teams evaluating MCP.