Testing a service accessibility:
We use the below command to create both a service and a pod with the nginx image:
We can check if the service is accessible from inside a newly created debian container using the nslookup tool:
--restart: is the restart policy when the pod crashes for example, in the above example it is set to "never".
We get the below results which show that our service is reachable through the DNS server below "10.11.50.9":
We can also see the service name "nginx-1.default.svc.cluster.local",
"default" is the name of the default namespace of kubernetes, where our service lives.