• Kubernetes日志路径


    Kubernetes日志路径配置

    Kubernetes各组件默认不将日志输出到文件,可能是不好控制吧,默认只输出到控制台

    kubelet

    具体配置如下,kuberlet.service.d/10-kubeadm.conf

    <root@HK-K8S-WN4 /usr/lib/systemd/system/kubelet.service.d># cat 10-kubeadm.conf 
    # Note: This dropin only works with kubeadm and kubelet v1.11+
    [Service]
    Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
    Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
    # This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
    EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
    # This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
    # the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
    EnvironmentFile=-/etc/sysconfig/kubelet
    ExecStart=
    ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS

    一共四个环境变量,真是吃饱撑得没事做,可能是为了功能更明确一点吧

    具体日志修改的变量在/etc/sysconfig/kubelet文件中,如下 (--v=5 是日志级别的定义等级包含了debug模式,有助于在排错的,正常运行可以关闭)

    二个参数:--logtostderr默认是true代表输出到控制台上,--log-dir默认是空,代表输出到控制台上,亲测如果需要输出到文件中,目录必须是/var/log/kubernetes,如果有朋友测试其它的目录可以,告诉一下

    <root@HK-K8S-WN4 /usr/lib/systemd/system/kubelet.service.d># cat /etc/sysconfig/kubelet 
    KUBELET_EXTRA_ARGS=--logtostderr=false --log-dir=/var/log/kubernetes --v=5

     systemctl daemon-reload && systemctl start kubelet.service

    切换至具体的日志目录 /var/log/kubernetes,查看如下

    <root@HK-K8S-WN4 /var/log/kubernetes># ls -lrth
    total 23M
    -rw-r--r-- 1 root root  926 Aug 16 12:01 kubelet.HK-K8S-WN4.root.log.ERROR.20210816-120124.15011
    -rw-r--r-- 1 root root 1.6K Aug 16 12:01 kubelet.HK-K8S-WN4.root.log.WARNING.20210816-120117.15011
    -rw-r--r-- 1 root root  18K Aug 16 12:30 kubelet.HK-K8S-WN4.root.log.INFO.20210816-120117.15011
    lrwxrwxrwx 1 root root   54 Aug 16 12:30 kubelet.INFO -> kubelet.HK-K8S-WN4.root.log.INFO.20210816-123000.23141
    lrwxrwxrwx 1 root root   57 Aug 16 12:30 kubelet.WARNING -> kubelet.HK-K8S-WN4.root.log.WARNING.20210816-123001.23141
    lrwxrwxrwx 1 root root   55 Aug 16 12:30 kubelet.ERROR -> kubelet.HK-K8S-WN4.root.log.ERROR.20210816-123007.23141
    -rw-r--r-- 1 root root  926 Aug 16 12:30 kubelet.HK-K8S-WN4.root.log.ERROR.20210816-123007.23141
    -rw-r--r-- 1 root root 1.6K Aug 16 12:30 kubelet.HK-K8S-WN4.root.log.WARNING.20210816-123001.23141
    -rw-r--r-- 1 root root  23M Aug 16 14:24 kubelet.HK-K8S-WN4.root.log.INFO.20210816-123000.23141

     

     

  • 相关阅读:
    iOS中3种正则表达式的使用
    iOS 正则表达式
    Autolayout-VFL语言添加约束-备
    PHP一个最简单的CMS内容管理系统
    国外主流PHP框架比较
    PHP中的ob_start() 的使用
    jpGraph的应用及基本安装配置 BY 命运
    未能加载文件或程序集“Common”或它的某一个依赖项。试图加载格式不正确的程序
    Android手机 Fildder真机抓包
    axWindowsMediaPlayer1获取音频长度
  • 原文地址:https://www.cnblogs.com/apink/p/15147682.html
Copyright © 2020-2023  润新知