如何为 istio 入口网关添加自定义端口?

leo*_*leo 4 kubernetes kubernetes-helm istio kubernetes-ingress

我是 istio 的新手。我有一个简单的入口网关 yaml 文件,监听端口是 26931,但是在我应用了 yaml 之后,端口 26931 没有出现在入口网关公开的端口集中。那么我是否缺少一些必要的步骤或其他什么?

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: batman-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 26931
      name: http
      protocol: HTTP
    hosts:
    - "*"
Run Code Online (Sandbox Code Playgroud)

A_S*_*Suh 9

您不是使用 Gateway 对象公开端口,而是使用 istio-ingressgateway 服务公开端口。

kubectl edit svc istio-ingressgateway -n istio-system
Run Code Online (Sandbox Code Playgroud)

所以如果你想暴露26931端口,你应该用网关服务来做

  ports:
  - name: http
    nodePort: 30001
    port: 26931
    protocol: TCP
    targetPort: 80
Run Code Online (Sandbox Code Playgroud)

还评论了您之前的帖子-如何在 istio 中配置入口网关?


pep*_*red 7

从 Istio 1.5.1 开始,使用istioctl以下命令安装(请参阅官方文档):

istioctl manifest apply -f your-overlay-config.yaml
Run Code Online (Sandbox Code Playgroud)

components.ingressGateways可以在文件部分下指定其他端口your-overlay-config.yaml。例如:

apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
  namespace: istio-system
spec:
  components:
    citadel:
      enabled: true
    sidecarInjector:
      enabled: true
    telemetry:
      enabled: true
    ingressGateways:
      - name: istio-ingressgateway
        enabled: true
        k8s:
          service:
            ports:
              # We have to specify original ports otherwise it will be erased
              - port: 15020
                targetPort: 15020
                name: status-port
              - port: 80
                targetPort: 80
                name: http2
              - port: 443
                name: https
              - port: 15029
                targetPort: 15029
                name: kiali
              - port: 15030
                targetPort: 15030
                name: prometheus
              - port: 15031
                targetPort: 15031
                name: grafana
              - port: 15032
                targetPort: 15032
                name: tracing
              - port: 15443
                targetPort: 15443
                name: tls
              - port: 31400
                name: tcp
              # Your additional ports
              - port: 10000
                name: misc
  addonComponents:
    prometheus:
      enabled: false
  values:
    sidecarInjectorWebhook:
      enableNamespacesByDefault: true
    global:
      proxy:
        accessLogFile: "/dev/stdout"
    gateways:
      istio-egressgateway:
        enabled: false
      istio-ingressgateway:
        sds:
          enabled: true
Run Code Online (Sandbox Code Playgroud)

值得注意的是,对于 Istio 1.5 和 Istio 1.4 端口必须在values.gateways.istio-ingressgateway部分下指定。


Ryo*_*ota 5

端口设置在网关Helm 子图中完成。您可以在 Istio 中声明性地定义附加端口,而不是直接编辑服务,values.yaml如下所示。

注意:从 Istio v1.2 和 v1.3.0 开始,原始子图中定义的默认端口列表将覆盖。为了保持默认值不变,下面的代码片段有一些硬拷贝的值。

gateways:
  istio-ingressgateway:
    ports:
      # Default port list copied from the original subchart values
      # Ref: https://github.com/istio/istio/blob/release-1.2/install/kubernetes/helm/istio/charts/gateways/values.yaml
      #      (the ports below override the default and do not get merged, and thus need to be copied here)
      - port: 15020
        targetPort: 15020
        name: status-port
      - port: 80
        targetPort: 80
        name: http2
        nodePort: 31380
      - port: 443
        name: https
        nodePort: 31390
      - port: 15029
        targetPort: 15029
        name: https-kiali
      - port: 15030
        targetPort: 15030
        name: https-prometheus
      - port: 15031
        targetPort: 15031
        name: https-grafana
      - port: 15032
        targetPort: 15032
        name: https-tracing
        # This is the port where sni routing happens
      - port: 15443
        targetPort: 15443
        name: tls
      ##=== Additional Ports =======================##
      - port: 8080
        targetPort: 8080
        name: http-custom
      - port: 8081
        targetPort: 8081
        name: http-custom-backup
      ##____________________________________________##
Run Code Online (Sandbox Code Playgroud)