Deployment
Recreate, RollingUpdate
1. ReCreate
1-1) Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-1
spec:
selector:
matchLabels:
type: app
replicas: 2
strategy:
type: Recreate
revisionHistoryLimit: 1
template:
metadata:
labels:
type: app
spec:
containers:
- name: container
image: kubetm/app:v1
terminationGracePeriodSeconds: 10
1-2) Service
apiVersion: v1
kind: Service
metadata:
name: svc-1
spec:
selector:
type: app
ports:
- port: 8080
protocol: TCP
targetPort: 8080
Command
while true; do curl 10.99.5.3:8080/version; sleep 1; done
Kubectl
kubectl rollout undo deployment deployment-1 --to-revision=2
kubectl rollout history deployment deployment-1
2. RollingUpdate
2-1) Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-2
spec:
selector:
matchLabels:
type: app2
replicas: 2
strategy:
type: RollingUpdate
minReadySeconds: 10
template:
metadata:
labels:
type: app2
spec:
containers:
- name: container
image: kubetm/app:v1
terminationGracePeriodSeconds: 0
2-2) Service
apiVersion: v1
kind: Service
metadata:
name: svc-2
spec:
selector:
type: app2
ports:
- port: 8080
protocol: TCP
targetPort: 8080
Command
while true; do curl 10.99.5.3:8080/version; sleep 1; done
3. Blue/Green
ReplicaSet
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: replica1
spec:
replicas: 2
selector:
matchLabels:
ver: v1
template:
metadata:
name: pod1
labels:
ver: v1
spec:
containers:
- name: container
image: kubetm/app:v1
terminationGracePeriodSeconds: 0
Service
apiVersion: v1
kind: Service
metadata:
name: svc-3
spec:
selector:
ver: v1
ports:
- port: 8080
protocol: TCP
targetPort: 8080