简体   繁体   English

在 AKS 中通过 Ingress 访问 Prometheus 和 Grafana

[英]Access Prometheus and Grafana via Ingress in AKS

I have an AKS Cluster deployed and I have deployed Prometheus and Grafana in monitoring namespace.我部署了一个 AKS 集群,并且在监视命名空间中部署了 Prometheus 和 Grafana。 I have also created a Ingress rule to access both the application in default namespace.我还创建了一个入口规则来访问默认命名空间中的两个应用程序。 To access both the services I have created services in default namespace as External name.为了访问这两个服务,我在默认命名空间中将服务创建为外部名称。

kind: Service
apiVersion: v1
metadata:
  name: prometheus-server-alb
  namespace: monitoring
spec:
  selector:
    app: prometheus
  ports:
    - protocol: TCP
      port: 9090
      targetPort: 9090
---
apiVersion: v1
kind: Service
metadata:
  name: grafana
  namespace: monitoring
  annotations:
      prometheus.io/scrape: 'true'
      prometheus.io/port:   '3000'
spec:
  selector: 
    app: grafana  
  ports:
    - port: 3000
      targetPort: 3000
---
kind: Service
apiVersion: v1
metadata:
  name: grafana-ext
  namespace: default
spec:
  type: ExternalName
  externalName: grafana.monitoring.svc.cluster.local
  ports:
  - port: 3000
    targetPort: 3000
---
kind: Service
apiVersion: v1
metadata:
  name: prometheus-ext
  namespace: default
spec:
  type: ExternalName
  externalName: prometheus-server-alb.monitoring.svc.cluster.local
  ports:
  - port: 9090
    targetPort: 9090
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: sitecore-ingress
  annotations:
    kubernetes.io/ingress.class: azure/application-gateway
    appgw.ingress.kubernetes.io/ssl-redirect: "true"
spec:
  rules:
  - host: grafana.test.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: grafana-ext
            port: 
              number: 3000
  - host: prometheus.test.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: prometheus-ext
            port: 
              number: 9090
  tls:
  - secretName: monitoring-tls
    hosts:
    - prometheus.test.com
    - grafana.test.com

I am able to access the services locally inside default namespace and also provided all the required thing link certificate, etc. Still I am not able to access it.我能够在默认命名空间内本地访问服务,还提供了所有必需的事物链接证书等。但我仍然无法访问它。 It is giving me "502-bad gateway error".它给我“502 错误网关错误”。

Can anyone help me?谁能帮我? Thank you in advance.先感谢您。

• I would suggest you to please add the below annotation in your AKS deployment yaml file to prevent using private IP for the application gateway: - • 我建议您在 AKS部署 yaml文件中添加以下注释,以防止将私有 IP用于应用程序网关:-

 kubernetes.io/ingress.class: azure/application-gateway
 appgw.ingress.kubernetes.io/use-private-ip: "false"

The above annotation along with the one that you have used to allow the SSL redirection for the application gateway while accessing the Graffana and Prometheus monitoring namespace while accessing the AKS cluster through the application gateway itself will surely help you get past the 'Bad gateway' error.上面的注释以及您在访问GraffanaPrometheus监视命名空间时使用的允许应用程序网关SSL 重定向的注释,同时通过应用程序网关本身访问 AKS 集群肯定会帮助您克服“Bad gateway”错误.

• Also, other than the above, I will request you to please check whether readiness or liveness probe is defined for the monitoring namespaces or not. • 此外,除上述之外,我会要求您检查是否为监视命名空间定义了就绪或活动探测 As per what I can get to know, it is not enabled, thus I would request you to please enable them and then check the status.据我所知,它没有启用,因此我请求您启用它们,然后检查状态。 I would also suggest you to please check the default health probe configured whether it is able to reach the monitoring namespaces or not.我还建议您检查配置的默认运行状况探测是否能够到达监视命名空间。 The error that you are facing regarding the bad gateway might also be due to the health probe not able to reach the backend resources.您面临的有关错误网关的错误也可能是由于运行状况探测无法到达后端资源造成的。 As when you provision an application gateway, the health probe is automatically by default configured through the 'HTTPGet' method.当您提供应用程序网关时,默认情况下会通过“HTTPGet”方法自动配置运行状况探测。

For more details regarding the above, I would request you to please refer to the following documentation links: -有关上述内容的更多详细信息,请参阅以下文档链接:-

https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-troubleshooting-502 https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-troubleshooting-502

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

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