Kubernetes kubelet原木在哪里?

Kubernetes kubelet原木在哪里?,kubernetes,Kubernetes,我在我的Ubuntu机器上安装了Kubernetes。出于某些调试目的,我需要查看kubelet日志文件(如果有这样的文件) 我在/var/logs中查找过,但找不到这样的文件。可能在哪里?这取决于它是如何安装的。我在Docker MultiNode之后的一些Ubuntu机器上安装了Kubernetes 在这个安装中,我使用logs命令查找日志,如下所示 找到您的容器ID $ docker ps | egrep kubelet 使用该容器ID查看日志 $ docker logs `<c

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


我在
/var/logs
中查找过,但找不到这样的文件。可能在哪里?

这取决于它是如何安装的。我在Docker MultiNode之后的一些Ubuntu机器上安装了Kubernetes

在这个安装中,我使用logs命令查找日志,如下所示

  • 找到您的容器ID

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

    $ docker logs `<container-id>`
    
    $docker日志``
    

  • 最后,我可以在/var/log/upstart目录中找到它。我的机器中的Kubernetes是使用upstart启动的。这就是为什么这些日志文件位于upstart目录中的原因

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

    # journalctl -u kubelet
    

    如果您试图直接转到该文件,您可以在/var/log/syslog目录中找到kubelet日志。这是针对ubuntu 16.04及以上版本的。

    我是通过安装Kubernetes的

  • 查找要输入的docker容器
  • 在容器
    kind2控制平面内,您可以在两个位置找到日志文件:

    • /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中查看。

    我通过在群集目录中运行kube-up.sh脚本安装了Kubernetes,并且我有一个作为主节点和次节点运行的节点Kubernet通常是主机中的一个进程,不是pod。亚马逊EKS就是这种情况——由于这条评论,刚刚找到了kubelet日志。微软的AKS也是如此。GKE也适用,但您可能需要为您的VM用户设置密码,并将其添加到
    systemd journal
    组。使用
    sudo passwd
    设置密码,并使用
    sudo gpasswd-a systemd journal
    将自己添加到组中,然后注销和登录,上述命令应该可以工作。
    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