Deployment 템플릿 & 관련 명령어


apiVersion: apps/v1
kind: Deployment
metadata:
  name: web                                 # 디플로이명
  labels:
    name: web-apache                         # <- 지정하는 것을 app으로 할건지 name으로 할건지 통일해야함
  annotations:
    kubernetes.io/change-cause: version 2.2 # <- 업뎃하기 전 여기 수정해야함 ex) to 2.4
spec:
  progressDeadlineSeconds: 600              # 10분까지 업뎃 못하면 취소
  revisionHistoryLimit: 10                  # 히스토리에 10개까지 기록
  strategy:
    rollingUpdate:
      maxSurge: 25%                         # update 되는 pod 갯수
      maxUnavailable: 25%                   # terminating 되는 pod 갯수
    type: RollingUpdate
  replicas: 2
  selector:
    matchLabels:
      name: web-apache
    matchExpressions:
    - {key: app, operator: In, values: ["main"]}
    - {key: rel, operator: In, values: ["stable"]}
  template:
    metadata:
     labels:
       name: web-apache
       app : main
       rel : stable
    spec:
      containers:
      - name: apache-container              # 컨테이너명
        image: httpd:2.2                    # <- 업뎃하기 전 여기 수정해야함
--- 1. ##### scale 변경 `$ kubectl scale deployment {디플로이명} --replicas=2` 2. ##### 롤링 업데이트 _yaml 파일 annotations 및 image version 수정후_ `$ kubectl apply -f [filename]` 3. ##### 히스토리 확인 `$ kubectl rollout history deployment {디플로이명}` 4. ##### 롤백 `$ kubectl rollout undo deployment {디플로이명} --to-revision={REVISION 번호}` 5. ##### 버전확인 `$ kubectl describe pod {파드명} | grep "Image:"`
되돌아가기 수정