Creating Kubernetes Deployments
Generate production-ready Kubernetes manifests with health checks, resource limits, and security best practices.
Quick Start
Basic Deployment + Service
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-api
labels:
app: my-api
spec:
replicas: 3
selector:
matchLabels:
app: my-api
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
template:
metadata:
labels:
app: my-api
spec:
containers:
- name: my-api
image: my-registry/my-api:v1.0.0
ports:
- containerPort: 8080 # 8080: HTTP proxy port
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
livenessProbe:
httpGet:
path: /healthz
port: 8080 # HTTP proxy port
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /readyz
port: 8080 # HTTP proxy port
initialDelaySeconds: 5
periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
name: my-api
spec:
type: ClusterIP
selector:
app: my-api
ports:
- port: 80
targetPort: 8080 # HTTP proxy port
Deployment Strategies
| Strategy |
Use Case |
Configuration |
| RollingUpdate |
Zero-downtime updates |
maxSurge: 25%, maxUnavailable: 25% |
| Recreate |
Stateful apps, incompatible versions |
type: Recreate |
| Blue-Green |
Instant rollback |
Two deployments, switch Service selector |
| Canary |
Gradual rollout |
Multiple deployments with weighted traffic |
Blue-Green Deployment
# Blue deployment (current production)
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-api-blue
labels:
app: my-api
version: blue
spec:
replicas: 3
selector:
matchLabels:
app: my-api
version: blue
template:
metadata:
labels:
app: my-api
version: blue
spec:
containers:
- name: my-api
image: my-registry/my-api:v1.0.0
---
# Service points to blue
apiVersion: v1
kind: Service
metadata:
name: my-api
spec:
selector:
app: my-api
version: blue # Switch to 'green' for deployment
ports:
- port: 80
targetPort: 8080 # 8080: HTTP proxy port
Service Types
| Type |
Use Case |
Access |
| ClusterIP |
Internal services |
my-api.namespace.svc.cluster.local |
NodePor
Ready to use kubernetes-deployment-creator?
|