<p>I have a kubernetes deployment using environment variables and I wonder how to set dynamic endpoints in it.</p>

<p>For the moment, I use</p>

<pre><code>$ kubectl get ep rtspcroatia
NAME          ENDPOINTS         AGE
rtspcroatia   172.17.0.8:8554   3h33m
</code></pre>

<p>And copy/paste the endpoint's value in my deployment.yaml. For me, it's not the right way to do it, but I can't find another method..</p>

<p>Here is a part of my deployment.yaml :</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    io.kompose.service: person-cam0
  name: person-cam0
spec:
  template:
    metadata:
      labels:
        io.kompose.service: person-cam0
    spec:
      containers:
      - env:
        - name: S2_LOGOS_INPUT_ADDRESS
          value: rtsp://172.17.0.8:8554/live.sdp
        image: ******************
        name: person-cam0

</code></pre>

<p>EDIT : And the service of the rtsp container</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  labels:
    io.kompose.service: rtspcroatia
  name: rtspcroatia
spec:
  type: LoadBalancer
  ports:
  - protocol: TCP
    port: 8551
    targetPort: 8554
  selector:
    io.kompose.service: rtspcroatia
</code></pre>

<p>Can you help me to have something like :</p>

<pre><code>      containers:
      - env:
        - name: S2_LOGOS_INPUT_ADDRESS
          value: rtsp://$ENDPOINT_ADDR:$ENDPOINT_PORT/live.sdp
</code></pre>

<p>Thank you !</p>

Borhink
<p>You could set dynamic ENDPOINTS values like "POD_IP:SERVICE_PORT" as shown on below sample yaml code. </p>

<pre><code>   containers:
   - env:
     - name: MY_ENDPOINT_IP
       valueFrom:
           fieldRef:
               fieldPath: status.podIP
     - name: S2_LOGOS_INPUT_ADDRESS
       value: rtsp://$MY_ENDPOINT_IP:$RTSPCROATI_SERVICE_PORT/live.sdp
</code></pre>
