Kubernetes kubelet原木在哪里?

时间:2015-12-06 02:55:33

标签: kubernetes

我在我的Ubuntu机器上安装了Kubernetes。出于某些调试目的,我需要查看kubelet日志文件(如果有任何此类文件)。

我查看了first second,但我找不到这样的文件。那可能在哪里?

5 个答案:

答案 0 :(得分:54)

如果您使用systemd运行kubelet,则可以使用以下方法查看kubelet的日志:

# journalctl -u kubelet

答案 1 :(得分:4)

如果尝试直接转到文件,则可以在/ var / log / syslog目录中找到kubelet日志。这适用于Ubuntu 16.04及更高版本。

答案 2 :(得分:3)

最后我可以在/ var / log / upstart目录中找到它。我的机器中的Kubernetes开始使用upstart。这就是为什么这些日志文件在upstart目录

答案 3 :(得分:2)

这取决于它的安装方式。我按照http://kubernetes.io/v1.1/docs/getting-started-guides/docker-multinode.html上的Docker-MultiNode说明在一些Ubuntu机器上安装了Kubernetes。

通过此安装,我可以使用logs命令找到日志。

  1. 找到您的容器ID。

    $ docker ps | egrep kubelet
    
  2. 使用该容器ID查看日志

    $ docker logs `<container-id>`
    

答案 4 :(得分:1)

我通过kind (Kubernetes in docker)安装了Kubernetes。

  1. 找到kind的docker容器以输入
$ 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. 在容器kind2-control-plane中,您可以在两个地方找到日志文件:

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

然后,您会发现它们是相同的,您可以看到以下示例:

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

如果您想详细了解目录,可以在Github中查看2019-2-merge-request