이 콘텐츠는 선택한 언어로 제공되지 않습니다.

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

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

  1. Connect to the node in debug mode:

    $ oc debug node/<node>
    Copy to Clipboard Toggle word wrap
    $ chroot /host
    Copy to Clipboard Toggle word wrap

    Alternatively, it is possible to SSH to the node and become root.

  2. After access is established, check the default log level:

    $ systemctl cat kubelet
    Copy to Clipboard Toggle word wrap

    Example output

    # /etc/systemd/system/kubelet.service.d/20-logging.conf
    [Service]
    Environment="KUBELET_LOG_LEVEL=2"
    Copy to Clipboard Toggle word wrap

  3. Define the new verbosity required in a new /etc/systemd/system/kubelet.service.d/30-logging.conf file, which overrides /etc/systemd/system/kubelet.service.d/20-logging.conf. In this example, the verbosity is changed from 2 to 8:

    $ echo -e "[Service]\nEnvironment=\"KUBELET_LOG_LEVEL=8\"" > /etc/systemd/system/kubelet.service.d/30-logging.conf
    Copy to Clipboard Toggle word wrap
  4. Reload systemd and restart the service:

    $ systemctl daemon-reload
    Copy to Clipboard Toggle word wrap
    $ systemctl restart kubelet
    Copy to Clipboard Toggle word wrap
  5. Gather the logs, and then revert the log level increase:

    $ rm -f /etc/systemd/system/kubelet.service.d/30-logging.conf
    Copy to Clipboard Toggle word wrap
    $ systemctl daemon-reload
    Copy to Clipboard Toggle word wrap
    $ systemctl restart kubelet
    Copy to Clipboard Toggle word wrap

3.2. Persistent kubelet log level configuration

Procedure

  • Use the following MachineConfig object 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"
    Copy to Clipboard Toggle word wrap

    Generally, it is recommended to apply 0-4 as debug-level logs and 5-8 as trace-level logs.

3.3. Log verbosity descriptions

Expand
Log verbosityDescription

--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.

3.4. Gathering kubelet logs

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
    Copy to Clipboard Toggle word wrap
    $ oc adm node-logs --role worker -u kubelet
    Copy to Clipboard Toggle word wrap

    Alternatively, inside the node, run the following command:

    $ journalctl -b -f -u kubelet.service
    Copy to Clipboard Toggle word wrap
  • To collect master container logs, run the following command:

    $ sudo tail -f /var/log/containers/*
    Copy to Clipboard Toggle word wrap
  • 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
    Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat