Kubernetes Pods not able to access Internet
Trying to resolve the external network(public internet) from Kubernetes pods and getting "couldn't resolve hostname"
If this scenario a show stopper, You have accessed the right solution page. Let us resolve within no time.
Problem:
Resolution:
1. check the Firewall status first, as we trying to access the public network.
sudo firewall-cmd --list-all
If you see the MASQ is Disabled, then it is quite obvious why traffic is not routing out.
"IP Masquerade is a networking function also called MASQ, IPMASQ. It allows a set of machines to invisibly access the Internet via the MASQ gateway. IP Masquerade is a form of Network Address Translation or NAT which NAT allows internally connected computers that do not have one or more registered Internet IP addresses to communicate to the Internet via the Linux server's Internet IP address."
2. Use the below command to enable the feature
sudo firewall-cmd --permanent --add-masquerade
3. Reload the Firewall.
"Reload firewall rules and keep state information. The current permanent configuration will become new runtime configuration"
sudo firewall-cmd --reload
4. List the firewall configuration again. and now you can see the changes.
sudo firewall-cmd --list-all
5. Now exec the Pod and try to Update the repository.
[osboxes@master ~]$ k get pods # k is an alias of kubectl, I set for my ease[alias k=kubectl]
NAME READY STATUS RESTARTS AGE
centos 1/1 Running 12 2d10h
k exec -it centos /bin/bash
"This solution is useful for beginners and Developers for local use, For corporate usage, one has to follow the 'proxy' standards to route from INTRANET"
Hope this might helped for those looking for a solution. If any suggestions or new solutions required, please comment. I will try my best to precise the solution.
This helped me, Thanks.
ReplyDelete