728x90
반응형
canary deployment (카나리 배포)
정의
파드를 배포(업데이트)하는 방법
배포 방법 | 설명 |
블루 그린 업데이트 | 블루 제품을 전부 제거 후 그린 제품을 업데이트 (서비스 중단 간격이 생김) |
롤링 업데이트 | 서비스 중단없이 한 개씩 업데이트 하는 방법 |
카나리 배포 | 기존 버전을 유지한 채로 일부 버전만 신규 버전으로 올려서 신규 버전에 버그나 이상은 없는지 확인 |
시나리오
- name=mainui version=stable 버전의 pod를 생성
root@master:~# cat > 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: nginx image: nginx:1.14 ports: - containerPort: 80 root@master:~# kubectl create -f mainui-stable.yaml deployment.apps/mainui-stable created
- name=mainui를 selector하는 service 생성
root@master:~# cat > mainui-service.yaml apiVersion: v1 kind: Service metadata: name: mainui-svc spec: selector: app: mainui ports: - port: 80 protocol: TCP targetPort: 8080 root@master:~# kubectl create -f mainui-service.yaml service/mainui-svc created root@master:~# kubectl get svc -o wide NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2d1h <none> mainui-svc ClusterIP 10.108.214.91 <none> 80/TCP 6s app=mainui root@master:~# kubectl describe svc 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.108.214.91 IPs: 10.108.214.91 Port: <unset> 80/TCP TargetPort: 8080/TCP Endpoints: 10.36.0.1:8080,10.44.0.3:8080 Session Affinity: None Events: <none>
- name=mainui version=canary 버전의 pod를 생성
root@master:~# cat > 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: nginx image: nginx:1.14 ports: - containerPort: 80 root@master:~# kubectl create -f mainui-canary.yaml deployment.apps/mainui-canary created
- stable, canary 버전이 공존해 있으면서 배포된 것을 확인
root@master:~# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES mainui-canary-58cbfd7f4-lv82l 1/1 Running 0 15s 10.36.0.2 node1.example.com <none> <none> mainui-stable-59c9f65b7c-n2zss 1/1 Running 0 7m11s 10.36.0.1 node1.example.com <none> <none> mainui-stable-59c9f65b7c-xz559 1/1 Running 0 7m10s 10.44.0.3 node2.example.com <none> <none> root@master:~# kubectl get deployments.apps NAME READY UP-TO-DATE AVAILABLE AGE mainui-canary 1/1 1 1 78s mainui-stable 2/2 2 2 8m14s root@master:~# kubectl describe svc 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.108.214.91 IPs: 10.108.214.91 Port: <unset> 80/TCP TargetPort: 8080/TCP Endpoints: 10.36.0.1:8080,10.36.0.2:8080,10.44.0.3:8080 Session Affinity: None Events: <none>
- canary 버전의 pod 개수 조절하여 확인
root@master:~# kubectl scale deployment mainui-canary --replicas=2 deployment.apps/mainui-canary scaled root@master:~# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES mainui-canary-58cbfd7f4-jt2nw 1/1 Running 0 16s 10.44.0.4 node2.example.com <none> <none> mainui-canary-58cbfd7f4-lv82l 1/1 Running 0 110s 10.36.0.2 node1.example.com <none> <none> mainui-stable-59c9f65b7c-n2zss 1/1 Running 0 8m46s 10.36.0.1 node1.example.com <none> <none> mainui-stable-59c9f65b7c-xz559 1/1 Running 0 8m45s 10.44.0.3 node2.example.com <none> <none> root@master:~# kubectl get deployments.apps NAME READY UP-TO-DATE AVAILABLE AGE mainui-canary 2/2 2 2 96s mainui-stable 2/2 2 2 8m32s-09 root@master:~# kubectl describe svc 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.108.214.91 IPs: 10.108.214.91 Port: <unset> 80/TCP TargetPort: 8080/TCP Endpoints: 10.36.0.1:8080,10.36.0.2:8080,10.44.0.3:8080 + 1 more... Session Affinity: None Events: <none>
- canary 버전 제거하고 stable 버전만 유지
root@master:~# kubectl delete deployment mainui-canary deployment.apps "mainui-canary" deleted root@master:~# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES mainui-stable-59c9f65b7c-n2zss 1/1 Running 0 9m47s 10.36.0.1 node1.example.com <none> <none> mainui-stable-59c9f65b7c-xz559 1/1 Running 0 9m46s 10.44.0.3 node2.example.com <none> <none> root@master:~# kubectl get deployments.apps NAME READY UP-TO-DATE AVAILABLE AGE mainui-stable 2/2 2 2 9m51s root@master:~# kubectl describe svc 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.108.214.91 IPs: 10.108.214.91 Port: <unset> 80/TCP TargetPort: 8080/TCP Endpoints: 10.36.0.1:8080,10.44.0.3:8080 Session Affinity: None Events: <none>
728x90
반응형
'DevOps > Kubernetes' 카테고리의 다른 글
Kubernetes - Helm (헬름) (0) | 2021.12.28 |
---|---|
Kubernetes 대시보드 설치 (0) | 2021.12.08 |
Kubernetes - Ingress (인그레스) (0) | 2021.12.01 |
Kubernetes - kube-proxy (0) | 2021.11.30 |
Kubernetes - Headless Service (0) | 2021.11.30 |