DevOps

CKA 예제 리마인더 - 13. Rolling Updates and Rollbacks

Vince_rf 2024. 10. 31. 02:10


롤링업데이트를 하는 디플로이를 생성하세요

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  creationTimestamp: "2024-10-30T16:55:55Z"
  generation: 1
  name: frontend
  namespace: default
  resourceVersion: "905"
  uid: 4e331b0d-b765-4487-ab01-a84a98340324
spec:
  minReadySeconds: 20
  progressDeadlineSeconds: 600
  replicas: 4
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      name: webapp
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        name: webapp
    spec:
      containers:
      - image: kodekloud/webapp-color:v2
        imagePullPolicy: IfNotPresent
        name: simple-webapp
        ports:
        - containerPort: 8080
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  availableReplicas: 4
  conditions:
  - lastTransitionTime: "2024-10-30T16:56:21Z"
    lastUpdateTime: "2024-10-30T16:56:21Z"
    message: Deployment has minimum availability.
    reason: MinimumReplicasAvailable
    status: "True"
    type: Available
  - lastTransitionTime: "2024-10-30T16:55:55Z"
    lastUpdateTime: "2024-10-30T16:56:21Z"
    message: ReplicaSet "frontend-7b5df69f4" has successfully progressed.
    reason: NewReplicaSetAvailable
    status: "True"
    type: Progressing
  observedGeneration: 1
  readyReplicas: 4
  replicas: 4
  updatedReplicas: 4




업데이트 전략을 Recrate 로 바꾸세요

spec.strategy 에서 rollingUpdate 필드 주석, type을 Recreate로 수정

  strategy:
    #rollingUpdate:
      #maxSurge: 25%
      #maxUnavailable: 25%
    type: Recreate