<p>We are using argo cd and kubernetes.</p>
<p>And I want to use environmental variables in the yaml file.</p>
<p>For example,</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: guestbook-ui
  annotations:
spec:
  ports:
    - port: $PORT
      targetPort: $TARGET_PORT
  selector:
    app: guestbook-ui
</code></pre>
<p>I want to set the value of the environmental variable (PORT and TARGET_PORT) when deploying it to Argo CD.</p>
<p>What should I do?</p>

Junseok Lee
<p>I'd recommend converting your raw YAML to a Helm chart and templating the relevant fields.</p>
<p>Argo CD has an <a href="https://github.com/argoproj/argocd-example-apps/tree/master/helm-guestbook" rel="nofollow noreferrer">example Helm app</a> with a service similar to yours.</p>
<p>You could define a service like this:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: guestbook-ui
  annotations:
spec:
  ports:
    - port: {{ .Values.service.port }}
      targetPort: {{ .Values.service.targetPort }}
  selector:
    app: guestbook-ui
</code></pre>
<p>And then define your port and targetPort parameters in Argo CD.</p>
