From 4d4f27b8b3bb1beea5f57e0742f29c0ba6e24362 Mon Sep 17 00:00:00 2001 From: Komh Date: Wed, 22 Apr 2026 15:05:11 +0800 Subject: [PATCH 1/2] [configure] Configure Kubelet Log Level Verbosity --- .../Configure_Kubelet_Log_Level_Verbosity.md | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 docs/en/solutions/Configure_Kubelet_Log_Level_Verbosity.md diff --git a/docs/en/solutions/Configure_Kubelet_Log_Level_Verbosity.md b/docs/en/solutions/Configure_Kubelet_Log_Level_Verbosity.md new file mode 100644 index 00000000..2b32ffef --- /dev/null +++ b/docs/en/solutions/Configure_Kubelet_Log_Level_Verbosity.md @@ -0,0 +1,111 @@ +--- +kind: + - Troubleshooting +products: + - Alauda Container Platform +ProductsVersion: + - 4.1.0,4.2.x +--- +## Issue + +When troubleshooting node-level problems, increasing the kubelet log verbosity helps identify the root cause. The default log level (`2`) may not provide enough detail for complex issues such as pod scheduling failures, volume mount errors, or container runtime communication problems. + +## Root Cause + +The kubelet supports configurable log verbosity levels ranging from `0` (least verbose) to `10` (most verbose). The default level is `2`, which provides basic operational information. Higher levels expose progressively more diagnostic data, but consume additional CPU, disk I/O, and memory on the node. + +## Resolution + +### Log Level Reference + +| Level Range | Purpose | +|---|---| +| 0 | Critical errors only | +| 1–2 | Default operational output | +| 3–4 | Debug-level information, suitable for most troubleshooting | +| 5–8 | Trace-level output, verbose internal state dumps | +| 9–10 | Maximum verbosity, rarely needed | + +### Persistent Configuration (Mutable Host OS) + +On mutable host OSes (standard Linux distributions with a writable `/etc`), set the kubelet log level persistently by adding or modifying the `--v` flag via a systemd drop-in file: + +```bash +sudo mkdir -p /etc/systemd/system/kubelet.service.d/ +sudo tee /etc/systemd/system/kubelet.service.d/10-log-level.conf < **Important:** Revert the log level back to the default (`2`) after collecting the necessary logs. Extended operation at high verbosity places significant load on node resources. + +## Diagnostic Steps + +Verify the current kubelet log level by inspecting the running process: + +```bash +ps aux | grep kubelet | grep -o '\-\-v=[0-9]*' +``` + +Gather kubelet logs from a specific node: + +```bash +kubectl get nodes +kubectl debug node/ --image=busybox -- cat /host/var/log/kubelet.log +``` + +Alternatively, SSH into the node and use journalctl: + +```bash +ssh +sudo journalctl -b -f -u kubelet.service +``` + +To collect logs from all nodes at once: + +```bash +for n in $(kubectl get nodes --no-headers | awk '{print $1}'); do + ssh "$n" "sudo journalctl -u kubelet.service --since '1 hour ago'" > "${n}.kubelet.log" +done +``` From 7efbdfbd406ebfc5becd5d7b30de98ae0850f1a1 Mon Sep 17 00:00:00 2001 From: Komh Date: Wed, 22 Apr 2026 19:01:35 +0800 Subject: [PATCH 2/2] [configure] Configure Kubelet Log Level Verbosity --- .../Configure_Kubelet_Log_Level_Verbosity.md | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/docs/en/solutions/Configure_Kubelet_Log_Level_Verbosity.md b/docs/en/solutions/Configure_Kubelet_Log_Level_Verbosity.md index 2b32ffef..68b627fb 100644 --- a/docs/en/solutions/Configure_Kubelet_Log_Level_Verbosity.md +++ b/docs/en/solutions/Configure_Kubelet_Log_Level_Verbosity.md @@ -26,22 +26,35 @@ The kubelet supports configurable log verbosity levels ranging from `0` (least v | 5–8 | Trace-level output, verbose internal state dumps | | 9–10 | Maximum verbosity, rarely needed | -### Persistent Configuration (Mutable Host OS) +### Persistent Configuration — KubeletConfiguration (preferred on kubeadm clusters) -On mutable host OSes (standard Linux distributions with a writable `/etc`), set the kubelet log level persistently by adding or modifying the `--v` flag via a systemd drop-in file: +On kubeadm-provisioned clusters the kubelet is configured through `/var/lib/kubelet/config.yaml`. Set the `verbosity` field there and restart kubelet: + +```bash +# On the target node +sudo sed -i 's/^\s*verbosity:.*/verbosity: 4/; t; $a\verbosity: 4' /var/lib/kubelet/config.yaml +sudo systemctl restart kubelet +``` + +This works regardless of how the systemd unit passes arguments to kubelet, and kubeadm-based automation will preserve it across upgrades. + +### Persistent Configuration — systemd drop-in (fallback) + +If you cannot edit `config.yaml` (some operator-managed setups lock the file), override the kubelet `ExecStart` via a drop-in that **inlines the `--v` flag directly**. Setting a bare environment variable like `KUBELET_LOG_LEVEL=4` does **not** raise verbosity — the stock kubeadm systemd unit only expands the three specific variables `$KUBELET_KUBECONFIG_ARGS`, `$KUBELET_CONFIG_ARGS`, and `$KUBELET_KUBEADM_ARGS`; any other name (including `KUBELET_LOG_LEVEL` or `KUBELET_EXTRA_ARGS`) is silently ignored. ```bash sudo mkdir -p /etc/systemd/system/kubelet.service.d/ -sudo tee /etc/systemd/system/kubelet.service.d/10-log-level.conf <