c语言sscanf函数的用法是什么
328
2022-09-11
Cilium host-Reachable Services
Host-Reachable
简介
Host-Reachable
Host-Reachable 是在同一集群内部,通过 sevice 访问的东西流量的一种配置,我们可以通过这种类似直接到达目的 pod ,而不经过 kube-proxy 的 nat 的方式进行提供东西方向的流量。
为了方便演示,我们使用的 NodePort 类型的方式进行抓包。
引用官方文档的一句话:
Host-reachable services act transparent to Cilium’s lower layer datapath in that upon connect system call (TCP, connected UDP) or sendmsg as well as recvmsg (UDP) the destination IP is checked for an existing service IP and one of the service backends is selected as a target, meaning, while the application is assuming its connection to the service address, the corresponding kernel’s socket is actually connected to the backend address and therefore no additional lower layer NAT is required.
大概意思就是:
Host-reachable services 对 Cilium 的底层数据通路是透明的,在连接系统调用(TCP、UDP)或者发送和接收 msg 的时候,目的 ip 被检查为现有的服务 IP,并选择服务后端之一作为目标,这意味着,当应用程序假定其连接到服务地址时,相应的内核的套接字实际上连接到后端地址,因为不需要额外的下层 NAT。
部署方式
在 native-routing 模式的基础上进行更改测试
增加选项
enable-host-reachable-services: "true"
演示前提
client-pod node-1 对应图中 pod1
cni-test node-2 对应图中 service pod
我们在 client-pod 所在节点 curl cni-test 的 svc,看报文的地址是否是直达的 node-2 节点
root@master:# kubectl get pod -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATESclient-pod-64d766778d-zdtrg 1/1 Running 0 41s 10.0.0.24 node-1.whale.com
# client-pod 对应 lxc 网卡root@node-1:# ip link show | grep "^13"13: lxc2dc106b03723@if12:
抓包测试
东西流量抓包
client-pod 通过 nodeport 访问 cni-test
root@master:~# kubectl exec -it client-pod-64d766778d-zdtrg -- curl 192.168.0.120:30121
If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.
For online documentation and support please refer to
client-pod eth0
kubectl exec -it client-pod-64d766778d-zdtrg -- tcpdump -pne -i eth0 -w client-eth0.cap
client-pod lxc
tcpdump -pne -i lxc2dc106b03723 -w c-lxc.cap
client-pod ens33
此报文是 client pod 出去的报文,并不是收到请求和响应报文,我们可以借助,master 主机上的 ens33 网卡的报文进行验证
tcpdump -pne -i ens33 -w c-ens33.cap
master ens33
通过删选 报文进行验证
tcpdump -pne -i ens33 -w m-ens33.cap
cni-test ens33
tcpdump -pne -i ens33 -w cni-恩师3.cap
cni-test lxc
tcpdump -pne -i lxc172dc1c8e33d -w cni-lxc.cap
cni-test eth0
kubectl exec -it cni-test-777bbd57c8-xsgx4 -- tcpdump -pne -i eth0 -w cni-eth0.cap
南北流量抓包对比
我们单独开一个 192.168.0.50 的机器进行抓包,此机器不属于集群内部,所以他访问的流量是南北流量
我们提供服务器的 pod 在 192.168.0.130 上,我们访问 192.168.0.110:3012 测试抓包
root@tf:~# curl 192.168.0.110:30121
If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.
For online documentation and support please refer to
50.cap
tcpdump -pne -i ens33 -w 50.cap
110-ens33.cap
tcpdump -pne -i ens33 -w m-ens33.cap
总结
集群内部东西方向的流量可以通过 host-Reachable 的方式达到直连的效果。
而集群内外南北方向的流量则是通过 SNAT 的方式达到集群提供正常访问的目的。下一节我们说一下南北方向还可以通过 DSR 的方式缩短 SNAT 的报文响应距离。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~