Pod를 배포(업데이트)하는 방법
- Blue, Green update
- Canary update
- Rolling update
Canary 배포란?
- 기존 버전을 유지한 채로 일부 버전만 신규 버전으로 올려서 신규 버전에 버그나 이상은 없는지 확인
- definition
apiVersion: apps/v1
kind: Deployment
metadata:
name: mainui-canary
spec:
replicas: 1
selector:
matchLabels:
app: mainui
version: canary
template:
metadata:
labels:
app: mainui
version: canary
spec:
containers:
- name: mainui
image: nginx:1.15
ports:
- containerPort: 80
[ Hands - on ] : label를 이용한 Canary 배포
- Deployment로 pod 생성 및 확인
vi mainui-stable.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mainui-stable
spec:
replicas: 2
selector:
matchLabels:
app: mainui
version: stable
template:
metadata:
labels:
app: mainui
version: stable
spec:
containers:
- name: mainui
image: nginx:1.14
ports:
- containerPort: 80
kubectl create -f mainui-stable.yaml
kubectl get pods --show-lables
NAME READY STATUS RESTARTS AGE LABELS
mainui-stable-7dd79788-cs88h 1/1 Running 0 73s app=mainui,pod-template-hash=7dd79788,version=stable
mainui-stable-7dd79788-ncp6x 1/1 Running 0 73s app=mainui,pod-template-hash=7dd79788,version=stable
- 단일 진입점 생성 및 접속 확인
vi mainui-service.yaml
apiVersion: v1
kind: Service
metadata:
name: mainui-svc
spec:
selector:
app: mainui
ports:
- port: 80
protocol: TCP
targetPort: 80
kubectl create -f mainui-service.yaml
kubectl describe service mainui-svc
Name: mainui-svc
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=mainui
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.98.12.13
IPs: 10.98.12.13
Port: <unset> 8080/TCP
TargetPort: 8080/TCP
Endpoints: 192.168.11.82:80,192.168.221.17:80
Session Affinity: None
Events: <none>
curl 10.98.12.13
- Canary version pod 생성
vi mainui-canary.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mainui-canary
spec:
replicas: 1
selector:
matchLabels:
app: mainui
version: canary
template:
metadata:
labels:
app: mainui
version: canary
spec:
containers:
- name: mainui
image: nginx:1.15
ports:
- containerPort: 80
kubectl create -f mainui-canary.yaml
kubectl describe service mainui-svc
Name: mainui-svc
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=mainui
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.98.12.13
IPs: 10.98.12.13
Port: <unset> 80/TCP
TargetPort: 80/TCP
Endpoints: 192.168.11.82:80,192.168.11.83:80,192.168.221.17:80 #canary version 추가
Session Affinity: None
Events: <none>
- Canary version pod 증가
kubectl scale deployment mainui-canary --replicas=2
- pod 삭제
kubectl delete deployments.apps mainui-canary
kubectl delete deployments.apps mainui-stable
<이미지 참고 : https://www.youtube.com/watch?v=u588KXtBoKU&list=PLApuRlvrZKohaBHvXAOhUD-RxD0uQ3z0c&index=33>
참고 : https://www.youtube.com/watch?v=u588KXtBoKU&list=PLApuRlvrZKohaBHvXAOhUD-RxD0uQ3z0c&index=33
'INFRA > DevOps' 카테고리의 다른 글
[k8s] Secret (1) | 2023.01.25 |
---|---|
[K8s] ConfigMap (0) | 2023.01.16 |
[K8s] Annotation (0) | 2023.01.03 |
[k8s] Label (0) | 2022.12.29 |
[K8S 1.24 버전 업그레이드] dockershim vs containerd (0) | 2022.12.21 |
댓글