ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 틀린 문제 #6. Rolling Updates and Rollbacks
    kubernetes/CKA 2025. 12. 10. 10:04

    문제 1

    Let us try that. Upgrade the application by setting the image on the deployment to kodekloud/webapp-color:v2


    Do not delete and re-create the deployment. Only set the new image name for the existing deployment.

     
     

    Deployment Name: frontend

     

    Deployment Image: kodekloud/webapp-color:v2


    # Deployment 확인

    kubectl get deploy
    NAME       READY   UP-TO-DATE   AVAILABLE   AGE
    frontend   4/4     4            4           6m4s

     

    # Deployment 상세 확인

    kubectl describe deploy frontend
    Name:                   frontend
    Namespace:              default
    CreationTimestamp:      Wed, 10 Dec 2025 00:52:11 +0000
    Labels:                 <none>
    Annotations:            deployment.kubernetes.io/revision: 1
    Selector:               name=webapp
    Replicas:               4 desired | 4 updated | 4 total | 4 available | 0 unavailable
    StrategyType:           RollingUpdate
    MinReadySeconds:        20
    RollingUpdateStrategy:  25% max unavailable, 25% max surge
    Pod Template:
      Labels:  name=webapp
      Containers:
       simple-webapp:
        Image:         kodekloud/webapp-color:v1
        Port:          8080/TCP
        Host Port:     0/TCP
        Environment:   <none>
        Mounts:        <none>
      Volumes:         <none>
      Node-Selectors:  <none>
      Tolerations:     <none>
    Conditions:
      Type           Status  Reason
      ----           ------  ------
      Available      True    MinimumReplicasAvailable
      Progressing    True    NewReplicaSetAvailable
    OldReplicaSets:  <none>
    NewReplicaSet:   frontend-6b86c6b555 (4/4 replicas created)
    Events:
      Type    Reason             Age    From                   Message
      ----    ------             ----   ----                   -------
      Normal  ScalingReplicaSet  6m12s  deployment-controller  Scaled up replica set frontend-6b86c6b555 from 0 to 4

     

    # Rolling Update

    kubectl set image deployment frontend simple-webapp=kodekloud/webapp-color:v2
    deployment.apps/frontend image updated

     

    문제 2

    Change the deployment strategy to Recreate


    Delete and re-create the deployment if necessary. Only update the strategy type for the existing deployment.

     
     

    Deployment Name: frontend

     

    Deployment Image: kodekloud/webapp-color:v2

     

    Strategy: Recreate


    # 이미 존재하는 deploy의 정보를 yaml 파일로 생성

    kubectl get deploy frontend -o yaml > frontend.yaml

     

    # frontend.yaml에서 Strategy를 Recreate로 변경

    vi frontend.yaml
    ----------------
    ...
      strategy:
        type: Recreate
    ...
    ----------------

     

    # 현재 존재하는 Deploy 삭제

    kubectl delete deploy frontend
    deployment.apps "frontend" deleted from default namespace

     

    # 재배포

    kubectl create -f frontend.yaml
    deployment.apps/frontend created

     

    문제 3

    Upgrade the application by setting the image on the deployment to kodekloud/webapp-color:v3


    Do not delete and re-create the deployment. Only set the new image name for the existing deployment.

     
     

    Deployment Name: frontend

     

    Deployment Image: kodekloud/webapp-color:v3


    # Deploy 정보 확인

    kubectl get deploy
    NAME       READY   UP-TO-DATE   AVAILABLE   AGE
    frontend   4/4     4            4           15m
    kubectl describe deploy frontend
    Name:                   frontend
    Namespace:              default
    CreationTimestamp:      Wed, 10 Dec 2025 00:52:11 +0000
    Labels:                 <none>
    Annotations:            deployment.kubernetes.io/revision: 2
    Selector:               name=webapp
    Replicas:               4 desired | 4 updated | 4 total | 4 available | 0 unavailable
    StrategyType:           RollingUpdate
    MinReadySeconds:        20
    RollingUpdateStrategy:  25% max unavailable, 25% max surge
    Pod Template:
      Labels:  name=webapp
      Containers:
       simple-webapp:
        Image:         kodekloud/webapp-color:v2
        Port:          8080/TCP
        Host Port:     0/TCP
        Environment:   <none>
        Mounts:        <none>
      Volumes:         <none>

     

    # Rolling Update

    kubectl set image deploy frontend simple-webapp=kodekloud/webapp-color:v3

     

    # 확인

     watch -n 2 kubectl get deploy
     watch -n 2 kubectl get pods

     

    watch 옵션은 리소스를 실시간으로 반복 조회

    watch -n 2 : 2초마다 반복

    'kubernetes > CKA' 카테고리의 다른 글

    Metric Server  (0) 2025.12.08
    Multiple Scheduler  (0) 2025.12.05
    틀린 문제 #5. Priority Classes  (0) 2025.12.05
    Priority Classes  (0) 2025.12.05
    틀린 문제 #4 Static Pod  (0) 2025.12.05
Designed by Tistory.