<p>I was setting up a laravel and socketcluster install on kubernetes and when try to add redis to laravel got an error about an env variable that i doesn't have defined, so when i print all the env variables in any container i get all the variables from others services like this:</p>

<pre><code>SCC_STATE_PORT_7777_TCP_PORT=7777
KUBERNETES_SERVICE_PORT=443
PHP_PORT_9000_TCP_ADDR=10.35.246.141
SOCKETCLUSTER_SERVICE_PORT=8000
RDB_SERVICE_PORT_DB=28015
REDIS_SERVICE_PORT=6379
SCC_BROKER_PORT_8888_TCP_PROTO=tcp
MARIADB_PORT_3306_TCP=tcp://10.35.247.244:3306
KUBERNETES_PORT_443_TCP_PORT=443
RDB_SERVICE_PORT_WEB=8080
RDB_PORT=tcp://10.35.250.91:28015
RDB_PORT_28015_TCP=tcp://10.35.250.91:28015
KUBERNETES_SERVICE_HOST=10.35.240.1
NGINX_PORT_80_TCP_PORT=80
PHP_SERVICE_PORT=9000
RDB_SERVICE_PORT=28015
RDB_PORT_8080_TCP_ADDR=10.35.250.91
SCC_STATE_PORT_7777_TCP_ADDR=10.35.254.120
SOCKETCLUSTER_PORT=tcp://10.35.244.112:8000
RDB_PORT_28015_TCP_ADDR=10.35.250.91
PHP_PORT=tcp://10.35.246.141:9000
PHP_PORT_9000_TCP=tcp://10.35.246.141:9000
RDB_PORT_28015_TCP_PROTO=tcp
REDIS_PORT_6379_TCP_ADDR=10.35.254.59
MARIADB_PORT_3306_TCP_PORT=3306
SCC_STATE_PORT_7777_TCP_PROTO=tcp
MARIADB_SERVICE_PORT=3306
PHP_SERVICE_HOST=10.35.246.141
PHP_PORT_9000_TCP_PROTO=tcp
RDB_PORT_8080_TCP=tcp://10.35.250.91:8080
RDB_PORT_8080_TCP_PROTO=tcp
REDIS_PORT_6379_TCP_PROTO=tcp
MARIADB_PORT_3306_TCP_ADDR=10.35.247.244
KUBERNETES_PORT_443_TCP_ADDR=10.35.240.1
NGINX_PORT_80_TCP_ADDR=10.35.247.125
REDIS_SERVICE_HOST=10.35.254.59
SCC_BROKER_SERVICE_HOST=10.35.243.129
SCC_STATE_PORT_7777_TCP=tcp://10.35.254.120:7777
NGINX_PORT=tcp://10.35.247.125:80
SOCKETCLUSTER_PORT_8000_TCP_PROTO=tcp
SCC_STATE_SERVICE_PORT=7777
SCC_STATE_PORT=tcp://10.35.254.120:7777
NGINX_PORT_80_TCP_PROTO=tcp
SOCKETCLUSTER_PORT_8000_TCP=tcp://10.35.244.112:8000
RDB_SERVICE_HOST=10.35.250.91
NGINX_SERVICE_PORT_DB=80
MARIADB_PORT_3306_TCP_PROTO=tcp
PHP_PORT_9000_TCP_PORT=9000
SOCKETCLUSTER_PORT_8000_TCP_PORT=8000
SOCKETCLUSTER_PORT_8000_TCP_ADDR=10.35.244.112
REDIS_PORT_6379_TCP=tcp://10.35.254.59:6379
NGINX_PORT_80_TCP=tcp://10.35.247.125:80
SCC_BROKER_PORT_8888_TCP=tcp://10.35.243.129:8888
KUBERNETES_PORT=tcp://10.35.240.1:443
NGINX_SERVICE_PORT=80
RDB_PORT_28015_TCP_PORT=28015
RDB_PORT_8080_TCP_PORT=8080
SCC_BROKER_SERVICE_PORT=8888
SCC_STATE_SERVICE_HOST=10.35.254.120
MARIADB_SERVICE_HOST=10.35.247.244
KUBERNETES_SERVICE_PORT_HTTPS=443
REDIS_PORT=tcp://10.35.254.59:6379
REDIS_PORT_6379_TCP_PORT=6379
SCC_BROKER_PORT=tcp://10.35.243.129:8888
NGINX_SERVICE_HOST=10.35.247.125
SCC_BROKER_PORT_8888_TCP_PORT=8888
MARIADB_PORT=tcp://10.35.247.244:3306
KUBERNETES_PORT_443_TCP_PROTO=tcp
SOCKETCLUSTER_SERVICE_HOST=10.35.244.112
SCC_BROKER_PORT_8888_TCP_ADDR=10.35.243.129
KUBERNETES_PORT_443_TCP=tcp://10.35.240.1:443
</code></pre>

<p>when i have this deployments:
<img src="https://i.ibb.co/yXbCc77/Captura.png" alt="gke"></p>

<p>Any idea if this is a feature, a miss config or what?
UPDATE: or if i could disable it?</p>

<p><a href="https://kubernetes.io/docs/concepts/services-networking/service/#environment-variables" rel="nofollow noreferrer">It's a feature.</a>  For every Service in the same namespace, you get <code>OTHERSVC_SERVICE_HOST</code> and <code>OTHERSVC_SERVICE_PORT</code> environment variables, plus some others that come from the legacy Docker links feature.  I don't know of any way to turn these off.</p>

<p>Actually using these is problematic in practice, because it depends on the consuming pod starting after the producing service is up, which is hard to guarantee; DNS lookups <code>othersvc.default.svc.cluster.local</code> may not resolve at runtime but won't have a missing environment variable.  Conversely, if you might configure your pod with an environment variable named something like <code>MICRO_SERVICE_HOST</code> or <code>DATABASE_PORT</code>, those names are liable to be "stepped on" by the generated environment variables.</p>
