<p>I have a .NET-core web application. This is deployed to an Azure Container Registry. I deploy this to my Azure Kubernetes Service using </p>

<blockquote>
  <p>kubectl apply -f testdeployment.yaml</p>
</blockquote>

<p>with the yaml-file below</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: myweb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myweb
  template:
    metadata:
      labels:
        app: myweb
    spec:
      containers:
      - name: myweb
        image: mycontainerregistry.azurecr.io/myweb:latest
        ports:
        - containerPort: 80
      imagePullSecrets:
        - name: my-registry-key</code></pre>
</div>
</div>
</p>

<p>This works splendid, but when I change some code, push new code to container and run the </p>

<blockquote>
  <p>kubectl apply -f testdeployment</p>
</blockquote>

<p>again, the AKS/website does not get updated, until I remove the deployment with</p>

<blockquote>
  <p>kubectl remove deployment myweb</p>
</blockquote>

<p><strong>What should I do to make it overwrite whatever is deployed?</strong> I would like to add something in my yaml-file. (Im trying to use this for continuous delivery in Azure DevOps). </p>

Cowborg
<p>I believe what you are looking for is imagePullPolicy. The default is ifNotPresent which means that the latest version will not be pulled.</p>

<p><a href="https://kubernetes.io/docs/concepts/containers/images/" rel="noreferrer">https://kubernetes.io/docs/concepts/containers/images/</a></p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: myweb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myweb
  template:
    metadata:
      labels:
        app: myweb
    spec:
      containers:
      - name: myweb
        image: mycontainerregistry.azurecr.io/myweb
        imagePullPolicy: Always
        ports:
        - containerPort: 80
      imagePullSecrets:
        - name: my-registry-key
</code></pre>

<p>To ensure that the pod is recreated, rather run:</p>

<pre><code>kubectl delete -f testdeployment &amp;&amp; kubectl apply -f testdeployment
</code></pre>
