Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of basic troubleshooting of K8s

Shulou Source: shulou.com Published: 2022-06-01 18:43:37 10月04日 Update

This article mainly introduces "the basic troubleshooting method of K8s". In the daily operation, I believe that many people have doubts about the basic troubleshooting method of K8s. The editor consulted all kinds of materials and sorted out the simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about the basic troubleshooting method of K8s! Next, please follow the editor to study!

K8s basic troubleshooting

Kubectl is the most important tool in the process of troubleshooting and is usually the starting point for locating errors. Some commonly used commands are also listed here, which are often used in subsequent troubleshooting processes.

Troubleshooting Overview View Pod status and run node kubectl get pods-o widekubectl-n kube-system get pods-o wide View Pod event kubectl describe pod View Node status kubectl get nodeskubectl describe node kube-apiserver log PODNAME=$ (kubectl-n kube-system get pod-l component=kube-apiserver-o jsonpath=' {.items [0] .metadata.name}') kubectl-n kube-system logs $PODNAME-tail 10 operations assume that the control plane runs as Kubernetes static Pod. If kube-apiserver is managed with systemd, you need to log in to the master node and use journalctl-u kube-apiserver to view its logs. Kube-controller-manager log PODNAME=$ (kubectl-n kube-system get pod-l component=kube-controller-manager-o jsonpath=' {.items [0] .metadata.name}') kubectl-n kube-system logs $PODNAME-- the above command operation assumes that the control plane runs as Kubernetes static Pod. If kube-controller-manager is managed with systemd, you need to log in to the master node and use journalctl-u kube-controller-manager to view its logs. Kube-scheduler log PODNAME=$ (kubectl-n kube-system get pod-l component=kube-scheduler-o jsonpath=' {.items [0] .metadata.name}') kubectl-n kube-system logs $PODNAME-- the above command operation assumes that the control plane runs as Kubernetes static Pod. If kube-scheduler is managed with systemd, you need to log in to the master node and use journalctl-u kube-scheduler to view its logs. Kube-dns log

Kube-dns is usually deployed as Addon, and each Pod contains three containers. The most important thing is the log of the kubedns container:

PODNAME=$ (kubectl-n kube-system get pod-l k8s-app=kube-dns-o jsonpath=' {.items [0] .metadata.name}') kubectl-n kube-system logs $PODNAME-c kubednsKubelet log

Kubelet is usually managed by systemd. To view the Kubelet log, you need to log in to Node by SSH first. It is recommended to use kubectl-node-shell instead of assigning a public network IP address to each node. For example:

[root@localhost ~] # cat KubectlMutham NodeShield nsenter-$ [- z "$1"]; then echo "Please specify node name" exit 1fiNODE = "$1" IMAGE= "alpine" POD= "nsenter-$ (env LC_CTYPE=C tr-dc a-z0-9)

< /dev/urandom | head -c 6)"NAMESPACE=""# Check the nodekubectl get node "$NODE" >

/ dev/null | | exit 1 overrides = "$(cat)

Tags: Log method node command learning login management run plane form static control container tool way more state process help practical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei vpn Linux NVidia macOS