- Created by Sansae, last modified on Mar 06, 2024
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 51 Next »
목차
Pod 개요
- 쿠버네티스에서 생성하고 관리할 수 있는 배포 가능한 가장 작은 컴퓨팅 단위

Pod Lifecycle
https://kimjingo.tistory.com/137

- Pending: Pod 생성 요청을 받았지만 하나 이상의 container가 실행준비를 마치지 못한 상태이다. 컨테이너 이미지를 다운로드하는 시간도 이 phase에 포함된다.
- Running: Node가 배정되었고, 모든 컨테이너가 생성된 상태이다. 최소한 하나 이상의 컨테이너가 실행 중이거나 시작 또는 재시작 중이다.
- Succeeded: Pod의 모든 컨테이너가 성공적으로 종료되었으며, 재시작할 필요가 없다.
- Failed: 모든 컨테이너가 종료되었으나, 하나 이상의 컨테이너가 0이 아닌 값을 반환하였거나 시스템에 의해 강제로 종료되어 실패로 끝난 경우이다.
- Unknown: k8s가 Pod의 상태 정보를 읽어오지 못하는 상태이며, 일반적으로 kubelet과 API 서버간의 통신에 문제가 있는 경우가 많다.
#참고로 node가 다운되거나 네트워크 연결이 원활하지 않은 경우, 해당 node의 모든 Pod은 Failed phase로 전이(transition)된다.
Pod Manifest (Desired State)
https://dev-k8sref-io.web.app/docs/workloads/pod-v1/
apiVersion: v1 #쿠버네티스 API버전을 가리킴
kind: Pod #리소스 유형
metadata (ObjectMeta): 포드와 관련된 이름, 네임스페이스, 라벨, 그밖의 정보
- namespace
- name
- labels
spec (PodSpec): #컨테이너, 볼륨등의 정보
- containers
- volumes
- status(PodStatus) : #포드의 상태, 각 컨테이너의 설명 및 상태, 포드 내부의 IP 및 그밖의 기본 정보 등 (k8s가 정의함)
curl -X POST http://<kube-apiserver-ip>:<port>/api/v1/namespaces/default/pods 'JSON'
apiVersion: v1
kind: Pod
metadata:
name: nginx
lables:
app: myapp
type: front-end
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
https://hub.docker.com/layers/library/nginx/1.14.2/images/sha256-295c7be079025306c4f1d65997fcf7adb411c88f139ad1d34b537164aa060369?context=explore

kubectl run nginx --image=nginx:1.14.2 --dry-run=client # 명령어 검토 kubectl run nginx --image=nginx:1.14.2 --dry-run=client -o yaml # 명령에 대해 yaml로 보기 kubectl run nginx --image=nginx:1.14.2 --dry-run=client -o yaml > nginx-pod.yaml # yaml을 파일로 저장하기
Pod 실습
Pod 생성
sansae@sansaeAir15m2 ~ % k apply -f nginx-pod.yaml pod/nginx created
Pod 확인
sansae@sansaeAir15m2 ~ % k get pod NAME READY STATUS RESTARTS AGE nginx 1/1 Running 0 86m
Pod 상세 정보 확인
sansae@sansaeAir15m2 ~ % k describe pod nginx
Name: nginx
Namespace: default
Priority: 0
Service Account: default
Node: aks-agentpool-33019784-vmss000000/10.224.0.4
Start Time: Fri, 08 Mar 2024 14:38:30 +0900
Labels: app=myapp, type=front-end
Annotations: cni.projectcalico.org/containerID: caca6fff7130ca9b8ddc20811d6a24b2f5c4ef9acd135521e955343bb4d0c39b
cni.projectcalico.org/podIP: 10.244.0.19/32
cni.projectcalico.org/podIPs: 10.244.0.19/32
Status: Running
IP: 10.244.0.19
IPs:
IP: 10.244.0.19
Containers:
nginx:
Container ID: containerd://999b11a1c2f614dff1cd1e7a00ca9960dc09ff148faaabace98ffa038b1582f0
Image: nginx:1.14.2
Image ID: docker.io/library/nginx@sha256:f7988fb6c02e0ce69257d9bd9cf37ae20a60f1df7563c3a2a6abe24160306b8d
Port: <none>
Host Port: <none>
State: Running
Started: Fri, 08 Mar 2024 14:38:36 +0900
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-cpjv5 (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-cpjv5:
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: <none>
sansae@sansaeAir15m2 ~ %
Pod 삭제
sansae@sansaeAir15m2 ~ % k delete -f nginx-pod.yaml pod "nginx" deleted --- sansae@sansaeAir15m2 ~ % k delete pod nginx pod "nginx" deleted
- No labels