Kubernetes/KoudKloud - CKAD with Tests

Deployments 업데이트 관련

비번변경 2021. 12. 7. 18:18

2021.11.15 - deployment 확인 및 생성 명령어

이 글에서는 Deployments의 업데이트 전략을 확인하고, 수정하는 방법에 대해 정리한다.

 

Deployments Update 전략 확인

describe 명령 실행 결과에서 StrategyType 필드를 확인한다.

kubectl describe deployments.apps <NAME>

Deployments Update 전략 확인

 

Deployments Rolling Update 시 삭제 가능한 포드 수 확인

describe 명령 실행 결과에서 RollingUpdateStrategy 필드를 확인한다.

Deployments Rolling Update 시 삭제 가능한 포드 수 확인

  • max unavailable : Rolling Update 시 동시 삭제가 가능한 포드의 최대 개수
  • max surge : Rolling Update 시 동시 생성이 가능한 포드의 최대 개수

두 값 모두 기본값은 25%이다.

 

Deployments Update

edit 명령어로 image 등 업데이트할 정보를 수정하여 저장한다.

kubectl edit deployments.apps <NAME>

 

Deployments Update 전략 수정

edit 명령어로 .spec.strategy 필드를 수정한다.

기존 Rolling Update 전략을 Recreate 전략으로 수정하고자 한다면, .spec.strategy.type을 Recreate로 변경한 후, .spec.strategy.rollingUpdate에 해당하는 필드를 삭제한다.

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "2"
  creationTimestamp: "2021-11-27T07:52:17Z"
  generation: 2
  name: frontend
  namespace: default
  resourceVersion: "1069"
  uid: 4a6abc78-bf2d-4292-a0dd-b030ebb213e3
spec:
  minReadySeconds: 20
  progressDeadlineSeconds: 600
  replicas: 4
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      name: webapp
  strategy:
    type: Recreate
728x90