<p>I have a node.js (express) project checked into gitlab and this is running in Kubernetes . I know we can set env variables in Kubernetes(on Azure, aks) in deployment.yaml file.</p>

<p>How can i pass  gitlab ci/cd env variables to kubernetes(aks) (deployment.yaml file) ?</p>

Fakeer
<p>You can develop your own helm charts. This will pay back in long perspective. </p>

<p>Other approach: there is an easy and versatile way is to put <code>${MY_VARIABLE}</code> placeholders into the deployment.yaml file. Next, during the pipeline run, at the deployment job use the <code>envsubst</code> command to substitute vars with respective values and deploy the file. </p>

<p>Example deployment file:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment-${MY_VARIABLE}
  labels:
    app: nginx
spec:
  replicas: 3
(...)
</code></pre>

<p>Example job:</p>

<pre><code>(...)
deploy:
  stage: deploy
  script:
    - envsubst &lt; deployment.yaml &gt; deployment-${CI_JOB_NAME}.yaml
    - kubectl apply -f deployment-${CI_JOB_NAME}.yaml
</code></pre>
