I have made a nginx deployment which will be tagged by a ClusterIP service via a selector. Then I entered a new pod that is not related to that deployment nor service. And from within that pod I try to ping the i.p of the ClusterIP service hoping it would reach the nginx deploy, but it's not receiving the ping response.
The nginx deployment I made was with this manifest.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx
spec:
selector:
matchLabels:
run: my-nginx
replicas: 1
template:
metadata:
labels:
run: my-nginx
spec:
containers:
- name: my-nginx
image: nginx
ports:
- containerPort: 80
Then, the service I created was with this manifest:
apiVersion: v1
kind: Service
metadata:
name: basicping-service
labels:
run: my-nginx
spec:
ports:
- port: 80
protocol: TCP
selector:
run: my-nginx
I made sure the service got created by running kubectl get svc
and it did, the i.p is 10.98.91.185
And then I created a new pod completely unrelated to this deployment&Service.
kubectl run -it --rm --image=ubuntu bash
From within it, I pinged a sandbox server called pingtest.net
just to see it was able to send requests and receive response. And it did
So finally, I tried pinging the basicping-service
created previously by trying to ping the i.p of the service, I did this by running ping 10.98.91.185
And here is the problem. It does sends pings but doesn't receives the responses back, even after several minutes.
It was my understanding that the ping should have received a response. But is my understanding of services incorrect ? Or it should have worked but there is an error?
Just for more documentation, the my-nginx deployment is running, and the pod as well. And there seems to be nothing wrong with the nginx running in it. I checked this by running the kubectl describe
of the deploy & pod, and also by checking the pod's logs, it's running nginx correctly apparently. Also, after running kubectl describe svc basicping-service
it does shows the nginx pod's i.p address with port 80 as the endpoint