<p>My deployment yaml file is bitbucket and CI/CD pipeline to build the image and deploy the container is in Azure DevOps. I am able to build and tag the image correctly i.e. with each pipeline run the image version is incremented by 1 e.g. 1.0.0, 1.0.1,1.0.2 ... There is no &quot;latest&quot; tag in this repository. How do I pass this image tag dynamically in the deployment.yml file so that kubectl deploy stage always picks the latest tagged image ?</p>
<p>my deployment file currently looks like:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: ubuntu-custom
  labels:
    app: ubuntu-custom
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ubuntu-custom
  template:
    metadata:
      labels:
        app: ubuntu-custom
    spec:
      containers:
      - name: ubuntu-custom
        image:  &lt;acr&gt;/ubuntu-custom:latest
        command: [&quot;sleep&quot;]
        args: [&quot;365d&quot;]
      imagePullSecrets:
      - name: acrsecret
</code></pre>
<p>I have tried to change the image to - image: acr/ubuntu-custom but I get the ImagePullBackOff error.</p>
<p>I am sure I need to pass the latest tag in the deployment file but I am not sure how I can achieve that.</p>

notageek27
<ol>
<li><p>Use sed command</p>
<p><code>sed 's/\\&lt;arc\\&gt;/${ACR_REPO_URL}/g' deploy.yaml</code></p>
</li>
<li><p>Use yq</p>
</li>
</ol>
<pre><code>    yq -i -y &quot;.spec. template.spec.containers.image = \\&quot;${ACR_REPO_URL}\\&quot;&quot; 
 deploy.yaml
</code></pre>
