<p>In pod specification, there is the option <code>enableServiceLinks</code>. When set to false, environment variables related to services running at the moment of pod creation will not be injected into pod.</p>

<p>The problem is that I expected this to also happen with kubernetes clusterIp service on default namespace:</p>

<pre><code>NAME                        TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)    AGE
kubernetes                  ClusterIP   10.116.0.1     &lt;none&gt;        443/TCP    27d
</code></pre>

<p>But it is injecting environment variables into pod as follows:</p>

<pre><code>KUBERNETES_SERVICE_PORT=443
KUBERNETES_PORT=tcp://10.116.0.1:443
NODE_VERSION=12.18.0
HOSTNAME=static-web
YARN_VERSION=1.22.4
SHLVL=1
HOME=/root
test_value=8585
TERM=xterm
KUBERNETES_PORT_443_TCP_ADDR=10.116.0.1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP_PROTO=tcp
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_PORT_443_TCP=tcp://10.116.0.1:443
KUBERNETES_SERVICE_HOST=10.116.0.1
PWD=/indecision-app
</code></pre>

<p>Deployment file used for deployment:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: indecision-app-deployment
  labels:
    app: indecision-app
spec:
  selector:
    matchLabels:
      app: indecision-app
  template:
    metadata:
      labels:
        app: indecision-app
    spec:
      enableServiceLinks: false
      containers:
      - name: indecision-app
        image: hleal18/indecision-app:latest
        ports:
        - containerPort: 8080
</code></pre>

<p>Is this the correct behavior? Is there an API-supported way of avoiding these service environment variables to be injected?</p>

hleal18
<p>According to the <a href="https://github.com/kubernetes/kubernetes/blob/9050c510e640f325d008792a517fe85808b34150/pkg/kubelet/kubelet_pods.go#L523" rel="nofollow noreferrer">source code</a>:</p>
<blockquote>
<p>We always want to add environment variabled for master services from
the master service namespace, even if <code>enableServiceLinks</code> is false.</p>
</blockquote>
<p>Which basically means that you will and should not prevent those specific environment variables from being injected to the pods.</p>
<p>I hope this solves your issue.</p>
