kubectl 不输出日志

kubectl does not output the logs

我打印了我所有的 Pods:

$ 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

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

你能试试下面的命令吗(指定 pod 的命名空间)。

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