본문 바로가기
software engineering/k8s

Deployments - Updating a Deployment

by _블로그 2021. 2. 10.

Updating a Deployment

Deployment's Pod template 변경이 있어야 rollout이 트리거 됨.

 

아래 명령어로 nginx image update 가능. --record 쓰면 .metadata.annotation[kubernetes.io/change-cause]에 명령어가 추가된다.

kubectl set image deployment/nginx-deployment nginx=nginx:1.16.1 --record

edit 명령어로 직접 vi로 yaml 수정하는 방법도 있음.

kubectl edit deployment.v1.apps/nginx-deployment

업데이트 시에 설정된 replica 수의 최소 75% 이상의 pods 수를 유지하며, 최대 125%의 pods 수만 생성되게 조절 함. 즉 업데이트 시 25%까지만 여유분을 둠. 결론은 설정한 수에 크게 영향이 안 가도록 잘 조절하며 바꿔치기 한다는 얘기.

 

위 내용은 아래 명령어의 Events 란에서 실제 Sacled up/down 된 것 확인할 수 있음

k describe deployments nginx-deployment

Rollover (aka multiple updates in-flight)

위에서 봤듯이 Deployment의 image 업데이트하면 기존 pods는 0으로 scaled down 되고 새로운 pods이 replicas 수에 맞게 셋업된다.

 

Deployment rollout 중에 update를 시도하면 새로운 ReplicaSet을 생성하여 scale up 시도하고 기존 ReplicaSet은 바로 scale down 한다.

Label selector updates

label selector 추가/수정은 기존 rs를 고아로 만들고 새로운 rs를 생성. ? 그럼 기존 rs는 수동으로 제거해야 되나?

LIST

댓글