我有 1 個主節點和 2 個節點正在運行,并且有 kube-proxy 進行除錯。
kube-m1:/$ kubectl get pod -n kube-system kube-proxy-tmt58
NAME READY STATUS RESTARTS AGE
kube-proxy-tmt58 1/1 Running 6 439d
如何指定命名空間kubectl logs以除錯 Pod?
kube-m1:/$ kubectl logs kube-proxy-tmt58
Error from server (NotFound): pods "kube-proxy-tmt58" not found
我是 kubernetes 的新手,因此,如果能獲得一些關于 pod 和節點除錯的良好且有效的指南或材料,也將非常有用且非常有幫助 :)
非常感謝。
uj5u.com熱心網友回復:
就像你這樣做是為了獲得一個 pod,指定一個你可以傳遞的命名空間-n| --namespace標志,所以你的命令看起來像
kubectl logs kube-proxy-tmt58 -n kube-system
uj5u.com熱心網友回復:
除了@jabbson 的回答,我只想提及并推薦您保存到書簽kubectl Cheat Sheet 中。這個頁面有大量的 kubectl 使用示例。它將對您深入了解 kubernetes 世界有很大幫助。
# Get commands with basic output
kubectl get services # List all services in the namespace
kubectl get pods --all-namespaces # List all pods in all namespaces
kubectl get pods -o wide # List all pods in the current namespace, with more details
kubectl get deployment my-dep # List a particular deployment
kubectl get pods # List all pods in the namespace
kubectl get pod my-pod -o yaml # Get a pod's YAML
# Describe commands with verbose output
kubectl describe nodes my-node
kubectl describe pods my-pod
# Get all worker nodes (use a selector to exclude results that have a label
# named 'node-role.kubernetes.io/master')
kubectl get node --selector='!node-role.kubernetes.io/master'
# Get all running pods in the namespace
kubectl get pods --field-selector=status.phase=Running
# Get ExternalIPs of all nodes
kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="ExternalIP")].address}'
# Logs
kubectl logs my-pod # dump pod logs (stdout)
kubectl logs -l name=myLabel # dump pod logs, with label name=myLabel (stdout)
kubectl logs my-pod --previous # dump pod logs (stdout) for a previous instantiation of a container
kubectl logs my-pod -c my-container # dump pod container logs (stdout, multi-container case)
kubectl logs -l name=myLabel -c my-container # dump pod logs, with label name=myLabel (stdout)
kubectl logs my-pod -c my-container --previous # dump pod container logs (stdout, multi-container case) for a previous instantiation of a container
kubectl logs -f my-pod # stream pod logs (stdout)
kubectl logs -f my-pod -c my-container # stream pod container logs (stdout, multi-container case)
kubectl logs -f -l name=myLabel --all-containers # stream all pods logs with label name=myLabel (stdout)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/370059.html
標籤:Kubernetes 节点 kube代理
