title: How to automatically restart pods when a new image ready
body: <p>I'm using K8s on GCP.</p>
  <p>Here is my deployment file</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: simpleapp-direct
    labels:
      app: simpleapp-direct
      role: backend
      stage: test
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: simpleapp-direct
        version: v0.0.1
    template:
      metadata:
        labels:
          app: simpleapp-direct
          version: v0.0.1
      spec:
        containers:
          - name: simpleapp-direct
            image: gcr.io/applive/simpleapp-direct:latest
            imagePullPolicy: Always
  </code></pre>
  <p>I first apply the deployment file with kubectl apply command</p>
  <pre><code>kubectl apply -f deployment.yaml 
  </code></pre>
  <p>The pods were created properly.</p>
  <p>I was expecting that every time I would push a new image with the tag latest, the pods would be automatically killed and restart using the new images.</p>
  <p>I tried the rollout command</p>
  <pre><code>kubectl rollout restart deploy simpleapp-direct
  </code></pre>
  <p>The pods restart as I wanted.</p>
  <p>However, I don't want to run this command every time there is a new latest build.
  How can I handle this situation ?.</p>
  <p>Thanks a lot</p>