<p>During pod startup Kubernetes is creating some environment variables based on services i created (via downward API?). Problem is that one of them, MY_APPLICATION_PORT, seems to be initialized incorrectly, it looks like:</p>
<pre><code>MY_APPLICATION_PORT=tcp://192.168.0.5:7777
</code></pre>
<p>whereas i expect it to hold only 7777 value. The problem is that i have a Spring Boot application that has this property in application.properties:</p>
<pre><code>my.application.port=7777
</code></pre>
<p>So when spring resolves it's properties, it prefers value from environment variable over one from .properties file, thus overwriting it with incorrect value.</p>
<p>My question is - do you guys know how to control creation of kubernetes env variables? I can overwrite it in my deployment.yaml, but I wonder if there's another way.</p>
<p>EDIT:</p>
<p>I've found this as a closest description of my issue I've seen online:
<a href="https://github.com/kubernetes/kubernetes/issues/65130" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/65130</a></p>

brtk
<p>This environment variable comes from compatibility with a very old Docker feature.  You can disable it in Kubernetes by setting <code>enableServiceLinks: false</code> on a <a href="https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#containers" rel="nofollow noreferrer">Container</a> object in a Pod spec, anywhere that may appear.  For example:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
        - name: ...
          enableServiceLinks: false
          env: [...]
</code></pre>
<p>In particular the syntax is intended to be compatible with the environment variables generated by container links in first-generation Docker networking.  Since then Docker has also introduced a DNS system into its core, and in pure Docker using links at all is now considered obsolete.  It should be safe to always set this Kubernetes property, especially if it causes conflicts like what you describe here.</p>
