We running or components in Kubernetes with Docker as container runtime. A problem with it is that pod environment is polluted with Docker-style link variables like
SERVICENAME_PORT_8181_TCP
SERVICENAME_PORT_HTTP
- .....
SERVICENAME_PORT
for each visible service (the ones in same namespace). In this situation it is rather easy for automatically created variables to have conflicts with explicitly declared environment. This sometimes leads to hard-to-diagnose problems. I would also not want to rely on those automatic variables as would prefer containers not to depend on details of Kubernetes service configuration. Currently I am adding unique name prefixes to explicit variables to avoid such conflicts.
Is there a way to configure cluster to not add those automatic variables for each visible service? Alternatively, would using other runtimes like containerd
solve this problem?
I am surprised that there are no readily googleable solutions for this since configuration through environment variables is considered a good practice. How in general do I use environment without running into such naming conflicts? Or service names are considered a part of contract with containers and I should not change them freely?