Custom LoadBalancer For Grafana & Istio

3/29/2021

I have loaded Grafana as an add-on from the Istio docs, i put it behind a sub domain for the main site.

But i need to build a custom load balancer for it, so that the sub domain can point to that.

This is what i have:

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

But it's not loading, i have already updated the 'grafana' sub domain to point to the new load balancer. The cert is a wild card lets encrypt that is in the <code>istio-system</code> namespace.

Is this because I added to the same namespace as the default load balancer? I have not seen anything that says you cant run more than one LB in one NS?

Thanks,

-- C0ol_Cod3r
istio
kubernetes
load-balancing

1 Answer

3/30/2021

From what I see it's not working because creation of a service is not enough to create a custom load balancer in Istio.


If you want to create a custom gateway, then please refer to the following answer. You need to create it with either Helm or Istio Operator.

Then you can use the selector to instruct your gateway to use the new custom ingress gateway, instead of the default one, which selector is istio: ingressgateway.


As for your gateway configuration, if you want to use the following selector

spec:
  selector:
    istio: grafana-ingressgateway

Then you should create this label on your custom grafana ingress gateway.

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