## Cluster Component Troubleshooting
Troubleshooting Kubernetes cluster components requires a systematic approach, often starting with identifying the affected component and then examining its logs, status, and configuration. The primary components include the Control Plane (kube-apiserver, etcd, kube-scheduler, kube-controller-manager) and Worker Node components (kubelet, kube-proxy, container runtime).
Control Plane Components
- `kube-apiserver`: This is the central hub. If it's down, `kubectl` commands will fail.
- Diagnosis: Check `systemctl status kube-apiserver`, `journalctl -u kube-apiserver`, and its static pod logs (e.g., `/etc/kubernetes/manifests/kube-apiserver.yaml` if deployed as a static pod). Look for network issues, certificate problems, or etcd connectivity errors.
- `etcd`: The cluster's backend store. If `etcd` is unhealthy or unreachable, the API server cannot function.
- Diagnosis: Use `etcdctl --endpoints=<etcd-ip>:2379 member list` and `etcdctl --endpoints=<etcd-ip>:2379 endpoint health`. Check `systemctl status etcd` and `journalctl -u etcd`. Ensure the data directory (`--data-dir`) is accessible and not full.
- `kube-scheduler`: Responsible for assigning pods to nodes. If down, new pods will remain in `Pending` state.
- Diagnosis: Check `systemctl status kube-scheduler` and `journalctl -u kube-scheduler`. Look for errors related to API server connectivity or resource constraints.
- `kube-controller-manager`: Runs various controllers (e.g., Node, Replication, Endpoint). If down, many cluster operations (like creating services, managing endpoints) will fail or be delayed.
- Diagnosis: Check `systemctl status kube-controller-manager` and `journalctl -u kube-controller-manager`. Similar to the scheduler, look for API server connectivity issues.
Worker Node Components
- `kubelet`: The agent that runs on each node, responsible for registering the node and managing pods.
- Diagnosis: Check `systemctl status kubelet` and `journalctl -u kubelet`. Look for errors related to container runtime connectivity, CNI issues, or incorrect `--register-node` configuration. A node might appear `NotReady` if `kubelet` is unhealthy.
- `kube-proxy`: Maintains network rules on nodes, enabling communication to pods and services.
- Diagnosis: Check `systemctl status kube-proxy` and `journalctl -u kube-proxy`. Verify `iptables -L -t nat` or `ipvsadm -L` rules. Issues often manifest as service connectivity problems.
- Container Runtime (e.g., `containerd`, `Docker`): Responsible for running containers.
- Diagnosis: Check `systemctl status containerd` (or `docker`) and `journalctl -u containerd`. Pods will fail to start or remain in `ContainerCreating` if the runtime is unhealthy. Use `crictl ps` (for `containerd`) or `docker ps` to verify running containers.
General Troubleshooting Steps
1. Check Logs: Always start with `journalctl -u <component>` or `kubectl logs -n kube-system <pod-name>`.
2. Check Events: `kubectl get events -A` can provide high-level insights into what's failing.
3. Resource Usage: Ensure components have sufficient CPU/memory.
4. Networking: Verify connectivity between components (e.g., API server to etcd, kubelet to API server). Use `netstat`, `ss`, `ping`, `curl`.
5. Certificates: Ensure all components have valid and correctly configured TLS certificates.
What is the primary indicator that the `kube-apiserver` might be down?
`kubectl` commands fail to connect to the cluster.
tap to reveal
How do you check the health of `etcd` members from the command line?
`etcdctl --endpoints=<etcd-ip>:2379 member list` and `etcdctl --endpoints=<etcd-ip>:2379 endpoint health`.
tap to reveal
What is the most common symptom if the `kube-scheduler` is not functioning correctly?
New pods remain in the `Pending` state indefinitely.
tap to reveal
Which command is typically used to check the status and logs of a systemd-managed Kubernetes component on a node?
`systemctl status <component>` and `journalctl -u <component>`.
tap to reveal
A node is showing `NotReady`. Which component is most likely having issues on that node?
The `kubelet` agent.
tap to reveal
What is the role of `kube-proxy` and what common tool does it use to implement its function?
`kube-proxy` maintains network rules for service communication, primarily using `iptables` (or `ipvs`).
tap to reveal
If pods are stuck in `ContainerCreating` state, which component should you investigate on the node?
The container runtime (e.g., `containerd` or `Docker`).
tap to reveal
How can you view cluster-wide events that might indicate component failures or issues?
`kubectl get events -A`.
tap to reveal