代码之家  ›  专栏  ›  技术社区  ›  Jaskaranbir Singh

赫尔姆-通过Nginx ingres访问Grafana

  •  0
  • Jaskaranbir Singh  · 技术社区  · 8 年前

    我使用Helm部署Grafana,配置文件中包含以下内容(仅显示相关部分):

    ingress:
      enabled: true
      annotations:
        ingress.kubernetes.io/rewrite-target: /grafana
        kubernetes.io/ingress.class: nginx-internal
    

    然后我使用Helm部署了Nginx入口,配置如下:

    controller:
      config:
        ssl-redirect: "false"
      ingressClass: nginx-internal
    
      service:
        type: NodePort
        nodePorts:
          http: 30080
          https: 30443
    

    以下是入口的描述:

    Name:             mottled-magpie-grafana
    Namespace:        kube-system
    Address:
    Default backend:  default-http-backend:80 (<none>)
    Rules:
      Host                 Path  Backends
      ----                 ----  --------
      chart-example.local
                           /   mottled-magpie-grafana:80 (10.32.0.93:3000)
    Annotations:
      ingress.kubernetes.io/rewrite-target:  /grafana
      kubernetes.io/ingress.class:           nginx-internal
    Events:
      Type    Reason  Age   From                      Message
      ----    ------  ----  ----                      -------
      Normal  CREATE  1h    nginx-ingress-controller  Ingress kube-system/mottled-magpie-grafana
      Normal  CREATE  1h    nginx-ingress-controller  Ingress kube-system/mottled-magpie-grafana
      Normal  CREATE  1h    nginx-ingress-controller  Ingress kube-system/mottled-magpie-grafana
      Normal  UPDATE  1h    nginx-ingress-controller  Ingress kube-system/mottled-magpie-grafana
      Normal  CREATE  53m   nginx-ingress-controller  Ingress kube-system/mottled-magpie-grafana
    

    一切都安装得很好,但是当我尝试从我的主机访问Grafana时 curl <hostIp>:30080/grafana .

    但是,这是有效的:

    curl <hostIp>:30080 -H "HOST: chart-example.local"
    

    安装程序正在本地虚拟机上运行。如何从浏览器访问Grafana(无需手动添加 Host 标题)?

    1 回复  |  直到 8 年前
        1
  •  3
  •   Marcin Romaszewicz    8 年前

    您的入口只为一个主机-chart-example.local设置,它来自Helm chart的Values.yaml。如果您没有运行其他入口,请将chart-example.local in Values.yaml替换为“*”,这将匹配任何主机。如果您有其他入口,这可能会窃取它们的流量,因此将其设置为“localhost”或“127.0.0.1”,您将能够连接到这两个入口中的任何一个。

    我喜欢做的是创建一个假主机名,比如foo.local,并将其添加到/etc/host s中,这样它就是一个有效的主机名。

    推荐文章