安装期间的 Istio-ingressgateway 自定义

Istio-ingressgateway customization during installation

我需要在 Istio 安装期间将 Istio ingressgateway(网关对象)的 'hosts' 从默认值 '*' 更改为 'whatever'。我们正在使用 IstioOperator 为我们的安装进行定制。 我认为应该用 k8s overlays

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

路径属性的表达式应该是什么?

我在https://github.com/istio/istio/blob/master/operator/pkg/patch/patch.go上找到了一些信息,但情况并不完全相同。

因此,命名空间 istio-system 中的 istio-gateway Gateway 对象应该从

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

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

我们正在使用 Istio 1.5.6

谢谢!

更新一个工作示例

感谢 @Jakub 为我指明了正确的方向。

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

我将此作为社区 Wiki 答案发布,以提高知名度。


@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

还有@Peter Claes 提供的工作示例

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