0
点赞
收藏
分享

微信扫一扫

Flomesh Ingress 使用实践(四)TLS 透传

16751712878584.jpg

FSM 是 Flomesh 流量管理体系的一个开源组件,用于 Kubernetes 南北向的流量管理。FSM 以可编程代理 Pipy 为核心,提供了 Ingress 管理器、Gateway API* 实现、负载均衡器以及跨集群的服务注册发现等功能。

在文章 《使用 Flomesh Ingress 管理 osm-edge 服务网格入口流量》 中,我们使用 Flomesh Ingress 来服务网格的入口流量管理。实际上 Flomesh Ingress 的功能还有很多,我们后续会一一介绍。

今天就为大家介绍 Flomesh Ingress 的 SSL 透传功能。

什么是 SSL 透传

SSL(Secure Socket Layer)也被称作 TLS(Transport Layer Security),其通过加密的方式来保护客户端与服务端的安全通信。

16751642158553.png

SSL 透传(SSL Passthrough)是代理服务器处理 SSL 请求的两种方式之一(另一种是 SSL offload)。在 SSL 透传模式下,代理不会解密来自客户端的 SSL 请求,而是将其传递到上游服务器进行解密,这就意味着数据在通过代理的时候保持加密的状态,以此来保证重要和敏感数据的安全性。

SSL 透传的优点

  • 由于数据不在代理上解密,而是以加密的方式转发到上游服务器,数据可以免受网络入侵。
  • 加密数据未经解密到达上游服务,确保了数据的机密性。
  • 这也是代理配置 SSL 的最简单方法。

SSL 透传的缺点

  • 流量中可能会恶意代码,这些代码将直接到达后端服务器。
  • 在 SSL 透传过程中,无法切换服务器。
  • 无法做 7 层流量处理。

接下来我们看下,如何使用 FMS Ingress 的 SSL 透传。

Demo

环境准备

使用单节点的 K3s 集群,并禁用 traefik。

export INSTALL_K3S_VERSION=v1.23.8+k3s1
curl -sfL https://get.k3s.io | sh -s - --disable traefik --disable servicelb --write-kubeconfig-mode 644 --write-kubeconfig ~/.kube/config

安装 FSM

通过 Helm 安装 FSM。在安装时通过参数 fsm.ingress.tls=true 开启 TLS,并使用 fsm.ingress.sslPassthrough=true 开启 SSL 透传。

helm repo add fsm https://charts.flomesh.io

helm install --namespace fsm --create-namespace \
--version=0.2.1-alpha.2 \
--set fsm.ingress.tls.sslPassthrough.enabled=true \
--set fsm.serviceLB.enabled=true \
--set fsm.ingress.tls.enabled=true \
fsm fsm/fsm

确认相应组件 pod 启动并正常运行。

kubectl get po -n fsm
NAME READY STATUS RESTARTS AGE
fsm-repo-5f6dc647c7-w45sl 1/1 Running 0 26s
fsm-manager-864c74b978-fdks9 1/1 Running 0 26s
svclb-fsm-ingress-pipy-controller-26382000-scgt2 2/2 Running 0 19s
fsm-ingress-pipy-5cfc98bb48-v9x5s 1/1 Running 0 26s

获取 Ingress 的 IP 和 端口。

export ingress_host=$(kubectl -n fsm get service fsm-ingress-pipy-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
export ingress_port=$(kubectl -n fsm get service fsm-ingress-pipy-controller -o jsonpath='{.spec.ports[?(@.name==https)].port}')

测试

为简单起见,这里我们不部署上游服务,而是直接将 https://httpbin.org 作为上游,通过 curlrevolve 参数,将其解析到上面拿到的 ingress 地址。如果 ingress 的端口不是 433,可以使用 connect-to 参数 --connect-to httpbin.org:443:$ingress_host:$ingress_port

curl https://httpbin.org/get -i --resolve httpbin.org:443:$ingress_host:$ingress_port
HTTP/2 200
date: Tue, 31 Jan 2023 11:21:41 GMT
content-type: application/json
content-length: 255
server: gunicorn/19.9.0
access-control-allow-origin: *
access-control-allow-credentials: true

{
args: {},
headers: {
Accept: */*,
Host: httpbin.org,
User-Agent: curl/7.68.0,
X-Amzn-Trace-Id: Root=1-63d8f9c5-5af02436470161040dc68f1e
},
origin: 20.205.11.203,
url: https://httpbin.org/get
}

总结

SSL 透传有优点也有缺点,需要根据使用场景来灵活选择是使用 SSL 透传还是 SSL 卸载。

举报

相关推荐

0 条评论