Kubernetes – Deployments
- Deployment is one of the most used object by DevOps engineers.
- Most of the DevOps work is involved around making deployments and making regular changes to the application code.
- Deployments are used for Upgrading apps/pod images, rollback, and performing these changes gracefully.
- A Deployment controller provides declarative updates for Pods and Replica sets.
- Deployment manages the replica sets to manage the number of pods.
Deployment Definition File – Sample 1
## Deploy 3 pods of name http-frontend, of image httpd on alpine 2.4
---
apiVersion: apps/v1
## Note the Kind type here
kind: Deployment
metadata:
name: httpd-frontend
spec:
selector:
## Note: ReplicaSets will not have the "matchLabels"
matchLabels:
name: httpd-frontend
template:
metadata:
labels:
name: httpd-frontend
spec:
containers:
- image: httpd:2.4-alpine
name: httpd-frontend
replicas: 3
Deployment Definition File – Sample 2
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx-server
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx-servers
image: nginx:latest
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 80