ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 틀린 문제 #4 Static Pod
    kubernetes/CKA 2025. 12. 5. 11:18

    문제 1

    Create a static pod named static-busybox that uses the busybox image , run in the default namespace and the command sleep 1000


    # --dry-run=client -o yaml 명령어로 static-busybox.yaml 파일 생성

    kubectl run static-busybox --image=busybox --dry-run=client -o yaml --command -- sleep 1000 > static-busybox.yaml

     

    # static pods 생성을 위해 static-busybox.yaml 파일을 /etc/kubernetes/manifests로 이동

    cp static-busybox.yaml /etc/kubernetes/manifests/

     

    # 생성 확인

    kubectl get pods
    NAME                          READY   STATUS    RESTARTS   AGE
    static-busybox-controlplane   1/1     Running   0          5s

     

    문제 2

    Edit the image on the static pod you created in the previous task to use busybox:1.28.4


    # edit 명령어로 기존 pod 수정

    kubectl edit pods static-busybox-controlplane
    pod/static-busybox-controlplane edited

     

    이미지만 1.28.4로 변경해준다.

     

    문제 3

    We just created a new static pod named static-greenbox. Find it and delete it.

     

    This question is a bit tricky. But if you use the knowledge you gained in the previous questions in this lab, you should be able to find the answer to it.


    # 현재 pod 확인

    kubectl get pods -o wide
    NAME                          READY   STATUS    RESTARTS   AGE     IP           NODE           NOMINATED NODE   READINESS GATES
    static-busybox-controlplane   1/1     Running   0          10m     172.17.0.4   controlplane   <none>           <none>
    static-greenbox-node01        1/1     Running   0          5m45s   172.17.1.2   node01         <none>           <none>

     

    static-greenbox-node01 pod는 node 01에 위치한 것을 확인

     

    # node01 IP 확인

    kubectl get nodes -o wide
    NAME           STATUS   ROLES           AGE   VERSION   INTERNAL-IP       EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION    CONTAINER-RUNTIME
    controlplane   Ready    control-plane   31m   v1.34.0   192.168.243.140   <none>        Ubuntu 22.04.5 LTS   5.15.0-1083-gcp   containerd://1.6.26
    node01         Ready    <none>          30m   v1.34.0   192.168.117.22    <none>        Ubuntu 22.04.5 LTS   5.15.0-1083-gcp   containerd://1.6.26

     

    # node01 접속

    ssh 192.168.117.22

     

    # node01 내 static pod 경로 확인

    node01 ~ ✖ cat /var/lib/kubelet/config.yaml
    apiVersion: kubelet.config.k8s.io/v1beta1
    authentication:
      anonymous:
        enabled: false
      webhook:
        cacheTTL: 0s
        enabled: true
      x509:
        clientCAFile: /etc/kubernetes/pki/ca.crt
    authorization:
      mode: Webhook
      webhook:
        cacheAuthorizedTTL: 0s
        cacheUnauthorizedTTL: 0s
    cgroupDriver: cgroupfs
    clusterDNS:
    - 172.20.0.10
    clusterDomain: cluster.local
    containerRuntimeEndpoint: unix:///var/run/containerd/containerd.sock
    cpuManagerReconcilePeriod: 0s
    crashLoopBackOff: {}
    evictionPressureTransitionPeriod: 0s
    fileCheckFrequency: 0s
    healthzBindAddress: 127.0.0.1
    healthzPort: 10248
    httpCheckFrequency: 0s
    imageMaximumGCAge: 0s
    imageMinimumGCAge: 0s
    kind: KubeletConfiguration
    logging:
      flushFrequency: 0
      options:
        json:
          infoBufferSize: "0"
        text:
          infoBufferSize: "0"
      verbosity: 0
    memorySwap: {}
    nodeStatusReportFrequency: 0s
    nodeStatusUpdateFrequency: 0s
    rotateCertificates: true
    runtimeRequestTimeout: 0s
    shutdownGracePeriod: 0s
    shutdownGracePeriodCriticalPods: 0s
    staticPodPath: /etc/just-to-mess-with-you
    streamingConnectionIdleTimeout: 0s
    syncFrequency: 0s
    volumeStatsAggPeriod: 0s

     

    /var/lib/kubelet/config.yaml 파일 내에서 staticPodPath를 확인해준다.

    staticPodPath: /etc/just-to-mess-with-you 이다.

     

    # 해당 경로에서 파일 삭제

    node01 ~ ➜  cd /etc/just-to-mess-with-you
    node01 /etc/just-to-mess-with-you ➜  ls
    greenbox.yaml
    node01 /etc/just-to-mess-with-you ✖ rm -f greenbox.yaml

     

    # control plane으로 이동 후 pod 확인

    node01 /etc/just-to-mess-with-you ➜  exit
    logout
    Connection to 192.168.117.22 closed.
    controlplane ~ ✖ kubectl get pods
    NAME                          READY   STATUS    RESTARTS   AGE
    static-busybox-controlplane   1/1     Running   0          15m

     

    pod가 삭제된 것을 확인 가능

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

    틀린 문제 #5. Priority Classes  (0) 2025.12.05
    Priority Classes  (0) 2025.12.05
    Static pod  (0) 2025.12.05
    틀린 문제 # DaemonSet  (0) 2025.12.05
    Taints/Tolerations와 Node Affinity의 차이  (0) 2025.12.04
Designed by Tistory.