root@bote798-ubuntu:~# kubectl cluster-info Kubernetes control plane is running at https://127.0.0.1:41165 CoreDNS is running at https://127.0.0.1:41165/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
root@bote798-ubuntu:~# kubectl get nodes NAME STATUS ROLES AGE VERSION my-first-control-plane Ready control-plane 31s v1.27.3
kubectl run my-nginx --image=nginx:alpine --port=80
查看 Pod
1 2 3 4 5 6 7
kubectl get pods # NAME READY STATUS RESTARTS AGE # my-nginx 1/1 Running 0 10s
kubectl get pods -o wide # 显示 IP 和所在节点 # NAME READY STATUS RESTARTS AGE IP NODE # my-nginx 1/1 Running 0 20s 10.244.0.5 my-first-control-plane
查看 Pod 详细信息
1
kubectl describe pod my-nginx
重点关注输出里的 Events 部分——Pod 从创建到运行的每一步都有记录。出了问题先看这里。
1 2 3 4 5 6 7 8
Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 30s default-scheduler Successfully assigned... Normal Pulling 29s kubelet Pulling image "nginx:alpine" Normal Pulled 25s kubelet Successfully pulled image Normal Created 25s kubelet Created container nginx Normal Started 25s kubelet Started container nginx