Kubernetes

How can you find out information on a Service related to a certain Pod if all you can use is kubectl exec --

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

You can run kubectl exec -- env which will give you a couple environment variables related to the Service.

Variables such as [SERVICE_NAME]_SERVICE_HOST, [SERVICE_NAME]_SERVICE_PORT, ...