内容简介:前言在Istio的世界里,如果想把外部的请求流量引入网格,你需要认识并会学会配置Istio Ingress Gateway什么是Ingress Gateway
前言
在Istio的世界里,如果想把外部的请求流量引入网格,你需要认识并会学会配置Istio Ingress Gateway
什么是Ingress Gateway
由于Kubernetes Ingress API只能支持最基本的HTTP路由,使用Kubernetes Ingress资源来配置外部流量的方式不能满足需求。因此Istio v1alpha3 routing API引入新的Istio Ingress Gateway取代Kubernetes Ingress。
Gateway为HTTP/TCP流量配置了一个负载均衡,用于承载网格边缘的进入和发出连接。在同一个网格中可以有多个不同的gateway存在。这一规范中描述了一系列开放端口,以及这些端口所使用的协议、负载均衡的 SNI 配置等内容。用户可以利用标准的Istio 路由规则控制HTTP和TCP请求进入网格。
从下图可以看到Istio gateway在整个网格中的使用情况:
如何配置Gateway控制Ingress流量
如果你已经安装好了bookinfo的应用,为了能在外部访问bookinfo中的productpage服务,只需要配置Gateway和相关的VirtualService。
用一个简单的gateway配置一个负载均衡使访问bookinfo.com的外部http流量能够进入网格:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: bookinfo-gateway
spec:
selector:
istio: ingressgateway
servers:
- hosts:
- bookinfo.com
port:
number: 80
name: http
protocol: HTTP
为了配置相应的路由,需要为相同的host定义一个VirtualService 并且用配置中gateways的字段绑定到刚才创建的Gateway:
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bookinfo
spec:
hosts:
- bookinfo.com
gateways:
- bookinfo-gateway # <---- 绑定gateway
- mesh # <----对内部通信进行流量控制
http:
- match:
- uri:
exact: /productpage
route:
- destination:
host: productpage
port:
number: 9080
这样就达到了在外网开放productpage服务的目的。
如何用HTTPS加密Gateway?
我们也可以为服务启用TLS保护,以HTTPS的形式对网格外提供服务。
首先需要使用 工具 生成客户端和服务器端的证书和密钥。然后使用密钥和证书作为输入,创建一个Secret。
$ kubectl create -n istio-system secret tls istio -ingressgateway-certs --key key.pem --cert cert.p em
接下来修改Gateway对象,为Ingress gateway开放一个443端口,用于提供HTTPS服务:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: bookinfo-gateway
spec:
selector:
istio: ingressgateway
servers:
- hosts:
- bookinfo.com
port:
number: 80
name: http
protocol: HTTP
- hosts:
- "*"
port:
number: 443
name: https
protocol: HTTPS
tls:
mode: SIMPLE
serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
privateKey: /etc/istio/ingressgateway-certs/tls.key
这样简单的配置就可以通过HTTPS协议访问bookinfo.com了。
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- idou老师教你学Istio12 : Istio 实现流量镜像
- idou老师教你学Istio06: 如何用istio实现流量迁移
- idou老师教你学Istio11 : 如何用Istio实现流量熔断
- idou老师教你学Istio 19 : Istio 流量治理功能原理与实战
- idou老师教你学Istio 09: 如何用Istio实现K8S Ingress流量管理
- idou老师教你学Istio 14:如何用K8S对Istio Service进行流量健康检查
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Out of their Minds
Dennis Shasha、Cathy Lazere / Springer / 1998-07-02 / USD 16.00
This best-selling book is now available in an inexpensive softcover format. Imagine living during the Renaissance and being able to interview that eras greatest scientists about their inspirations, di......一起来看看 《Out of their Minds》 这本书的介绍吧!