首页 > 解决方案 > 安装期间的 Istio-ingressgateway 自定义

问题描述

在 Istio 安装期间,我需要将 Istio ingressgateway(网关对象)的“主机”从默认值“*”更改为“whatever”。我们正在使用 IstioOperator 对我们的安装进行自定义。我认为应该用k8s覆盖来完成

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

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

我在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

标签: istio

解决方案


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


@Jens Wurm 提供的答案和代码示例对此有类似的问题。

这是覆盖的一部分,它将添加另一个带有一些示例规范的服务器条目。只需将其调整为您想要的方式即可。您还可以使用 spec.servers[0] 的路径覆盖您的第一个服务器条目,然后将值设置为您想要的任何值。

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

推荐阅读