Grafana 和 Istio 的自定义负载均衡器

Custom LoadBalancer For Grafana & Istio

我已经从 Istio 文档中将 Grafana 作为附加组件加载,我将其放在主站点的子域后面。

但我需要为它构建一个自定义负载均衡器,以便子域可以指向它。

这是我的:

apiVersion: v1
kind: Service
metadata:
  name: grafana-ingressgateway
  namespace: istio-system
spec:
  type: LoadBalancer
  ports:
    - port: 80
      targetPort: 80
      name: http2
    - port: 443
      name: https
  selector:
    app.kubernetes.io/name: grafana-lb
    app.kubernetes.io/instance: grafana-lb
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: ingress-grafana-gateway-configuration
  namespace: istio-system
spec:
  selector:
    istio: grafana-ingressgateway
  servers:
  - port:
      number: 80
      name: grafana-http-ui
      protocol: HTTP
    hosts:
    - "grafana.xxxx.com"
    tls:
      httpsRedirect: false
  - port:
      number: 443
      name: grafana-https-ui
      protocol: HTTPS
    tls:
      mode: SIMPLE
      credentialName: xxxx-cert
    hosts:
    - "grafana.xxxx.com"
---
kind: VirtualService
apiVersion: networking.istio.io/v1alpha3
metadata:
  name: grafana-virtual-service
  namespace: istio-system
spec:
  hosts:
    - "grafana.xxxx.com"
  gateways:
    - ingress-grafana-gateway-configuration
  http:
    - match:
      - uri:
          prefix: /
      route:
        - destination:
            host: grafana.istio-system.svc.cluster.local

但它没有加载,我已经更新了 'grafana' 子域以指向新的负载平衡器。该证书是一个通配符,允许在 istio-system 命名空间中进行加密。

这是因为我添加到与默认负载均衡器相同的命名空间吗?我没有看到任何说你不能 运行 在一个 NS 中超过一个 LB 的东西吗?

谢谢,

据我所知,它不起作用,因为创建服务不足以在 Istio 中创建自定义负载均衡器。


如果要创建自定义网关,请参考以下内容. You need to create it with either Helm or Istio Operator

然后你可以使用选择器来指示你的网关使用新的自定义入口网关,而不是默认的,选择器是istio: ingressgateway


关于你的网关配置,如果你想使用下面的选择器

spec:
  selector:
    istio: grafana-ingressgateway

那么你应该在你的自定义 grafana 入口网关上创建这个标签。

gateways:
  enabled: true
  custom-grafana-ingressgateway:
    namespace: default
    enabled: true
    labels:
      istio: grafana-ingressgateway