目录
- Gateway简介
- Gateway vs Kubernetes Ingress
- Gateway原理及实现
Gateway简介
在Istio中, Gateway控制着网格边缘的服务暴露。
- 1) L4-L6的负载均衡
- 2) 对外的mTLS
Istio服务网格中, Gateway可以部署任意多个,可以共用一个,也可以每个租户、 namespace单独隔离
Gateway根据流入流出方向分为ingress gateway和egress gateway
Ingress gateway:
- 控制外部服务访问网格内服务,配合VirtualService
Egress gateway:
- 控制网格内服务访问外部服务, 配合DestinationRule ServiceEntry使用
Gateway vs Kubernetes Ingress
Kubernetes Ingress集群边缘负载均衡, 提供集群内部服务的访问入口,仅支持L7负载均衡, 功能单一
Istio 1.0以前,利用Kubernetes Ingress实现网格内服务暴露。但是Ingress无法实现很多功能:
为了解决这些这些问题, Istio在1.0版本设计了新的v1alpha3API。
Gateway原理及实现
Gateway 与 普通sidecar均是使用Envoy作为proxy实行流量控制。
Pilot为不同类型的proxy生成相应的配置, Gateway的类型为router, sidecar的类型为sidecar。
Ingress Gateway 启动参数:
Sidecar启动参数:
Pilot如何得知proxy类型?
kubectl get crd gateways.networking.istio.io 验证
Istio networking所有配置API定义:
https://github.com/istio/api/tree/master/networking/v1alpha3
Gateway配置下发:
Gateway demo演示
- 控制Ingress HTTP流量
- 利用HTTPS保护后端服务
- mTLS
- 控制egress流量
理解外部请求如何到达应用
控制Ingress HTTP流量
HTTPS termination
生成证书
https://istio.io/docs/tasks/traffic-management/secure-ingress/#generate-client-andserver-certificates-and-keys创建secret:名称一定是istio-ingressgateway-certs,否则mount不上
$ kubectl create -n istio-system secret tls istio-ingressgateway-certs --key
httpbin.example.com/3_application/private/httpbin.example.com.key.pem --cert
httpbin.example.com/3_application/certs/httpbin.example.com.cert.pem
创建应用
$ kubectl apply -f samples/httpbin/httpbin.yaml
创建路由规则
$ kubectl apply -f samples/httpbin/httpbin-gateway-https.yaml
通过HTTPS访问
$ curl -v -HHost:httpbin.example.com --resolve httpbin.example.com:31390:100.109.176.196 --
cacert httpbin.example.com/2_intermediate/certs/ca-chain.cert.pem
https://httpbin.example.com:31390/status/418
mTLS
创建包含CA证书的secret
kubectl create -n istio-system secret generic istio-ingressgateway-ca-certs --fromfile=httpbin.example.com/2_intermediate/certs/ca-chain.cert.pem
更新Gateway TLS setting
Istio访问外部服务
Istio网格内默认不能访问外部服务,如果需要访问外部服务有三种方式:
创建应用时指定pod annotation
traffic.sidecar.istio.io/includeOutboundIPRanges: "127.0.0.1/24,10.96.0.1/24“
创建ServiceEntry
- 允许集群内访问外部服务http://httpbin.org:80
通过egress gateway控制访问外部服务
通过egress gateway控制访问外部服务
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。