Kubernetes/CKA

Static Pod는 왜 namespace 지정이 안될까?

leaf1991 2024. 8. 20. 15:17

그것은 static pod의 특성때문이다.

스태틱 파드의 특성

  1. 네임스페이스 지정 불가: 스태틱 파드는 Kubernetes에서 직접 관리하는 것이 아니라, 노드의 kubelet에 의해 관리된다.
    스태틱 파드의 설정 파일을 배치할 때, 파드의 메타데이터에 namespace 필드를 지정할 수 없으며, 기본적으로 default 네임스페이스에 배치됨.
    따라서 k get pod -n node01 명령어로 조회하려고 했을 때, node01이라는 네임스페이스가 존재하지 않으므로 파드가 조회되지 않는 것이였다..
  2. 스태틱 파드는 노드에 종속: 스태틱 파드는 특정 노드에서 실행되며, 해당 노드의 /etc/kubernetes/manifests/ 디렉토리 안에 YAML 파일을 배치하여 생성됨.
    따라서 해당 파드는 지정된 노드에서만 실행되며, 이 파드는 해당 노드에서만 관리된다..

설명에서 "Controlled By: Node/node01"이 나오는 이유

스태틱 파드는 kubelet에 의해 관리되므로, kubectl describe pod 명령어를 실행했을 때 Controlled By: Node/node01라는 설명이 나옵니다. 이는 해당 파드가 Kubernetes의 일반적인 컨트롤러(예: Deployment, ReplicaSet 등)에 의해 관리되는 것이 아니라, 특정 노드(node01)에 의해 관리된다는 것을 의미한다.

Name:         nginx-critical-node01
Namespace:    default
Priority:     0
Node:         node01/192.10.114.3
Start Time:   Tue, 20 Aug 2024 06:10:14 +0000
Labels:       run=nginx-critical
Annotations:  kubernetes.io/config.hash: 57cdbcad420cc9d8a04b83e4181d4b12
              kubernetes.io/config.mirror: 57cdbcad420cc9d8a04b83e4181d4b12
              kubernetes.io/config.seen: 2024-08-20T06:10:14.695524487Z
              kubernetes.io/config.source: file
Status:       Running
IP:           10.244.192.7
IPs:
  IP:           10.244.192.7
Controlled By:  Node/node01
Containers:
  nginx-critical:
    Container ID:   containerd://4c90eee478e7cc6b702b15d1458bcc4e656a11499cf1b8e41671fff97293a5f2
    Image:          nginx
    Image ID:       docker.io/library/nginx@sha256:447a8665cc1dab95b1ca778e162215839ccbb9189104c79d7ec3a81e14577add
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Tue, 20 Aug 2024 06:10:15 +0000
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:         <none>
Conditions:
  Type                        Status
  PodReadyToStartContainers   True 
  Initialized                 True 
  Ready                       True 
  ContainersReady             True 
  PodScheduled                True 
Volumes:                      <none>
QoS Class:                    BestEffort
Node-Selectors:               <none>
Tolerations:                  :NoExecute op=Exists
Events:
  Type    Reason   Age   From     Message
  ----    ------   ----  ----     -------
  Normal  Pulling  39s   kubelet  Pulling image "nginx"
  Normal  Pulled   39s   kubelet  Successfully pulled image "nginx" in 170ms (170ms including waiting). Image size: 71026652 bytes.
  Normal  Created  39s   kubelet  Created container nginx-critical
  Normal  Started  39s   kubelet  Started container nginx-critical

결론적으로, 스태틱 파드는 항상 default 네임스페이스에 존재하며, 네임스페이스를 따로 지정할 수 없다.
따라서 k get pod -n node01로 조회가 되지 않고, k get pod 명령어로 default 네임스페이스에서 조회되는 것이 정상이다.

 

 

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

CKA 문제 업데이트 공지 // 2024년 11월 25일 이후  (0) 2024.09.10
CKA 자격증 취득 후기  (1) 2024.09.10
emptyDir 이해  (0) 2024.08.11
Upgrade kubernetes 1.29.0 -> 1.30.0  (1) 2024.07.29
Cluster Upgrade Process  (1) 2024.07.15