[英]Accessing nginx-ingress-controller error log
I have set up one Kubernetes master node and 2 workers node.我已经设置了一个 Kubernetes 主节点和 2 个工作节点。 I deployed two web applications as a pod using kubectl
.我使用kubectl
将两个 Web 应用程序部署为一个 pod。 I deployed nginx-ingress-controller
( image: gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.6
) and created a service for the same with nodeport option.我部署了nginx-ingress-controller
(图片:gcr.io/google_containers/nginx-ingress-controller:0.9.0- gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.6
)并使用 nodeport 选项创建了一个服务。 How do I access the error logs of the nginx-ingress-controller
?如何访问nginx-ingress-controller
的错误日志? I'm able to see error.log
under /var/log/nginx/
, but it is link to /dev/stderr
.我可以在/var/log/nginx/
下看到error.log
,但它链接到/dev/stderr
。
TL;DR TL;博士
kubectl logs -n <<ingress_namespace>> <<ingress_pod_name>>
Check the namespace under which the Ingress controller is currently running.检查 Ingress 控制器当前运行的命名空间。
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
helloworld-deployment-7dc448d6b-5zvr8 1/1 Running 1 3d20h
helloworld-deployment-7dc448d6b-82dnt 1/1 Running 1 3d20h
$ kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
kube-apiserver-minikube 1/1 Running 1 3d20h
nginx-ingress-controller-586cdc477c-rhj9z 1/1 Running 1 3d21h
For me, it happens to be the kube-system
namespace on the pod nginx-ingress-controller-586cdc477c-rhj9z
.对我来说,它恰好是 pod nginx-ingress-controller-586cdc477c-rhj9z
上的kube-system
命名空间。
Now, get the logs just like you would for any pod using现在,像使用任何 pod 一样获取日志
kubectl logs -n kube-system nginx-ingress-controller-586cdc477c-rhj9z
In most cases, you will see that containerized applications spit out their logs to stdout/stderr, which means they are available as container logs.在大多数情况下,您会看到容器化应用程序将其日志吐出到 stdout/stderr,这意味着它们可以作为容器日志使用。 In Kubernetes you can access these logs by means of ie.在 Kubernetes 中,您可以通过 ie 访问这些日志。 kubectl logs <pod>
Update: a very nice tool for logs cli browsing - https://github.com/wercker/stern更新:一个非常好的日志 cli 浏览工具 - https://github.com/wercker/stern
I prefer: kubectl logs -lapp=nginx-ingress
我更喜欢: kubectl logs -lapp=nginx-ingress
(get the logs of all pods with the label nginx-ingress ) (获取标签为nginx-ingress的所有 pod 的日志)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.