《K8S Service实战与原理初探.docx》由会员分享,可在线阅读,更多相关《K8S Service实战与原理初探.docx(12页珍藏版)》请在第一文库网上搜索。
1、K8SService实战与原理初探【导读】本文主要讲述了K8SService的基本概念,使用方式及实现原理。故事的开始,让我们先从一件生产故障说起。5月29日,内部某系统出现大规模访问Service故障,发现Pod容器内无法正常访问ServiceIPiPort,整个故障持续时间超过12h,相关运维支撑人员没有找到根本原因和解决办法。经过复盘,我们发现,大家对于K8SSerViCe的原理不够清晰,导致对问题的定位不能做得到快速准确,如果当时能够按照如下的思路去思考问题,排查过程不至于花费如此久的时间。JW个Srvic3E法访同?WSrvkN府的U-Od事再I1JIt(SerViCe:POrt无法
2、访问个才机坨w?mu*.才矶一多个Srvic5e法访问参个主10均也MW17MKubPrryKubptaKUBE-SVC-XXXXXXXXXXXXXXXX-KUBE-SEP-XXXXXXXXXXXXXXXXrepresentsaC1usterIPservice KUBE-NODEPORTS-KUBE-SVC-XXXXXXXXXXXXXXXX-KUBE-SEP-XXXXXXXXXXXXXXXXrepresentsaNodePortservice几种不同类型的Service在Kube-Proxy启用Iptab1es模式下上的表现 C1usterIP-aKube-Services!-s172.200
3、.0.0i6-d10.100.160.92/32-ptcp-mcomment-commentdefau1t/CCS-gateway-C1USterip:httpc1usterIPr,-mtcpdport30080-jKUBE-MARK-MASQ-AKUBE-SERVICES-d10.100.160.92/32-ptcp-mcomment-comment,defau1t/ccs-gateway-c1usterip:httpc1usterIP-mtcp-dport30080-jKUBE-SVC-76GERFBRR2RGNBJ-AKUBE-SVC-76GERFBRR2RGHNBJ-mcommentc
4、oent,defau1tccs-gateway-c1usterip:httpr,mstatistic-moderandom-probabi1ity0.33333333349-jKUBE-SEP-GBVECAZBIC3ZKMXB-AKUBE-SVC-76GERFBRR2RGHNBJ-mcomment-comment,defa11/ccs-gateway-c1usterip:http,*-mstatistic-moderandom-probabi1ity0.50000000000-jKUBE-SEP-PVCYYXEU44D3IMGK-AKUBE-SVC-76GERFBRR2RGHNBJ-mcomm
5、ent-commentr,defau1t/ccs-gateway-c1usterip:httpr,-jKUBE-SEP-JECGZ1HE32MERRX-AKUBE-SVC-CEZPIJSAUFW5MYPQ-mcomment-comment,kubernetes-dashboarc1kubernetes-dashboard-jKUBE-SEP-Q06MV41IR5U56RP7M-AKUBE-SEP-GBVECAZBIC3ZKMXB-s172.200.6.224/32-mcommentcomment,defa1tccs-gateway-c1usterip:httpn-jKUBE-MARK-MASQ
6、-AKUBE-SEP-GBVECAZBIC3ZKMXB-Ptcp-mcomment-comment,defau1t/ccs-gateway-c1usterip:httpr,-mtcp-jDNAT-to-destination172.200.6.224:80.NodePortapiVersion:v1kind:Servicemetadata:1abe1s:app:ccs-gatewayspec:c1usterTP:10.101.156.39externa1TrafficPo1icy:C1usterports:-name:httpnodePort:30081port:30080protoco1:T
7、CPtargetPort:80se1ector:app:ccs-gatewaysessionAffinity:-AKUBE-NODEPORTS-Ptcp-mcomment-comment,defau1t/ccs-gateway-service:http,-mtcpdport30081-jKUBE-MARK-MASQ-AKUBE-NODEPORTS-ptcp-mcomment-commentwdefau1tccs-gateway-service:httpr,-mtcp-dport30081-jKUBE-SVC-QYHRFFH15VINYT2K#-AK1JBE-SVC-QYHRFFH15VINYT2K-mcomment-comment,defau1tccs-gateway-service:httpr,-mstatistic-moderandom-probabi1i