반응형
Pod 란?
- 컨테이너를 표현하는 k8s API의 최소 단위
- Pod에는 하나 또는 여러개의 컨테이너가 포함될 수 있음
Pod yaml을 이용하여 생성 (nginx-pod.yaml)
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
containers:
- name: nginx-container
image: nginx:1.14
ports:
- containerPort: 80
protocol: TCP
Pod 실행
# kubectl create -f nginx-pod.yaml
pod/nginx-pod created
현재 동작중인 Pod 확인
# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-pod 1/1 Running 0 30m
# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-pod 1/1 Running 0 31m 10.36.0.1 node1.example.com <none> <none>
Pod 상세 정보 확인
# kubectl describe pod nginx-pod
Name: nginx-pod
Namespace: default
Priority: 0
Service Account: default
Node: node1.example.com/10.100.0.101
Start Time: Thu, 24 Nov 2022 21:10:38 +0900
Labels: <none>
Annotations: <none>
Status: Running
IP: 10.36.0.1
IPs:
IP: 10.36.0.1
Containers:
nginx-container:
Container ID: containerd://3a195ee94f7e6ee83f7d7db56259777151038f0ede08f1ba444dbaff5adeb8f0
Image: nginx:1.14
Image ID: docker.io/library/nginx@sha256:f7988fb6c02e0ce69257d9bd9cf37ae20a60f1df7563c3a2a6abe24160306b8d
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Thu, 24 Nov 2022 21:10:52 +0900
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-4v5v5 (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-4v5v5:
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 33m default-scheduler Successfully assigned default/nginx-pod to node1.example.com
Normal Pulling 33m kubelet Pulling image "nginx:1.14"
Normal Pulled 32m kubelet Successfully pulled image "nginx:1.14" in 11.567076187s
Normal Created 32m kubelet Created container nginx-container
Normal Started 32m kubelet Started container nginx-container
Pod 로그 확인
# kubectl logs nginx-pod
10.32.0.1 - - [24/Nov/2022:12:34:39 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.68.0" "-"
10.32.0.1 - - [24/Nov/2022:12:34:40 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.68.0" "-"
Pod 컨테이너 접속
Single Pod
# kubectl exec nginx-pod -it -- /bin/bash
Multi Pod
# kubectl exec nginx-pod -c nginx-container -it -- /bin/bash
※ multi-container pod에서 container들의 pod명과 ip는 동일
[참고]
- https://www.youtube.com/watch?v=0rYt3PcggzA
반응형
'Kubernetes' 카테고리의 다른 글
[Kubernetes] Pod - init container & infra container (0) | 2022.11.29 |
---|---|
[Kubernetes] Pod - livenessProbe (0) | 2022.11.27 |
[Kubernetes] kubeadm init 실행시 unknown service runtime.v1alpha2.RuntimeService 발생 (0) | 2022.11.23 |
[Kubernetes] API version (0) | 2022.09.30 |
[Kubernetes] yaml 템플릿이란? (0) | 2022.09.30 |