kubernetes - 如何配置 Istio 虚拟服务目标协议(protocol)

标签 kubernetes istio

如何配置 Istio VirtualService 以将流量路由到监听 HTTPS 的目标后端?

配置 protocol: HTTPSscheme: HTTPS 无效。

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: api-rpi-access
spec:
  hosts:
  - "test.example.com"
  gateways:
  - api-gateway
  http:
  - match:
    - uri:
        port: https
        prefix: /
    route:
    - destination:
        host: some-https-service
        port:
          number: 8443
          protocol: HTTPS
        # scheme: HTTPS

这是我的网关:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: api-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: SIMPLE
      serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
      privateKey: /etc/istio/ingressgateway-certs/tls.key
    hosts:
    - "test.example.com"

最佳答案

为了在 istio ingressgateway 上执行 LTS 终止并将 https 流量发送到后端,我必须添加以下 DestinationRule

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: some-https-service
spec:
  host: diary
  trafficPolicy:
    tls:
      mode: SIMPLE

这是网关和虚拟服务:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: api-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: SIMPLE
      serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
      privateKey: /etc/istio/ingressgateway-certs/tls.key
    hosts:
    - "test.example.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: ext-access
spec:
  hosts:
  - "test.example.com"
  gateways:
  - api-gateway
  http:
  - match:
    - uri:
        port: https
        prefix: /
    route:
    - destination:
        host: some-https-service
        port:
          number: 8443

关于kubernetes - 如何配置 Istio 虚拟服务目标协议(protocol),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61920458/

相关文章:

Kubernetes - 如何仅运行一次作业

macos - 如何从本地 Kubernetes 连接到本地机器上的数据库

go - 创建/获取自定义 kubernetes 资源

istio - 如何在 'when' 条件下将 kube-secret 映射为 istio 键 : request. header 的值?

kubernetes - 如何使用 helm 提供程序覆盖 terraform 中的默认图表值?

kubernetes - 使用服务发现将具有相同 ID 的作业分派(dispatch)到同一个工作节点

apache-spark - 如何将 Spark 应用程序 jar 文件部署到 Kubernetes 集群?

istio - Istio 的通信 Sidecar Controle Plane

redis - 使用istio时Redis-cluster Helm图表无法完成工作

docker - 将 Docker 镜像从 Gitlab 的私有(private) Docker 注册表部署到 Openshift