Kubernetes Deployment Manifest
Production-ready Kubernetes deployment with resource limits, probes, rolling updates, and anti-affinity.
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-server
namespace: production
labels:
app: api-server
version: v1
spec:
replicas: 3
selector:
matchLabels:
app: api-server
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: api-server
version: v1
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
app: api-server
topologyKey: kubernetes.io/hostname
containers:
- name: api
image: registry.example.com/api-server:1.2.0
ports:
- containerPort: 3000
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 512Mi
livenessProbe:
httpGet:
path: /healthz
port: 3000
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet:
path: /ready
port: 3000
initialDelaySeconds: 5
periodSeconds: 10
env:
- name: NODE_ENV
value: production
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: api-secrets
key: db-passwordSponsored
DigitalOcean
Use Cases
- Deploying containerized applications to Kubernetes
- Zero-downtime rolling updates
- Production-grade pod configuration with resource limits
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
Kubernetes Deployment Configuration
Production-ready Kubernetes deployment with replicas, resource limits, health checks, and rolling updates.
Best for: Production container orchestration
GitHub Actions — Deploy to Cloudflare Pages
Automated deployment pipeline to Cloudflare Pages with build preview for PRs and production on main.
Best for: Zero-config deployment for static Next.js exports
Kubernetes HPA — Horizontal Pod Autoscaler
Configure horizontal pod autoscaling based on CPU, memory, and custom metrics for Kubernetes workloads.
Best for: Auto-scaling APIs based on traffic load
Kubernetes ConfigMap and Secret Management
Create and use ConfigMaps and Secrets for application configuration with env vars and volume mounts.
Best for: Managing application configuration in Kubernetes