<p>In <code>Dockerfile</code> I have mentioned volume like:</p>

<p><code>COPY src/ /var/www/html/</code> but somehow my code changes don't appear like it used to only with Docker. Unless I remove Pods, it does not appear. How to sync it?</p>

<p>I am using minikube.</p>

<p><strong>webserver.yaml</strong></p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: webserver
  labels:
    app: apache
spec:
  replicas: 3
  selector:
    matchLabels:
      app: apache
  template:
    metadata:
      labels:
        app: apache
    spec:
      containers:
      - name: php-apache
        image: learningk8s_website
        imagePullPolicy: Never
        ports:
        - containerPort: 80
</code></pre>

<p>When your container spec says:</p>

<pre><code>image: learningk8s_website
imagePullPolicy: Never
</code></pre>

<p>The second time you <code>kubectl apply</code> it, Kubernetes determines that it's exactly the same as the Deployment spec you already have and does nothing.  Even if it did generate new Pods, the server is highly likely to notice that it already has an image <code>learningk8s_website:latest</code> and won't pull a new one; indeed, you're explicitly telling Kubernetes not to.</p>

<p>The usual practice here is to include some unique identifier in the image name, such as a date stamp or commit hash.</p>

<pre><code>IMAGE=$REGISTRY/name/learningk8s_website:$(git rev-parse --short HEAD)
docker build -t "$IMAGE" .
docker push "$IMAGE"
</code></pre>

<p>You then need to make the corresponding change in the Deployment spec and <code>kubectl apply</code> it.  This will cause Kubernetes to notice that there is some change in the pod spec, create new pods with the new image, and destroy the old pods (in that order).  You may find a templating engine like <a href="https://helm.sh" rel="noreferrer">Helm</a> to be useful to make it easier to inject this value into the YAML.</p>
