Where are the Kubernetes kubelet logs located?

前端 未结 5 1791
抹茶落季
抹茶落季 2020-12-08 09:31

I installed Kubernetes on my Ubuntu machine. For some debugging purposes I need to look at the kubelet log file (if there is any such file).

I have looked in

相关标签:
5条回答
  • 2020-12-08 09:51

    Finally I could find it in /var/log/upstart directory. Kubernetes in my machine is started using upstart. That's why those log files are in upstart directory

    0 讨论(0)
  • 2020-12-08 09:52

    I installed Kubernetes by kind (Kubernetes in docker).

    1. find docker container of kind to enter
    $ docker container ps
    CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS                 PORTS                                                          NAMES
    62588e4d284b        kindest/node:v1.17.0          "/usr/local/bin/entr…"   2 weeks ago         Up 2 weeks             127.0.0.1:32769->6443/tcp                                      kind2-control-plane
    
    $ docker container exec -it kind2-control-plane bash
    root@kind2-control-plane:/# 
    
    1. Inside container kind2-control-plane, you could find logfiles in two place:

      • /var/log/containers/
      • /var/log/pods/

    And then,you will find they are the same, you can see the example below:

    root@kind2-control-plane:/# cat /var/log/containers/redis-master-7db7f6579f-scw95_default_master-f6374281c2c6afcfcd0ee1214d9bd51c1684c0b6c0ba1056295246ecd055563c.log | tail -n 5
    2020-04-08T12:09:29.824252114Z stdout F 
    2020-04-08T12:09:29.824372278Z stdout F [1] 08 Apr 12:09:29.822 # Server started, Redis version 2.8.19
    2020-04-08T12:09:29.824440661Z stdout F [1] 08 Apr 12:09:29.823 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
    2020-04-08T12:09:29.824459317Z stdout F [1] 08 Apr 12:09:29.823 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
    2020-04-08T12:09:29.82446451Z stdout F [1] 08 Apr 12:09:29.824 * The server is now ready to accept connections on port 6379
    
    root@kind2-control-plane:/# cat /var/log/pods/default_redis-master-7db7f6579f-scw95_094824e1-25aa-4e1e-ab23-d4bae861988a/master/0.log  | tail -n 5
    2020-04-08T12:09:29.824252114Z stdout F 
    2020-04-08T12:09:29.824372278Z stdout F [1] 08 Apr 12:09:29.822 # Server started, Redis version 2.8.19
    2020-04-08T12:09:29.824440661Z stdout F [1] 08 Apr 12:09:29.823 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
    2020-04-08T12:09:29.824459317Z stdout F [1] 08 Apr 12:09:29.823 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
    2020-04-08T12:09:29.82446451Z stdout F [1] 08 Apr 12:09:29.824 * The server is now ready to accept connections on port 6379
    
    root@kind2-control-plane:/# ls -l /var/log/containers/ | grep redis
    lrwxrwxrwx 1 root root 101 Apr  8 12:09 redis-master-7db7f6579f-scw95_default_master-f6374281c2c6afcfcd0ee1214d9bd51c1684c0b6c0ba1056295246ecd055563c.log -> /var/log/pods/default_redis-master-7db7f6579f-scw95_094824e1-25aa-4e1e-ab23-d4bae861988a/master/0.log
    

    If you want to know more in detail about the directories, you can see 2019-2-merge-request in Github.

    0 讨论(0)
  • 2020-12-08 09:59

    If you run kubelet using systemd, then you could use the following method to see kubelet's logs:

    # journalctl -u kubelet
    
    0 讨论(0)
  • 2020-12-08 10:02

    If you are trying to go directly to the file you can find the kubelet logs in /var/log/syslog directory. This is for ubuntu 16.04 and above.

    0 讨论(0)
  • 2020-12-08 10:12

    It depends how it was installed. I installed Kubernetes on some Ubuntu machines following the Docker-MultiNode instructions.

    With this install, I find the logs using the logs command like this.

    1. Find your container ID.

      $ docker ps | egrep kubelet
      
    2. Use that container ID to view the logs

      $ docker logs `<container-id>`
      
    0 讨论(0)
提交回复
热议问题