istio的http访问https外部服务配置

文章介绍了如何在Istio环境中配置服务,使得外部通过HTTP访问内部实际上是HTTPS的服务。这涉及到ServiceEntry、DestinationRule、Gateway和VirtualService的配置,包括设置TLS模式为SIMPLE以允许HTTP流量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一般情况是应用提供http服务,通过网关使用https方式访问,这个配置在istio官网上可以看到例子,但有些时候,我们却要反过来,要访问的应用本身是https的,但我们要通过网关提供http访问,这种方式可能有些违反常理,但如果给istio开发http filter时,就得使用这种场景了,在istio中,tls方式不支持http filter。

  1. 配置ServiceEntry

apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: httpk8s-com
spec:
  hosts:
  - httpk8s.com
  ports:
  - number: 80
    name: http-port
    protocol: HTTP
    targetPort: 6443
  - number: 6443
    name: https-port
    protocol: HTTPS
  resolution: STATIC
  endpoints:
  - address: 192.168.18.3
  location: MESH_EXTERNAL
  1. 配置DestinationRule

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: httpk8s-com
spec:
  host: httpk8s.com
  trafficPolicy:
    portLevelSettings:
    - port:
        number: 80
      tls:
        mode: SIMPLE
  1. 配置Gateway

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: apiserver-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "httpk8s.com"
  1. 配置

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: apiserver-vs
spec:
  hosts:
  - "httpk8s.com"
  gateways:
  - apiserver-gateway
  http:
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        host: httpk8s.com
        port:
          number: 80

配置摘要

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值