Editing kubelet log level verbosity and gathering logs¶
To troubleshoot some issues with nodes, establish the kubelet’s log level verbosity depending on the issue to be tracked.
Modifying the kubelet as a one-time scenario¶
To modify the kubelet in a one-time scenario without rebooting the node due to the change of machine-config(spec":{"paused":false}}), allowing you to modify the kubelet without affecting the service, follow this procedure.
Procedure
-
Connect to the node in debug mode:
Alternatively, it is possible to SSH to the node and become root.
-
After access is established, check the default log level:
-
Define the new verbosity required in a new
/etc/systemd/system/kubelet.service.d/30-logging.conffile, which overrides/etc/systemd/system/kubelet.service.d/20-logging.conf. In this example, the verbosity is changed from2to8: -
Reload systemd and restart the service:
-
Gather the logs, and then revert the log level increase:
Persistent kubelet log level configuration¶
Procedure
-
Use the following
MachineConfigobject for persistent kubelet log level configuration:apiVersion: machineconfiguration.openshift.io/v1 kind: MachineConfig metadata: labels: machineconfiguration.openshift.io/role: master name: 99-master-kubelet-loglevel spec: config: ignition: version: 3.2.0 systemd: units: - name: kubelet.service enabled: true dropins: - name: 30-logging.conf contents: | [Service] Environment="KUBELET_LOG_LEVEL=2"Generally, it is recommended to apply
0-4as debug-level logs and5-8as trace-level logs.
Log verbosity descriptions¶
| Log verbosity | Description |
|---|---|
--v=0 |
Always visible to an Operator. |
--v=1 |
A reasonable default log level if you do not want verbosity. |
--v=2 |
Useful steady state information about the service and important log messages that might correlate to significant changes in the system. This is the recommended default log level. |
--v=3 |
Extended information about changes. |
--v=4 |
Debug level verbosity. |
--v=6 |
Display requested resources. |
--v=7 |
Display HTTP request headers. |
--v=8 |
Display HTTP request contents. |
Gathering kubelet logs¶
Procedure
-
After the kubelet’s log level verbosity is configured properly, you can gather logs by running the following commands:
Alternatively, inside the node, run the following command:
-
To collect master container logs, run the following command:
-
To directly gather the logs of all nodes, run the following command: