• Kubernetes Logs 如何获取kube-system pod的日志


    你如何从kube-system pod获取日志?运行kubectl log pod_name不起作用:

    [root@k8s-master ~]# kubectl logs etcd-k8s-master 
    Error from server (NotFound): pods "etcd-k8s-master" not found

    查看集群中的所有命名空间:

    [root@k8s-master ~]# kubectl get pods --all-namespaces
    NAMESPACE     NAME                                 READY   STATUS    RESTARTS   AGE
    default       nginx-demo-v1-94kqx                  1/1     Running   0          23m
    default       nginx-demo-v1-t88mj                  1/1     Running   0          23m
    kube-system   coredns-9d85f5447-jb8l2              1/1     Running   0          6d7h
    kube-system   coredns-9d85f5447-zx2j5              1/1     Running   0          6d7h
    kube-system   etcd-k8s-master                      1/1     Running   0          6d7h
    kube-system   kube-apiserver-k8s-master            1/1     Running   0          6d7h
    kube-system   kube-controller-manager-k8s-master   1/1     Running   1          6d7h
    kube-system   kube-flannel-ds-amd64-2plp7          1/1     Running   0          6d4h
    kube-system   kube-flannel-ds-amd64-cnlbh          1/1     Running   0          6d4h
    kube-system   kube-flannel-ds-amd64-zr88r          1/1     Running   0          6d4h
    kube-system   kube-proxy-44fpd                     1/1     Running   0          6d6h
    kube-system   kube-proxy-5lrvp                     1/1     Running   0          6d7h
    kube-system   kube-proxy-c64px                     1/1     Running   0          6d6h
    kube-system   kube-scheduler-k8s-master            1/1     Running   1          6d7h

    出处:https://www.cnblogs.com/liucx/

    指定命名空间可以查看kube-system的pod日志

    kubectl –namespace kube-system logs kube-apiserver-k8s-master

    eg:
    kubectl -n kube-system  logs -f  etcd-k8s-master   #-f:动态实时查看日志
    kubectl logs -f etcd-k8s-master  -n kube-system 
    kubectl -n kube-system  logs -f  --tail 10 etcd-k8s-master #--tail:指定条数

    kubectl log <pod-name> -c <container_name> # 若 pod 只有一个容器,可以不加 -c
  • 相关阅读:
    owncloud7.0.2.1升级8.0.3
    iptables删除规则
    ESXi Install OpenWRT
    Eclipse连接VirtualBox中的Android x86
    win7、linux安装使用pip、mitmproxy
    linux php bom
    ios项目上传svn丢失*.a文件
    升级owncloud到7.0.2
    phpinfo有mysqlnd没有mysql
    Cacti监控Centos抓包unreachable
  • 原文地址:https://www.cnblogs.com/liucx/p/12699980.html
Copyright © 2020-2023  润新知