<p>in the yaml file can we use something like below to pull the image? or is there a better way?</p>

<p>I want to pull an image but the may vary depending on the releases.</p>

<p>configmap is like</p>

<pre><code>kind: ConfigMap
apiVersion: v1
metadata:
  name: configmap
  namespace: rel
data:
  # Configuration values can be set as key-value properties
  RELEASE_ID: 1.1.1
</code></pre>

<p>Pod is like </p>

<pre><code>    imagePullPolicy: Always
    image: "sid_z:$(RELEASE_LEVEL)"
    env:
      - name: RELEASE_LEVEL
        valueFrom:
          configMapKeyRef:
            name: configmap
            key: RELEASE_ID
</code></pre>

<p>rightnow it gives me an error invalid reference format  Error: InvalidImageName</p>

user2511126
<ul>
<li><p>You can't use Environment variables, because they are made available inside the container, as mentioned in the other answer.</p>
</li>
<li><p>using linux variables would not be processed as well because is the server who processes the yaml, not the terminal itself.</p>
</li>
<li><p>My suggestion is <strong>to use <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-image-em-" rel="nofollow noreferrer">Kubectl set image</a></strong>:</p>
</li>
</ul>
<blockquote>
<p><code>kubectl set image</code> Update existing container image(s) of resources like:</p>
<p>pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), replicaset (rs)</p>
</blockquote>
<ul>
<li>You can even see the processed yaml locally, before hitting the server with the parameter <code>--local</code>, more on that on the example bellow.</li>
</ul>
<hr />
<p><strong>Examples:</strong></p>
<ul>
<li>Print result in yaml format of updating the image of the container named <code>container-1</code> from local file, without hitting the server, neither changing the file:</li>
</ul>
<pre><code>$ cat hello.yaml 
apiVersion: v1
kind: Pod
metadata:
 name: hello
spec:
  containers:
  - name: container-1
    image: gcr.io/google-samples/hello-app:1.0
    ports:
    - name: http
      containerPort: 8080

$ kubectl set image -f hello.yaml container-1=gcr.io/google-samples/hello-app:2.0 --local -o yaml
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  name: hello
spec:
  containers:
  - image: gcr.io/google-samples/hello-app:2.0
    name: container-1
    ports:
    - containerPort: 8080
      name: http
    resources: {}
status: {}
</code></pre>
<ul>
<li>You can pipe the output to directly create the pod with the changed image:</li>
</ul>
<pre><code>$ kubectl set image -f hello.yaml container-1=gcr.io/google-samples/hello-app:2.0 --local -o yaml | kubectl apply -f -
pod/hello created

$ kubectl get pods
NAME    READY   STATUS    RESTARTS   AGE
hello   1/1     Running   0          22s

$ kubectl describe pod hello | grep Image:
    Image:          gcr.io/google-samples/hello-app:2.0
</code></pre>
<ul>
<li>Changing the image of <code>container-1</code> on the deployed pod <code>hello</code>:</li>
</ul>
<pre><code>$ kubectl set image pod/hello container-1=gcr.io/google-samples/hello-app:1.0
pod/hello image updated

$ kubectl describe pod hello | grep Image:
    Image:          gcr.io/google-samples/hello-app:1.0
</code></pre>
<ul>
<li>Update images of all containers from deployment <code>hello-2</code>:</li>
</ul>
<pre><code>$ kubectl apply -f hello-2-deploy.yaml 
deployment.apps/hello-2 created

$ kubectl get deployment hello-2
NAME      READY   UP-TO-DATE   AVAILABLE   AGE
hello-2   3/3     3            3           6s

$ kubectl describe deploy hello-2 | grep Image:
    Image:        gcr.io/google-samples/hello-app:2.0

$ kubectl set image deployment hello-2 *=nginx:latest
deployment.apps/hello-2 image updated

$ kubectl describe deploy hello-2 | grep Image:
    Image:        nginx:latest
</code></pre>
<ul>
<li>All updates were made without modifying the original yaml file.</li>
</ul>
<p>If you have any questions let me know in the comments.</p>
