Core concepts - PODs

Ju Young Pang

·

2025. 1. 16. 13:37

Q) How many pods exist on the system (all namespaces)?

$ k get pod -A | wc -l
8

# wc는 word count의 약자
# option 목록:
# -l : count lines
# -w : count words
# -m : count characters (공백 포함)
# -c : count bytes
# option이 없으면 line, words, character순으로 return

A) 7

저 위의 값에는 헤더도 포함되어있는 값이기 때문에 하나를 뺀 7개가 담임

 

Q) Create a new pod with the nginx image.

$ k run nginx --image=nginx
pod/nginx created

 

Q) What image was used to create the new pods?

$ k get po
NAME            READY   STATUS    RESTARTS   AGE
newpods-5z68b   1/1     Running   0          9m4s
newpods-chl7v   1/1     Running   0          9m4s
newpods-dkl8n   1/1     Running   0          9m4s
nginx           1/1     Running   0          6m

$ k describe po newpods-5z68b
Name:             newpods-5z68b
Namespace:        default
Priority:         0
Service Account:  default
Node:             controlplane/192.168.212.189
Start Time:       Thu, 16 Jan 2025 04:43:44 +0000
Labels:           tier=busybox
Annotations:      <none>
Status:           Running
IP:               10.42.0.11
IPs:
  IP:           10.42.0.11
Controlled By:  ReplicaSet/newpods
Containers:
  busybox:
    Container ID:  containerd://c4db65149cabc96fe937ec07e3b242ebb2d436710753b554ef78c21a5410b223
    Image:         busybox
    Image ID:      docker.io/library/busybox@sha256:a5d0ce49aa801d475da48f8cb163c354ab95cab073cd3c138bd458fc8257fbf1
    Port:          <none>
    Host Port:     <none>
    Command:
      sleep
      1000
    State:          Running
      Started:      Thu, 16 Jan 2025 04:43:46 +0000
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-6cm8c (ro)
Conditions:
  Type                        Status
  PodReadyToStartContainers   True 
  Initialized                 True 
  Ready                       True 
  ContainersReady             True 
  PodScheduled                True 
Volumes:
  kube-api-access-6cm8c:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age    From               Message
  ----    ------     ----   ----               -------
  Normal  Scheduled  9m36s  default-scheduler  Successfully assigned default/newpods-5z68b to controlplane
  Normal  Pulling    9m35s  kubelet            Pulling image "busybox"
  Normal  Pulled     9m35s  kubelet            Successfully pulled image "busybox" in 183ms (183ms including waiting). Image size: 2167089 bytes.
  Normal  Created    9m35s  kubelet            Created container busybox
  Normal  Started    9m34s  kubelet            Started container busybox
# 여기에는 describe 전문을 보는데에 익숙해지도록 전문을 넣었으나 더 좋은방식은 아래와같다
$ k describe po newpods-5z68b | grep Image:
  Image:         busybox

A) busybox

 

Q) Which nodes are these pods placed on?

$ k get po -o wide
NAME            READY   STATUS    RESTARTS   AGE   IP           NODE           NOMINATED NODE   READINESS GATES
newpods-5z68b   1/1     Running   0          13m   10.42.0.11   controlplane   <none>           <none>
newpods-chl7v   1/1     Running   0          13m   10.42.0.9    controlplane   <none>           <none>
newpods-dkl8n   1/1     Running   0          13m   10.42.0.10   controlplane   <none>           <none>
nginx           1/1     Running   0          10m   10.42.0.12   controlplane   <none>           <none>

A) controlplane

 

Q) Why do you think the container agentx in pod webapp is in error?

$ k describe po webapp
# ... 생략 ...
Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  95s                default-scheduler  Successfully assigned default/webapp to controlplane
  Normal   Pulling    95s                kubelet            Pulling image "nginx"
  Normal   Pulled     95s                kubelet            Successfully pulled image "nginx" in 160ms (160ms including waiting). Image size: 72080558 bytes.
  Normal   Created    95s                kubelet            Created container nginx
  Normal   Started    95s                kubelet            Started container nginx
  Warning  Failed     54s (x3 over 94s)  kubelet            Error: ErrImagePull
  Normal   BackOff    15s (x5 over 93s)  kubelet            Back-off pulling image "agentx"
  Warning  Failed     15s (x5 over 93s)  kubelet            Error: ImagePullBackOff
  Normal   Pulling    1s (x4 over 95s)   kubelet            Pulling image "agentx"
  Warning  Failed     1s (x4 over 94s)   kubelet            Failed to pull image "agentx": failed to pull and unpack image "docker.io/library/agentx:latest": failed to resolve reference "docker.io/library/agentx:latest": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

A) A Docker Image with this name doesn't exist

 

Q) Delete the webapp Pod.

$ k delete po webapp
pod "webapp" deleted

 

Q) Now change the image on this pod to redis.

$ k edit po redis
# 후에 yaml에서 image명 변경

 

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

Core Concepts - Imperative Commands  (0) 2025.01.18
Core Concepts - Services  (0) 2025.01.16
Core Concepts - Namespaces  (0) 2025.01.16
Core Concepts - Deployments  (0) 2025.01.16
Core Concepts - ReplicaSets  (0) 2025.01.16