78 lines
1.8 KiB
YAML
78 lines
1.8 KiB
YAML
# kubernetes/backend/backend.yaml
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: backend
|
|
namespace: todo-app
|
|
spec:
|
|
replicas: 2
|
|
selector:
|
|
matchLabels:
|
|
app: backend
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: backend
|
|
tier: api # ← label for NetworkPolicy
|
|
spec:
|
|
containers:
|
|
- name: backend
|
|
image: silvarno/todo-backend:latest
|
|
ports:
|
|
- containerPort: 5000
|
|
env:
|
|
- name: PORT
|
|
value: "5000"
|
|
- name: NODE_ENV
|
|
value: "production"
|
|
- name: MONGO_URI
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: todo-secrets
|
|
key: MONGO_URI
|
|
- name: JWT_SECRET
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: todo-secrets
|
|
key: JWT_SECRET
|
|
# Security context
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
runAsUser: 1000
|
|
allowPrivilegeEscalation: false
|
|
readOnlyRootFilesystem: true
|
|
# Health checks
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 5000
|
|
initialDelaySeconds: 15
|
|
periodSeconds: 20
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 5000
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 10
|
|
# Resource limits
|
|
resources:
|
|
requests:
|
|
memory: "128Mi"
|
|
cpu: "100m"
|
|
limits:
|
|
memory: "256Mi"
|
|
cpu: "500m"
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: backend-service
|
|
namespace: todo-app
|
|
spec:
|
|
selector:
|
|
app: backend
|
|
ports:
|
|
- port: 5000
|
|
targetPort: 5000
|
|
type: ClusterIP # ← internal only
|