Istio-ingressgateway customization during installation

Viewed 157

I need to change the 'hosts' of the Istio ingressgateway (Gateway object) from default value '*' to 'whatever' during Istio installation. We are using the IstioOperator to make customizations for our installation. I think it should be done with k8s overlays

...
   k8s:
         overlays:
            - kind: Gateway
              name: istio-ingressgateway
              patches:
                - path: spec.servers.??????
                  value: whatever
...

What should be the expression for the path attribute ?

I found some info on https://github.com/istio/istio/blob/master/operator/pkg/patch/patch.go, but the case is not exactly the same.

So, the istio-gateway Gateway object in namespace istio-system should change from

spec:
  servers:
    - hosts:
        - '*'
      port:
        name: http
        number: 80
        protocol: HTTP

to

spec:
  servers:
    - hosts:
        - whatever
      port:
        name: http
        number: 80
        protocol: HTTP

We are using Istio 1.5.6

Thx !

UPDATE with a working example

Thx to @Jakub for pointing me to the right direction.

          overlays:
            - kind: Gateway
              name: istio-ingressgateway
              patches:
                - path: spec.servers[0]
                  value: 
                    hosts:
                      - whatever.dummy
                    port:
                      name: http
                      number: 80
                      protocol: HTTP
1 Answers

I am posting this as a community wiki answer for better visibility.


There is similiar question about that with answer and code example provided by @Jens Wurm.

This is a part of an overlay that will add another server entry with some example specs. Just tweak it to be the way you want it to be. You can also override your first server entry with a path of spec.servers[0] and then set the value to whatever you want it to be.

ingressGateways: 
  - enabled: true
    k8s:
      overlays:
      - apiVersion: networking.istio.io/v1alpha3
        kind: Gateway
        name: ingressgateway
        patches:
        - path: spec.servers[1]
          value:
            hosts:
              - '*.example.com'
            port:
              name: https
              number: 443
              protocol: HTTPS
            tls:
              credentialName: example-cert
              mode: SIMPLE
              privateKey: sds
              serverCertificate: sds

And there is working example provided by @Peter Claes

  overlays:
    - kind: Gateway
      name: istio-ingressgateway
      patches:
        - path: spec.servers[0]
          value: 
            hosts:
              - whatever.dummy
            port:
              name: http
              number: 80
              protocol: HTTP
Related