2

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
Peter Claes
  • 285
  • 3
  • 9
  • 1
    Have you tried with `- path: spec.servers[0]`? There is similiar [question](https://stackoverflow.com/questions/61331425/istio-complicated-k8sobjectoverlay-pathvalue/61339117#61339117) about that, take a look. Let me know if that worked for you. – Jakub Sep 25 '20 at 09:17
  • Happy to help, I have posted community wiki answer for better visibility. If this answer or any other one solved your issue, please mark it as accepted or upvote it. – Jakub Sep 25 '20 at 11:32

1 Answers1

2

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
Jakub
  • 8,189
  • 1
  • 17
  • 31