<p>I use:
Spring Boot
Microservices (containerized)
Docker
Kubernetes</p>

<p>My case is as follows:</p>

<p>I have to generate link: 
<code>https://dev-myapp.com</code> OR <code>https://qa-myapp.com</code> 
depending on the environment in which my service is running (DEV, QA)
Depending on the environment (DEV, QA). I have one Spring profile BUT under this profile my app can run in kubernetes on 2 types of environment: DEV or QA. I want to generate proper link - read it from my properties file:</p>

<pre><code>@Value("${email.body}")
  private String emailBody;
</code></pre>

<p>application.yaml:</p>

<pre><code>email:
  body: Click on the following URL: ${ENVIRONMENT_URL:}/edge/invitation?code={0}&amp;email={1}
</code></pre>

<p>DEVOPS(Kubernetes):</p>

<p>Manifest in workloads folder (DEV branch, the same for qa branch nut this time with <a href="https://qa-myapp.com" rel="nofollow noreferrer">https://qa-myapp.com</a>):</p>

<pre><code>apiVersion: v1
kind: Service
...
...
apiVersion: apps/v1
kind: Deployment
...
...
containers:
env:
 - name: ENVIRONMENT_URL
          value: https://dev-myapp.com
</code></pre>

<p>So is i possible to read that value from kubernetes container in my Spring properties file? I want to get email.body property depending on the container my service is running on.</p>

Matley
<p>Yes this is possible and have corrected the syntax of the <code>yaml</code></p>

<pre><code>apiVersion: v1
kind: Service
...
...
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        command: ["/bin/sh", "-c", "env | grep ENVIRONMENT_URL"]
        env:
        - name: ENVIRONMENT_URL
          value: https://myapp.com. #Indedntation Changed
        ports:
        - containerPort: 80
</code></pre>
