I am trying to ping and access a k8s service from two different pods. However, I am able to access from one pod while from other pod it is inaccessible. What could be the reason for that ? And how can I fix?
— service accessible from the pod
/home/ravi>sudo docker exec -it bc1104f73042 /bin/bash
root@kpimon-go:/opt# ps -eaf
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 15:01 ? 00:00:00 ./kpimon
root 21 0 0 15:27 pts/0 00:00:00 /bin/bash
root 36 21 0 15:27 pts/0 00:00:00 ps -eaf
root@kpimon-go:/opt# cat /etc/resolv.conf
nameserver 10.96.0.10
search ricxapp.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
root@kpimon-go:/opt# cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.244.0.253 kpimon-go
root@kpimon-go:/opt# ping service-ricplt-e2mgr-http
ping: service-ricplt-e2mgr-http: Name or service not known ----------> unable to ping on k8s service
root@kpimon-go:/opt#
— service inaccessible from the pod
/home/ravi>sudo docker exec -it 1df20eaae850 /bin/bash
root@rtmgr:/# cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.244.0.250 rtmgr
root@rtmgr:/#
root@rtmgr:/# cat /etc/resolv.conf
nameserver 10.96.0.10
search ricplt.svc.cluster.local svc.cluster.local cluster.local
options ndots:5
root@rtmgr:/#
root@rtmgr:/#
root@rtmgr:/# ping service-ricplt-e2mgr-http ----------> unable to ping on k8s service
PING service-ricplt-e2mgr-http.ricplt.svc.cluster.local (10.101.210.88) 56(84) bytes of data.
64 bytes from service-ricplt-e2mgr-http.ricplt.svc.cluster.local (10.101.210.88): icmp_seq=1 ttl=64 time=0.059 ms
64 bytes from service-ricplt-e2mgr-http.ricplt.svc.cluster.local (10.101.210.88): icmp_seq=2 ttl=64 time=0.107 ms
^C
--- service-ricplt-e2mgr-http.ricplt.svc.cluster.local ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1025ms
rtt min/avg/max/mdev = 0.059/0.083/0.107/0.024 ms
root@rtmgr:/#
root@rtmgr:/#
— info about k8s pods and services
/home/ravi>kubeclt get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-5644d7b6d9-ngpd6 1/1 Running 13 9d
kube-system coredns-5644d7b6d9-pvzvz 1/1 Running 13 9d
kube-system etcd-ubuntu-20 1/1 Running 13 9d
kube-system kube-apiserver-ubuntu-20 1/1 Running 13 9d
kube-system kube-controller-manager-ubuntu-20 1/1 Running 13 9d
kube-system kube-flannel-ds-hrrml 1/1 Running 13 9d
kube-system kube-proxy-7hbwm 1/1 Running 13 9d
kube-system kube-scheduler-ubuntu-20 1/1 Running 13 9d
ricinfra deployment-tiller-ricxapp-68f777c4d4-lcmff 1/1 Running 1 4h22m
ricinfra tiller-secret-generator-vgkr9 0/1 Completed 0 4h22m
ricplt deployment-ricplt-a1mediator-669cc74647-mw7bb 1/1 Running 1 4h21m
ricplt deployment-ricplt-alarmmanager-57785458dd-ks5t2 1/1 Running 1 4h20m
ricplt deployment-ricplt-appmgr-77986c9cbb-h2mq8 1/1 Running 1 4h21m
ricplt deployment-ricplt-e2mgr-5dd878f58b-bhvss 1/1 Running 5 4h21m
ricplt deployment-ricplt-e2term-alpha-5d58997d8f-8kcrz 1/1 Running 1 4h21m
ricplt deployment-ricplt-o1mediator-5ddd66b4d6-h8nt8 1/1 Running 1 4h20m
ricplt deployment-ricplt-rtmgr-788975975b-kgxfj 1/1 Running 3 4h21m
ricplt deployment-ricplt-submgr-68fc656488-hcccs 1/1 Running 1 4h21m
ricplt deployment-ricplt-vespamgr-84f7d87dfb-mp76j 1/1 Running 1 4h20m
ricplt r4-influxdb-influxdb2-0 1/1 Running 1 4h12m
ricplt r4-infrastructure-kong-7995f4679b-brhdq 2/2 Running 6 4h22m
ricplt r4-infrastructure-prometheus-alertmanager-5798b78f48-hbn8k 2/2 Running 2 4h22m
ricplt r4-infrastructure-prometheus-server-c8ddcfdf5-vr8dk 1/1 Running 1 4h22m
ricplt statefulset-ricplt-dbaas-server-0 1/1 Running 1 4h21m
ricxapp ricxapp-kpimon-go-7b8bb97ffb-5x76c 1/1 Running 1 3h51m
/home/ravi>
/home/ravi>
/home/ravi>kubeclt get svc -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 9d
kube-system kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 9d
ricinfra service-tiller-ricxapp ClusterIP 10.98.94.194 <none> 44134/TCP 4h22m
ricplt aux-entry ClusterIP 10.105.149.143 <none> 80/TCP,443/TCP 4h22m
ricplt r4-influxdb-influxdb2 ClusterIP 10.110.14.243 <none> 80/TCP 4h13m
ricplt r4-infrastructure-kong-proxy NodePort 10.107.12.178 <none> 32080:32080/TCP,32443:32443/TCP 4h22m
ricplt r4-infrastructure-prometheus-alertmanager ClusterIP 10.104.86.76 <none> 80/TCP 4h22m
ricplt r4-infrastructure-prometheus-server ClusterIP 10.102.224.176 <none> 80/TCP 4h22m
ricplt service-ricplt-a1mediator-http ClusterIP 10.105.45.1 <none> 10000/TCP 4h21m
ricplt service-ricplt-a1mediator-rmr ClusterIP 10.108.188.147 <none> 4561/TCP,4562/TCP 4h21m
ricplt service-ricplt-alarmmanager-http ClusterIP 10.111.239.130 <none> 8080/TCP 4h20m
ricplt service-ricplt-alarmmanager-rmr ClusterIP 10.106.30.195 <none> 4560/TCP,4561/TCP 4h20m
ricplt service-ricplt-appmgr-http ClusterIP 10.110.110.91 <none> 8080/TCP 4h21m
ricplt service-ricplt-appmgr-rmr ClusterIP 10.110.96.28 <none> 4561/TCP,4560/TCP 4h21m
ricplt service-ricplt-dbaas-tcp ClusterIP None <none> 6379/TCP 4h22m
ricplt service-ricplt-e2mgr-http ClusterIP 10.101.210.88 <none> 3800/TCP 4h21m
ricplt service-ricplt-e2mgr-rmr ClusterIP 10.101.245.34 <none> 4561/TCP,3801/TCP 4h21m
ricplt service-ricplt-e2term-prometheus-alpha ClusterIP 10.97.95.213 <none> 8088/TCP 4h21m
ricplt service-ricplt-e2term-rmr-alpha ClusterIP 10.100.36.142 <none> 4561/TCP,38000/TCP 4h21m
ricplt service-ricplt-e2term-sctp-alpha NodePort 10.108.215.136 <none> 36422:32222/SCTP 4h21m
ricplt service-ricplt-o1mediator-http ClusterIP 10.96.196.67 <none> 9001/TCP,8080/TCP,3000/TCP 4h20m
ricplt service-ricplt-o1mediator-tcp-netconf NodePort 10.104.237.252 <none> 830:30830/TCP 4h20m
ricplt service-ricplt-rtmgr-http ClusterIP 10.105.27.42 <none> 3800/TCP 4h21m
ricplt service-ricplt-rtmgr-rmr ClusterIP 10.110.0.158 <none> 4561/TCP,4560/TCP 4h21m
ricplt service-ricplt-submgr-http ClusterIP None <none> 3800/TCP 4h21m
ricplt service-ricplt-submgr-rmr ClusterIP None <none> 4560/TCP,4561/TCP 4h21m
ricplt service-ricplt-vespamgr-http ClusterIP 10.98.139.191 <none> 8080/TCP,9095/TCP 4h21m
ricxapp aux-entry ClusterIP 10.99.152.66 <none> 80/TCP,443/TCP 4h22m
ricxapp service-ricxapp-kpimon-go-http ClusterIP 10.109.170.194 <none> 8080/TCP 3h51m
ricxapp service-ricxapp-kpimon-go-rmr ClusterIP 10.111.137.11 <none> 4560/TCP,4561/TCP 3h51m
/home/ravi>
2
Answers
Does the inaccessible pod’s namespace same with service? If not, try to
You are not able to ping the service in K8s.
Check whether you are using the same namespace to ping the pod. You can also use curl or wget
For additional info refer to the link Ways to connect