실습 :: pod 실행
[root@master ~/kube/06/pod]# kubectl run web1 --image=nginx --port=80
pod/web1 created
[root@master ~/kube/06/pod]# kubectl get pod
NAME READY STATUS RESTARTS AGE
web1 1/1 Running 0 2m27s
webserver1 1/1 Running 0 54m
[root@master ~/kube/06/pod]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
web1 1/1 Running 0 2m33s 10.233.102.136 node1 <none> <none>
webserver1 1/1 Running 0 54m 10.233.75.5 node2 <none> <none>
[root@master ~/kube/06/pod]# kubectl describe pod web1
Name: web1
Namespace: default
Priority: 0
Service Account: default
Node: node1/192.168.2.61
Start Time: Sat, 08 Mar 2025 15:40:24 +0900
Labels: run=web1
Annotations: cni.projectcalico.org/containerID: ad062e925f190e04964eb54da031dc9e0c2ac2baafac29fc2500e17ede1f87cb
cni.projectcalico.org/podIP: 10.233.102.136/32
cni.projectcalico.org/podIPs: 10.233.102.136/32
Status: Running
IP: 10.233.102.136
IPs:
IP: 10.233.102.136
Containers:
web1:
Container ID: docker://a6e8fac9f6977896bee910dd5064ca9526839979330db0f6e9f45160b466dfe5
Image: nginx
Image ID: docker-pullable://nginx@sha256:9d6b58feebd2dbd3c56ab5853333d627cc6e281011cfd6050fa4bcf2072c9496
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Sat, 08 Mar 2025 15:40:27 +0900
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-57zmg (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-57zmg:
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 2m50s default-scheduler Successfully assigned default/web1 to node1
Normal Pulling 2m49s kubelet Pulling image "nginx"
Normal Pulled 2m47s kubelet Successfully pulled image "nginx" in 2.2855594s (2.28556483s including waiting)
Normal Created 2m47s kubelet Created container web1
Normal Started 2m47s kubelet Started container web1
실습 :: yaml 파일 작성하여 pod 생성 및 구동/삭제
[root@master ~/kube/06/pod]# vi web2.yaml
[root@master ~/kube/06/pod]# cat web2.yaml
apiVersion: v1
kind: Pod
metadata:
name: web2
spec:
containers:
- name: nginx-container
image: nginx
ports:
- containerPort: 80
protocol: TCP
[root@master ~/kube/06/pod]# kubectl apply -f web2.yaml
pod/web2 created
[root@master ~/kube/06/pod]# kubectl get pod
NAME READY STATUS RESTARTS AGE
web1 1/1 Running 0 30m
web2 1/1 Running 0 4s
webserver1 1/1 Running 0 82m
[root@master ~/kube/06/pod]# kubectl delete pod --all
pod "web1" deleted
pod "web2" deleted
pod "webserver1" deleted