What exactly happens when we try to ping an External IP for a service of type Load balancer (kubernetes)?

Viewed 1983

My cluster is running on-prem. Currently when I try to ping the external IP of service type LoadBalancer assigned to it from Metal LB. I get a reply from one of the VM's hosting the pods - Destination Host unreachable. Is this because the pods are on an internal kubernetes network(I am using calico) and cannot be pinged. A detailed explanation of the scenario can help to understand it better. Also all the services are performing as expected. I am just curious to know the exact reason behind this since I am new at this. Any help will be much appreciated. Thank you

2 Answers

The LoadbalancerIP or the External SVC IP will never be pingable.

When you define a service of type LoadBalancer, you are saying I would like to Listen on TCP port 8080 for eg: on this SVC.

And that is the only thing your External SVC IP will respond to.

A ping would be UDP ICMP packets that do not match the destination of TCP port 8080.

You can do an nc -v <ExternalIP> 8080 to test it.

OR

use a tool like mtr and pass --tcp --port 8080 to do your tests

Actually, during installation of metal LB, we need to assign a ip range from which metal LB can assign ip. Those ip must be in range of your dhcp network. for example in virtual box, network ip is assigned from the Virtualbox host-only adapter dhcp server if you use host-only adapter.

The components of metal LB are:

The metallb-system/controller deployment. This is the cluster-wide controller that handles IP address assignments. The metallb-system/speaker daemonset. This is the component that speaks the protocol(s) of your choice to make the services reachable.

when you change the service type loadbalancer, Metal LB will assigned a ip address from its ip pools which is basically maping of kubernets internal ip with the metal LB assigned ip. you can see this by

kubect get svc  -n namespaces

For more details, please check this document.

Related