I have a kubernetes cluster on which I deployed pods and services. One of the pod should connect to a service via the service name given its manifest.
All services and pods are deployed in the default namespace.
I have the following error in looking at the logs of the pod:
cassandra cluster ['cassandra'] not reachable: [Errno -8] Unrecognized service
Caused by: java.net.UnknownHostException: cassandra: Name does not resolve
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
at java.net.InetAddress.getAllByName0(InetAddress.java:1276)
at java.net.InetAddress.getAllByName(InetAddress.java:1192)
at java.net.InetAddress.getAllByName(InetAddress.java:1126)
at com.datastax.driver.core.Cluster$Builder.addContactPoint(Cluster.java:884)
I have a service deployed called cassandra.
When I run nslookup inside a pod here is the output:
kubectl exec -it pod/kairosdb -- nslookup cassandra
nslookup: can't resolve '(null)': Name does not resolve
Name: cassandra
Address 1: <ip> cassandra.default.svc.cluster.local
Looking for some help on how to troubleshoot this.
For local lookup, use the the fully qualified service name. In this case, cassandra.deployed-namespace-name.svc.cluster.local.
If the pod is trying to access a service which is located in a different namespace then you need to specify the namespace of the service.
cassandra.namespacename
See this for more debugging help.