How to find the url of a service in kubernetes?

Foo picture Foo · Jan 2, 2020 · Viewed 24.6k times · Source

I have a local kubernetes cluster on my local docker desktop.

This is how my kubernetes service looks like when I do a kubectl describe service

Name:              helloworldsvc
Namespace:         test
Labels:            app=helloworldsvc
Annotations:       kubectl.kubernetes.io/last-applied-configuration:
                     {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"helloworldsvc"},"name":"helloworldsvc","namespace":"test...
Selector:          app=helloworldapp
Type:              ClusterIP
IP:                10.108.182.240
Port:              http  9111/TCP
TargetPort:        80/TCP
Endpoints:         10.1.0.28:80
Session Affinity:  None
Events:            <none>

This service is pointing to a deployment with a web app.

My question how to I find the url for this service? I already tried http://localhost:9111/ and that did not work.

I verified that the pod that this service points to is up and running.

Answer

P Ekambaram picture P Ekambaram · Jan 2, 2020

URL of service is in the below format:

<service-name>.<namespace>.svc.cluster.local:<service-port>

In your case it is:

helloworldsvc.test.svc.cluster.local:9111