028-86922220

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

k8s-service中iptablenodeport实现原理是什么

本篇文章给大家分享的是有关k8s-service中iptable node port实现原理是什么,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

成都创新互联公司专业为企业提供芙蓉网站建设、芙蓉做网站、芙蓉网站设计、芙蓉网站制作等企业网站建设、网页设计与制作、芙蓉企业网站模板建站服务,10年芙蓉做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

在这里我们主要介绍node port的实现原理,当然我们这里的k8s容器网络还是基于iptable的,不是基于ipvs的。

部署的nginx-ingress-controller的service我们可以看到:

kubectl describe service service-nginx-ingress -n kube-system

k8s-service中iptable node port实现原理是什么

对node port类型的service来说,访问host的port就访问到了这个服务。所以从host网络角度来看,当host收到数据包的时候应该是进入host network namespace的PREROUTING chain中,我们查看host network namespace的PREROUTING chain。

iptables -nvL -t nat

k8s-service中iptable node port实现原理是什么

根据规则,对于PREROUTING chain中,所有的流量都走到了KUBE-SERVICES这个target中。

查看KUBE-SERVICES target:

iptables -nvL -t nat | grep KUBE-SVC

k8s-service中iptable node port实现原理是什么

在KUBE-SERVICES target中我们可以看到当访问nginx-ingress-controller-service在host上的8080或者8443port的时候,根据规则匹配到了KUBE-NODEPORTS这个target。

查看KUBE-NODEPORTS target:

iptables -nvL -t nat

k8s-service中iptable node port实现原理是什么

在KUBE-NODEPORTS target中我们可以看到当访问8080和8443时:

查看KUBE-MARK-MASQ target:

这里只是做了一下标记,并没有nat target。

iptables -nvL -t nat

k8s-service中iptable node port实现原理是什么

查看KUBE-SVC-QY5PTWKILTPBPDCE和KUBE-SVC-SQYXO6PN7K55YEZU两个target:

iptables -nvL -t nat

k8s-service中iptable node port实现原理是什么

我们可以看到

查看KUBE-SEP-WM2TRROMQQXWNW4W和KUBE-SEP-7XLQX5JZL77UC7RY两个target:

iptables -nvL -t nat

k8s-service中iptable node port实现原理是什么

k8s-service中iptable node port实现原理是什么

我们可以看到

所以综合上面的例子,对于ipable方式的k8s集群内node port类型的service总结为:

以上就是k8s-service中iptable node port实现原理是什么,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注创新互联行业资讯频道。


新闻名称:k8s-service中iptablenodeport实现原理是什么
网站路径:http://www.tsicrk.com/article/jhppip.html

其他资讯

让你的专属顾问为你服务

1.6654s