1. Identify the pod that has an initContainer configured.
controlplane ~ ➜ k describe pod
...
ame: blue
Namespace: default
Priority: 0
Service Account: default
Node: controlplane/192.30.130.9
Start Time: Fri, 05 Jul 2024 14:53:30 +0000
Labels: <none>
Annotations: <none>
Status: Running
IP: 10.42.0.11
IPs:
IP: 10.42.0.11
Init Containers:
init-myservice:
Container ID: containerd://8155e6099f2f4690e5e011ba987fe1b42d8afbc78288c3a97c6ab2ea00ac3d7b
Image: busybox
Image ID: docker.io/library/busybox@sha256:9ae97d36d26566ff84e8893c64a6dc4fe8ca6d1144bf5b87b2b85a32def253c7
Port: <none>
Host Port: <none>
Command:
sh
-c
sleep 5
State: Terminated
Reason: Completed
Exit Code: 0
Started: Fri, 05 Jul 2024 14:53:31 +0000
Finished: Fri, 05 Jul 2024 14:53:36 +0000
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-slrmx (ro)
Host Port: <none>
Command:
sh
-c
answer : blue
2. What is the image used by the initContainer on the blue pod?
answer : busybox
3. What is the state of the initContainer on pod blue?
answer : Terminated
4. Why is the initContainer terminated? What is the reason?
answer : the process completed succesfully
---GPT 답변
Kubernetes에서 InitContainer가 Terminated 상태에 있다는 것은 초기화 컨테이너가 성공적으로 완료되었거나 실패했다는 것을 의미합니다. InitContainer는 메인 애플리케이션 컨테이너가 시작되기 전에 실행되어 필요한 초기화 작업을 수행하는 특별한 컨테이너입니다.
InitContainer의 상태 설명
• Terminated 상태: InitContainer가 종료되었음을 나타냅니다. 이 상태에는 두 가지 하위 상태가 있습니다:
• 성공적으로 종료된 경우: InitContainer가 할당된 작업을 성공적으로 완료하고 종료되었습니다. 이 경우, terminated 상태의 exitCode가 0입니다.
• 실패한 경우: InitContainer가 오류로 인해 실패하고 종료되었습니다. 이 경우, terminated 상태의 exitCode는 0이 아닌 값입니다.
5. We just created a new app named purple. How many initContainers does it have?
controlplane ~ ➜ k describe po purple
Name: purple
Namespace: default
Priority: 0
Service Account: default
Node: controlplane/192.30.130.9
Start Time: Fri, 05 Jul 2024 14:59:01 +0000
Labels: <none>
Annotations: <none>
Status: Pending
IP: 10.42.0.12
IPs:
IP: 10.42.0.12
Init Containers:
warm-up-1:
Container ID: containerd://4f02270c2c9e415daf638543b4733072ebe5b2582973299c4721bc295e8ebe52
Image: busybox:1.28
Image ID: docker.io/library/busybox@sha256:141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df416dea4f41046e0f37d47
Port: <none>
Host Port: <none>
Command:
sh
-c
sleep 600
State: Running
Started: Fri, 05 Jul 2024 14:59:02 +0000
Ready: False
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-fq9zh (ro)
warm-up-2:
Container ID:
Image: busybox:1.28
Image ID:
Port: <none>
Host Port: <none>
Command:
sh
-c
sleep 1200
State: Waiting
Reason: PodInitializing
Ready: False
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-fq9zh (ro)
Containers:
answer : 2
6. What is the state of the POD?
answer : Pendding
7. How long after the creation of the POD will the application come up and be available to users?
answe : 30 min (1800 sec)
8. Update the pod red to use an initContainer that uses the busybox image and sleeps for 20 seconds
Delete and re-create the pod if necessary. But make sure no other configurations change.
controlplane ~ ➜ k edit pod red
...
spec:
initContainers: ## 추가
- image: busybox
name: red-initcontainer
command:
- "sleep"
- "20"
containers:
- command:
- sh
9. A new application orange is deployed. There is something wrong with it. Identify and fix the issue.
Once fixed, wait for the application to run before checking solution.
...
dnsPolicy: ClusterFirst
enableServiceLinks: true
initContainers:
- command:
- sh
- -c
- sleeeep 2; # 오타수정
image: busybox
imagePullPolicy: Always
name: init-myservice
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run
'IT 기술 > k8s' 카테고리의 다른 글
[cka] Cluster Upgrade Process (0) | 2024.07.11 |
---|---|
[cka] OS Upgrades (0) | 2024.07.10 |
[cka] Multi Container PODs (0) | 2024.07.05 |
[cka] Secrets (0) | 2024.07.05 |
[cka] Env Variables (0) | 2024.07.05 |
댓글