Net Eng

[CKA] - Rolling update & Roll Back 본문

Cloud/Kubernetes

[CKA] - Rolling update & Roll Back

欲心 2024. 1. 19. 17:54

1. 배포 정책/업데이트 정책
- Rolling update/Rollback
- Canary update
- Blue-Green

2. Rolling update/Rollback
1) kubectl set image

kubebctl set image deploy DEPLOY CONTAINER=버전 --record


2) kubectl edit

3) kubectl apply

3. Rollback

kubectl rollout history deploy DEPLOY
kubectl rollout undo deploy DEPLOY

 


 

[선수 작업]

kubectl config set-context k8s --user=kubernetes-admin --cluster=kubernetes

 


 

[문제]

Q. Create a deployments as follows:

 

작업 클러스터: k8s

 

TASK:

name: nginx-app

Using container nginx with version 1.11.10-alpine

The deployment should contain 3 replicas

 

Next, deploy the application with new version 1.11.13-alpine, by performing a rolling update

 

Finally, rollback that update to the previous version 1.11.10-alpine


 

[풀이]

kubectl config use-context k8s

* k8s 클러스터로 변경

 

kubectl create deploy nginx-app --image=nginx:1.11.10-alpine --replicas=3

* 1.11.10 버전으로 deploy 생성

 

kubectl set image deployment/nginx-app nginx=nginx:1.11.13-alpine --record

* 1.11.13 버전으로 롤링 업데이트

 

kubectl rollout status deployment nginx-app

* 상태 확인

 

kubectl rollout history deployment nginx-app

* 히스토리 확인

 

kubectl describe deployment/nginx-app

* 변경 내용 확인

 

kubectl rollout undo deployment nginx-app

* previous 버전으로 롤백

 

kubectl rollout status deployment nginx-app

* 상태 확인

 

kubectl get deploy,rs,po -o wide

* 변경 내용 확인

 


 

[참고]

 

Deployments

A Deployment manages a set of Pods to run an application workload, usually one that doesn't maintain state.

kubernetes.io

 

'Cloud > Kubernetes' 카테고리의 다른 글

[CKA] - Node 관리  (0) 2024.01.21
[CKA] - Node Labels & nodeSelector  (0) 2024.01.21
[CKA] - Deployment & Pod Scale  (0) 2024.01.19
[CKA] - Side-car Container Pod 생성하기  (0) 2024.01.19
[CKA] - Multi-Container Pod 생성하기  (0) 2024.01.19