首页 > 解决方案 > kubectl 不输出日志

问题描述

我用以下方式打印我所有的 Pod:

$ kubectl get pods --all-namespaces

输出是:

NAMESPACE             NAME                                                  READY   STATUS    RESTARTS   AGE  
calico-system         calico-kube-controllers-7487d7f956-hx4fp              1/1     Running   0          88m  
calico-system         calico-node-vn52p                                     1/1     Running   0          88m  
calico-system         calico-typha-7588984c44-m6tsz                         1/1     Running   0          88m  
gitlab-managed-apps   install-ingress                                       0/1     Error     0          14m********  
gitlab-managed-apps   install-prometheus                                    0/1     Error     0          12m  
kube-system           coredns-f9fd979d6-2n2pg                               1/1     Running   0          91m  
kube-system           coredns-f9fd979d6-sq9bl                               1/1     Running   0          91m  
kube-system           etcd-tuoputuo-iamnotstone-server                      1/1     Running   0          91m  
kube-system           kube-apiserver-tuoputuo-iamnotstone-server            1/1     Running   0          91m  
kube-system           kube-controller-manager-tuoputuo-iamnotstone-server   1/1     Running   0          91m  
kube-system           kube-proxy-87jkr                                      1/1     Running   0          91m  
kube-system           kube-scheduler-tuoputuo-iamnotstone-server            1/1     Running   0          91m  
tigera-operator       tigera-operator-58f56c4958-4x9tp                      1/1     Running   0          89m  

但是当我执行日志命令时:

$ kubectl logs -f install-ingress

我看到这个错误

Error from server (NotFound): pods "install-ingress" not found

标签: kuberneteskubectl

解决方案


install-ingresspod 在命名gitlab-managed-apps空间中。如果您没有在kubectl命令中指定命名空间,那么它将在不存在该 pod 的默认命名空间中搜索该 pod。install-ingress

您能否尝试以下命令(指定 pod 的命名空间)。

kubectl logs -f install-ingress -n gitlab-managed-apps

推荐阅读