Unable to ping one service to another service in Kubernetes cluster?

11/16/2018

I have created a local ubuntu Kubernetes cluster, having 1 master and 2 slave nodes.

I deployed 2 applications in 2 pods and created service for both of the pods, it's working fine. I entered inside pod by typing this command ,

$ kubectl exec -it firstpod /bin/bash
# apt-get update

Unable to make update and I'm getting an error:

Err http://security.debian.org jessie/updates InRelease

Err http://deb.debian.org jessie InRelease

Err http://deb.debian.org jessie-updates InRelease

Err http://security.debian.org jessie/updates Release.gpg   Temporary failure resolving 'security.debian.org' Err http://deb.debian.org jessie-backports InRelease

Err http://deb.debian.org jessie Release.gpg   Temporary failure resolving 'deb.debian.org' Err http://deb.debian.org jessie-updates Release.gpg   Temporary failure resolving 'deb.debian.org' Err http://deb.debian.org jessie-backports Release.gpg   Temporary failure resolving 'deb.debian.org' Reading package lists... Done W: Failed to fetch http://deb.debian.org/debian/dists/jessie/InRelease

W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/InRelease

W: Failed to fetch http://security.debian.org/dists/jessie/updates/InRelease

W: Failed to fetch http://deb.debian.org/debian/dists/jessie-backports/InRelease

W: Failed to fetch http://security.debian.org/dists/jessie/updates/Release.gpg  Temporary failure resolving 'security.debian.org'

W: Failed to fetch http://deb.debian.org/debian/dists/jessie/Release.gpg  Temporary failure resolving 'deb.debian.org'

W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/Release.gpg  Temporary failure resolving 'deb.debian.org'

W: Failed to fetch http://deb.debian.org/debian/dists/jessie-backports/Release.gpg  Temporary failure resolving 'deb.debian.org'

W: Some index files failed to download. They have been ignored, or old ones used instead.

I'm trying to ping my second pod service:

# ping secondservice (This is the service name of secondpod)
PING secondservice.default.svc.cluster.local (10.100.190.196): 56 data bytes
unable to ping.

How can I ping/call the second service from the first node?

-- Chintamani
kubernetes
kubernetes-service

1 Answer

11/16/2018

There are two (unrelated) questions I see there. I'm going to focus on the second one since the first is unclear to me (what is the ask?).

So, you wonder why the following doesn't work:

# ping secondservice 

This is not a bug or unexpected (actually, I wrote about it here). In short: the FQDN secondservice.default.svc.cluster.local gets resolved via the DNS plugin to a virtual IP (VIP), the very essence of this VIP is that it is virtual, that is, it's not attached to a network interface, it's just a bunch of iptables rules. Hence, the ICMP-based ping has nothing to work against, since it's not a 'real' IP. You can curl the service, though. Assuming the service runs on port 9876, the following should work:

# curl secondservice:9876
-- Michael Hausenblas
Source: StackOverflow