kubectl pod 的增删改查
kubectl run 命令格式
Usage:
kubectl run NAME --image=image [–env=“key=value”] [–port=port]
[–dry-run=server|client] [–overrides=inline-json] [–command] – [COMMAND]
[args…] [options]
新增一个pod;
[root@centos7_1 ~]# kubectl run myweb --image=nginx
pod/myweb created
查看pod信息;
[root@centos7_1 ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
myweb 1/1 Running 0 20s
#显示pod的详细信息,包含ip,image,状况等
[root@centos7_1 ~]# kubectl describe pod myweb
Name: myweb
Namespace: default
Priority: 0
Node: 192.168.137.101/192.168.137.101
Start Time: Mon, 23 May 2022 14:28:46 +0800
Labels: run=myweb
Annotations:
Status: Running
IP: 172.20.1.5
IPs:
IP: 172.20.1.5
Containers:
myweb:
Container ID: docker://15bf0f694fcfa36c6073155affa26e262ebf310580b29239fb06213fca20a44e
Image: nginx
Image ID: docker-pullable://nginx@sha256:2d17cc4981bf1e22a87ef3b3dd20fbb72c3868738e3f307662eb40e2630d4320
Port:
Host Port:
State: Running
Started: Mon, 23 May 2022 14:29:05 +0800
Ready: True
Restart Count: 0
Environment:
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-fchhw (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-fchhw:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional:
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors:
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 71s default-scheduler Successfully assigned default/myweb to 192.168.137.101
Normal Pulling 69s kubelet Pulling image “nginx”
Normal Pulled 53s kubelet Successfully pulled image “nginx” in 16.633764145s
Normal Created 53s kubelet Created container myweb
Normal Started 52s kubelet Started container myweb
查看pod运行在那个node上;
[root@centos7_1 ~]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
myweb 1/1 Running 0 33s 172.20.1.5 192.168.137.101
删除pod;
[root@centos7_1 ~]# kubectl delete pod myweb
pod “myweb” deleted



