Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 3. 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.
3.1. Modifying the kubelet as a one-time scenario Link kopierenLink in die Zwischenablage kopiert!
To modify the kubelet in a one-time scenario without rebooting the node due to the change of
machine-config(spec":{"paused":false}})
Procedure
Connect to the node in debug mode:
$ oc debug node/<node>$ chroot /hostAlternatively, it is possible to SSH to the node and become root.
After access is established, check the default log level:
$ systemctl cat kubeletExample output
# /etc/systemd/system/kubelet.service.d/20-logging.conf [Service] Environment="KUBELET_LOG_LEVEL=2"Define the new verbosity required in a new
file, which overrides/etc/systemd/system/kubelet.service.d/30-logging.conf. In this example, the verbosity is changed from/etc/systemd/system/kubelet.service.d/20-logging.confto2:8$ echo -e "[Service]\nEnvironment=\"KUBELET_LOG_LEVEL=8\"" > /etc/systemd/system/kubelet.service.d/30-logging.confReload systemd and restart the service:
$ systemctl daemon-reload$ systemctl restart kubeletGather the logs, and then revert the log level increase:
$ rm -f /etc/systemd/system/kubelet.service.d/30-logging.conf$ systemctl daemon-reload$ systemctl restart kubelet
3.2. Persistent kubelet log level configuration Link kopierenLink in die Zwischenablage kopiert!
Procedure
Use the following
object for persistent kubelet log level configuration:MachineConfigapiVersion: 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
as debug-level logs and0-4as trace-level logs.5-8
3.3. Log verbosity descriptions Link kopierenLink in die Zwischenablage kopiert!
| Log verbosity | Description |
|---|---|
|
| Always visible to an Operator. |
|
| A reasonable default log level if you do not want verbosity. |
|
| 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. |
|
| Extended information about changes. |
|
| Debug level verbosity. |
|
| Display requested resources. |
|
| Display HTTP request headers. |
|
| Display HTTP request contents. |
3.4. Gathering kubelet logs Link kopierenLink in die Zwischenablage kopiert!
Procedure
After the kubelet’s log level verbosity is configured properly, you can gather logs by running the following commands:
$ oc adm node-logs --role master -u kubelet$ oc adm node-logs --role worker -u kubeletAlternatively, inside the node, run the following command:
$ journalctl -b -f -u kubelet.serviceTo collect master container logs, run the following command:
$ sudo tail -f /var/log/containers/*To directly gather the logs of all nodes, run the following command:
- for n in $(oc get node --no-headers | awk '{print $1}'); do oc adm node-logs $n | gzip > $n.log.gz; done