2

I would like to perform a call to my echo-server but I can not figure out what's the hostname of my service:

orion:webanalytics papaburger$ kubectl get services -n web-analytics
NAME                   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)      AGE
echo-server            ClusterIP   10.100.92.251    <none>        80/TCP       87m
web-api                ClusterIP   10.100.92.250    <none>        8080/TCP     87m

I have tried to reach using kubectl exec -it curl-curl0 -- curl http://web-analytics.echo-server.svc.cluster.local/heythere but it fails:

curl: (6) Couldn't resolve host 'web-analytics.echo-server.svc.cluster.local'

If I change web-analytics.echo-server.svc.cluster.local to cluster ip, it works.

How can I make my pods (web-api) reach the echo server?

edit:

orion:webanalytics papaburger$ kubectl get ep -n web-analytics
NAME                   ENDPOINTS             AGE
echo-server            172.16.187.247:80     95m
web-api                172.16.184.217:8080   95m
8
  • where is the web-analytics service described? as far as I can see the output you describe it say it's diffrent service Commented Jul 28, 2020 at 18:07
  • Check the update Commented Jul 28, 2020 at 18:09
  • Why the service name is diffrent? Commented Jul 28, 2020 at 18:09
  • What do you mean? I'm new to K8s Commented Jul 28, 2020 at 18:09
  • I can not see the web-analytics service name? Commented Jul 28, 2020 at 18:10

2 Answers 2

5

it should be like this

the service name is always like this

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

kubectl exec -it curl-curl0 -- curl http://echo-servcer.web-analytics.svc.cluster.local/heythere

or alternative way would be you can directly curl the POD_IP:80

1

The DNS name is referred incorrectly, it follows the following format

my-svc.my-namespace.svc.cluster-domain.example

Based on the kubectl output, the DNS should be

echo-server.web-analytics.svc.cluster.local

The respective curl will be -

kubectl exec -it curl-curl0 -- curl http://echo-server.web-analytics.svc.cluster.local/heythere

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.