首页 > 解决方案 > 无法通过 Kubernetes 的 AWS ELB 访问 Grafana(用于 prometheus)

问题描述

我们有一个由几个节点组成的集群,所以我不能做一个 NodePort,而只是去我的 node-ip(这是我为测试普罗米修斯所做的)。我在“监控”命名空间中做了一个 helm install stable/prometheus 和 stable/grafana。

到目前为止一切看起来都还不错。

然后,我尝试创建一个访问 Grafana 的 LB 服务,该服务已创建,我可以看到 CNAME 指向 AWS 上 ELB 的 A 记录,但是在访问 Grafana 的 URL 时,什么也没发生,没有 HTTP 错误,没有问题的页面,什么都没有。

这是service-elb.yaml

apiVersion: v1
kind: Service
metadata:
  name: grafana-lb
  namespace: monitoring
  labels:
    app: grafana
  annotations:
    dns.alpha.kubernetes.io/external: grafana-testing.country.ourdomain 
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:xxxxxx
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
    service.beta.kubernetes.io/aws-load-balancer-ssl-ports: '443'
    service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: '3600'
spec:
  selector:
    app: grafana
    tier: frontend
  type: LoadBalancer
  ports:
    - name: https
      port: 443
      targetPort: 80
    - name: http
      port: 80
      targetPort: 3000
  loadBalancerSourceRanges:
    - somerange
    - someotherrange
    - etc etc 

顺便说一句,如果我不使用 --set rbac.create=false 创建图表,则会出现有关服务帐户的权限错误

我最近为 Kibana 使用了 nginx-proxy-pass,并且还使用了类似的 LB 服务,没有问题。但是我在这里遗漏了一些东西,现在还找不到它是什么。

任何帮助都感激不尽。如果我让它工作,我会更新。

标签: amazon-web-serviceskubernetesgrafanaprometheus

解决方案


解决了,必须删除“层”选择器,只使用这样的规范:

    spec:
  selector:
    app: grafana
  type: LoadBalancer
  ports:
    - name: http
      port: 3000

推荐阅读