Score:0

Should my web app use the service name and port environment variables?

bj flag

I have a question about this feature, https://kubernetes.io/docs/concepts/services-networking/service/#environment-variables. Why k8s needs to inject service name and port into the pods as environment variables? Don't people always use k8s DNS to discover their services?

Could someone give a use case for when I should use them and when I should not?

jp flag
In the beginning, you did not always have an DNS server in the cluster, but nowadays you almost always have it.
David S. avatar
bj flag
Yes, I remember no DNS in K8s in the early days. But I still see people using it in a cluster that has DNS...it confuses me.
Score:0
tf flag

It will depend on what requirement you need in your setup. From this link[1] it will describe how to use service environment variables to specify the connection URL. 

On the other hand, DNS uses name to contact services instead of IP address[2]

[1]https://learn.microsoft.com/en-us/visualstudio/bridge/kubernetes-environment-variables

[2]https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.