当前位置:网站首页>Unable to access the CVM self built container outside the TKE cluster pod
Unable to access the CVM self built container outside the TKE cluster pod
2022-06-24 03:51:00 【Nieweixing】
1. Problem description
Use tke The customer of the product , Come across GlobalRouter In network mode tke Within cluster pod Unable to access out of cluster cvm build by oneself docker Container services ,cvm Nodes cannot be in the cluster pod service ,vpc-cni Cluster does not have this problem in network mode .
2. Problem phenomenon
Simulate problem phenomena , Outside the cluster cvm There's a nginx Containers , And map ports to nodes 8082,tke Within cluster pod Inside ping perhaps telnet Outside the cluster cvm The self built container service on does not work , Nodes in the cluster can be accessed through , Outside the cluster cvm Visit... In the cluster pod It doesn't work .
The specific test results are as follows :
- tke Cluster node access cvm On nginx service
- Within cluster pod visit cvm On nginx service
- Outside the cluster cvm Access the cluster pod
3. The analysis process
Why does it happen outside the cluster cvm Self built containers and clusters pod The phenomenon of impassability ? Let's simply grab the bag and take a look
pod Internal visit cvm Upper nginx service , At the same time cvm And pod Inner grab , From the above packet capturing results, we can see ,cvm I received pod Packet sent , however cvm Didn't return the package , Explain that the problem is cvm On , Why didn't you give it back to pod Well ?
Before we tested in cvm On is ping No cluster connection pod, You can use it here traceroute To test the routing direction , Let's see what's wrong
after traceroute You can find , visit pod The route to the node 172.18.0.1 This ip,172.18.0.1 This ip yes docker0 Bridged ip, Check the routing table and find that the destination is 172.18.0.0 The network segment ip All gone docker0 This network card . Check it out here , The cause of the problem is almost clear .
The reason is that cvm self-built docker Segments and tke Cluster network segment conflicts , Give back 172.18.0.0 Network segment packets are routed to docker0 NIC , Didn't go eth0 get out , The destination cannot receive the packet , The access is blocked .
4. Solution
Now that you know the reason , So what is the solution that doesn't exist ? Can't the follow-up be in the cluster pod Have you accessed the container service outside the cluster ?
Of course there are solutions . The solutions to this problem are 2 Kind of :
4.1 Modify cluster ip-masq-agent To configure
Careful students can find that , stay cvm Packet source received on ip yes pod The real ip, This leads to routing to docker0 On , normal k8s Access external services on ,pod ip Metropolis snat Node forming ip, Nothing here snat Node forming ip This is because a is deployed in the cluster ip-masq-agent Caused by components ,ip-masq-agent You can refer to the document for the specific description of https://cloud.tencent.com/developer/article/1688838
GlobalRouter In mode tke colony ,ip-masq-agent The default configuration access purpose is vpc The addresses of network segments and container network segments are not set snat, therefore pod visit cvm Is real pod ip.
If you want to pod visit cvm Don't be true pod Of ip, Use node ip, modify ip-masq-agent Configuration file for , Get rid of vpc Network segment configuration .
kubectl edit cm ip-masq-agent-config -n kube-system
modify configmap, Get rid of vpc Network segment 10.0.0.0/16, Then wait 1 Minutes later ,ip-masq-agent Of pod Reload configuration , Let's grab the bag and test again .
After modifying the configuration ,pod Inside, you can access cvm Of nginx The container serves , From the result of bag grabbing ,cvm The source of packet capture ip Turned into pod Where node node ip 10.0.17.16, When the destination ip Is the node ip,cvm The second routing rule will be followed on the , from eth0 Give the bag to pod, Therefore, the access is normal .
4.2 modify cvm On docker Container network segment
In addition to the above modification cluster ip-masq-agent Out of component configuration , Another solution is to modify cvm Upper docker Container network segment , To avoid and tke Cluster network segment conflict , This solution needs to be restarted cvm All the containers on , It needs to be used carefully .
Modify the /etc/docker/daemon.json The configuration file , No new one , Add the following , Here, the network segment is changed to 192.168 了 , Restart after saving docker.
"bip": "192.168.0.1/24"
Let's test , take ip-masq-agent Configuration plus vpc Network segment , And then in pod Internal access cvm Upper nginx Look at the service .
You can find , Changed cvm After the container network segment of , stay pod You can successfully access cvm Of nginx Service .
5. Think about expanding
Remember when we said , stay vpc-cni In the mode of , There will be no such problem , After the above analysis and troubleshooting , You should know why vpc-cni There won't be this problem , The reason is simple .
vpc-cni In this mode, all container network segments are vpc Next subnet ip, Container network and vpc Is the same network level ,vpc-cni Mode of pod visit cvm Upper docker Will go local Routing strategy , Go to the primary network card eth0 get out , So there won't be a problem .
边栏推荐
- Why use code signing? What certificates are required for code signing?
- hprofStringCache
- Create a telepresence USB drive using the DD command
- Tell you about mvcc
- Do you understand TLS protocol?
- Record the creation process of a joke widget (II)
- Build a small program + management background in 7 days, and this goose factory HR is blessed!
- Pits encountered in refactoring code (1)
- Clickhouse synchronous asynchronous executor
- 你了解TLS协议吗?
猜你喜欢

SQL注入绕过安全狗思路一

Common content of pine script script

黑帽实战SEO之永不被发现的劫持

ModStartCMS 主题入门开发教程

On game safety (I)

内存泄漏之KOOM

An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!

Clickhouse (02) Clickhouse architecture design introduction overview and Clickhouse data slicing design

浅谈游戏安全 (一)

flutter系列之:flutter中的offstage
随机推荐
A figure showing the price and expense structure of Tencent cloud real-time audio and video TRTC
Record the creation process of a joke widget (I)
Does the user need a code signing certificate? What is the use of a code signing certificate
RPM 包的构建 - SPEC 基础知识
[congratulations] rock solid! A new generation of AMD Blackstone architecture instance is launched!
Pine Script脚本常用内容
[code Capriccio - dynamic planning] t392 Judgement subsequence
web渗透测试----5、暴力破解漏洞--(1)SSH密码破解
Implement the throttling de dithering function
Why do I need a code signing certificate? Where can I get a code signing certificate?
How the new operator works
Protect your system with fail2ban and firewalld blacklists
Web penetration test - 5. Brute force cracking vulnerability - (4) telnet password cracking
黑帽实战SEO之永不被发现的劫持
Build a small program + management background in 7 days, and this goose factory HR is blessed!
How to use elastic scaling in cloud computing? What are the functions?
高斯光束及其MATLAB仿真
The request was aborted: Could not create SSL/TLS secure channel.
3. go deep into tidb: perform optimization explanation
你了解TLS协议吗?