简体   繁体   English

如何访问在 Azure 中运行的托管 k8s 上的 ingress-nginx 命名空间中安装的 Prometheus 和 Grafana?

[英]How to access Prometheus and Grafana installed in the ingress-nginx namespace on managed k8s running in Azure?

I have followed the instructions at https://kubernetes.github.io/ingress-nginx/user-guide/monitoring/ to install the Prometheus and Grafana to monitor the performance of the ingress-nginx controller.我已按照https://kubernetes.github.io/ingress-nginx/user-guide/monitoring/上的说明安装 Prometheus 和 Grafana 以监控 ingress-nginx 控制器的性能。

However, the instructions to access the Prometheus dashboard did not work for me.但是,访问 Prometheus 仪表板的说明对我不起作用。

Indeed, according to the instructions we should be able to access the service through one of the IPs returned by the following command:实际上,根据说明,我们应该能够通过以下命令返回的 IP 之一访问服务:

kubectl get nodes --selector=kubernetes.io/role!=master -o jsonpath={.items[*].status.addresses[?\(@.type==\"InternalIP\"\)].address}

However, I do not understand how it is possible, since the IPs are internal to the cluster.但是,我不明白这怎么可能,因为 IP 是集群内部的。 Even in their documentation:即使在他们的文档中:

在此处输入图片说明

How can it possibly work if the IP addresses 10.192.0.2 10.192.0.3 10.192.0.4 are internal to the cluster?如果 IP 地址10.192.0.2 10.192.0.3 10.192.0.4在集群内部,它怎么可能工作?


Here is what I have:这是我所拥有的:

mark@D-LP0003:~$ kubectl get svc -n ingress-nginx
NAME                                 TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)                      AGE
grafana                              NodePort       10.0.6.223     <none>          3000:32275/TCP               23m
ingress-nginx-controller             LoadBalancer   10.0.254.117   40.76.145.210   80:32542/TCP,443:31960/TCP   51m
ingress-nginx-controller-admission   ClusterIP      10.0.110.16    <none>          443/TCP                      51m
prometheus-server                    NodePort       10.0.208.16    <none>          9090:32053/TCP               48m
mark@D-LP0003:~$

No external IP.没有外部IP。 OK, the documentation has it in mind already and suggests to run another command:好的,文档已经考虑到它并建议运行另一个命令:

mark@D-LP0003:~$ kubectl get nodes -o wide
NAME                                STATUS   ROLES   AGE   VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION      CONTAINER-RUNTIME
aks-nodepool1-30294001-vmss000000   Ready    agent   14h   v1.17.9   10.240.0.4    <none>        Ubuntu 16.04.7 LTS   4.15.0-1092-azure   docker://3.0.10+azure
aks-nodepool1-30294001-vmss000001   Ready    agent   14h   v1.17.9   10.240.0.5    <none>        Ubuntu 16.04.7 LTS   4.15.0-1092-azure   docker://3.0.10+azure
aks-nodepool1-30294001-vmss000003   Ready    agent   11h   v1.17.9   10.240.0.6    <none>        Ubuntu 16.04.7 LTS   4.15.0-1092-azure   docker://3.0.10+azure
mark@D-LP0003:~$

Still no external IP.仍然没有外部IP。 And at this point the documentation suggests to run yet another command:此时文档建议运行另一个命令:

mark@D-LP0003:~$ kubectl get nodes --selector=kubernetes.io/role!=master -o jsonpath={.items[*].status.addresses[?\(@.type==\"InternalIP\"\)].address}
10.240.0.4 10.240.0.5 10.240.0.6mark@D-LP0003:~$

I get back the same internal IPs.我取回了相同的内部 IP。

The only way I found to access the dashboard is through the client side port forwarding:我发现访问仪表板的唯一方法是通过客户端端口转发:

kubectl port-forward svc/prometheus-server 9090:9090 -n ingress-nginx  &

And then I can access the server at http://localhost:9090 .然后我可以通过http://localhost:9090访问服务器。

But I do not want it.但我不想要它。 The service is supposed to be externally accessible, so how do I access it?该服务应该可以从外部访问,那么我如何访问它?

You have few options你有几个选择

  1. Since you are in Azure you could create a LoadBalancer type service instead of NodePort type service to expose grafana and prometheus.由于您在 Azure 中,您可以创建LoadBalancer类型的服务而不是NodePort类型的服务来公开 grafana 和 prometheus。 You will get an external IP for the service which you can use to access it.您将获得可用于访问该服务的外部 IP。

  2. Use the Master nodes IP and NodePort to access it.使用主节点 IP 和 NodePort 访问它。 Assuming master nodes have external IP.假设主节点有外部 IP。 Use MASTERNODEIP:32053 for prometheus and MASTERNODEIP:32275 for grafana对 prometheus 使用MASTERNODEIP:32053MASTERNODEIP:32275使用MASTERNODEIP:32053 32275

  3. Use ingress resource to expose them.使用入口资源来公开它们。 You already have a external IP for the LoadBalancer of the nginx ingress controller.您已经有一个用于 nginx 入口控制器的 LoadBalancer 的外部 IP。 Use that IP to access it.使用该 IP 访问它。 Refer to this to know how to do it.请参阅此内容以了解如何操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM