• Replicaset의 부모로 Replicaset 을 제어, Replicaset은 pod를 제어
  • 롤링 업데이트를 위해 만들어줌
    • 서비스 중단없이 업데이트를 이룸
  • 사용할때 kind를 Replicaset,Deployment 둘중 하나를 사용한것 외에는 크게 달라지는 점은 없다.
  • 롤링업데이트 방법
kubectl set image deployment <deploy_name> <container_name>=<new_versiong_image>
kubectl set image deployment <deploy_name> <container_name>=<new_versiong_image> -- record
  • 롤백
kubectl rollout undo deploy  
kubectl rollout history deployment
  • 만약 3개짜리 pod를 쓰고 있는데 update를 하면 1개의 pod를 업데이트(그동안 2개가 서비스), 그다음 2개의 pod를 업데이트,,,전부 업데이트,,, 이런식으로 된다
  • 업데이트 기록 로그 확인(yaml파일의 spec의 revisionHistoryLimit 갯수로 기록 로그 저장 갯수 제한 가능)
    • rollout의 resume , pause등을 통해 업데이트를 중단하고 재개할 수 있다.
    • undo 명령어를 통해 이전 버전으로 돌아갈 수 있다.
    • to-revision 명령어로 특정 버전을 찍고 돌아갈 수 있다.
  • kubectl rollout history deploymen ${name} deployment.apps/${name} REVISION CHANGE-CAUSE 1
  • 업데이트 기록이 나오게 하려면 생성할때 --record를 쓴다
kubectl create -f ${name} --record

deployment.apps/${name} created

kubectl rollout history deployment ${name}

deployment.apps/${name}  
REVISION CHANGE-CAUSE  
1 kubectl create --filename= ${name} --record=true
  • spec의 rolling update
spec:  
progressDeadlineSeconds: 100  
revisionHistoryLimit: 10  
strategy:  
rollingUpdate:  
maxSurge: 25%  
maxUnavailable: 25%  
type: RollingUpdate  
replicas: 3
  • 이렇게 된 경우 3(레플리카 갯수)*0.25 = 0.75, 반올림하여 1인데,
  • 그러면 3개중에 1개의 여유를 업데이트 할 때 갖을 수 있다.
  • 그러면 3개(업데이트 안됨)+1(업데이트 됨)=>2개+2개=>1개+3개=>3개 이런식으로 업뎃이 진행된다
  • kubectl apply -f 명령어를 이용해 업데이트를 진행할 수 있다.

+ Recent posts