<p>I have created this very basic application (myapp.yml):</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: myapp
  labels:
    app: myapp
spec:
  type: LoadBalancer
  ports:
  - port: 5035
    targetPort: 5035
    protocol: TCP
    name: http
  selector:
    app: myapp
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-deployment
  labels:
    app: myapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: monapp
        image: xxxxxxx.container-registry.ovh.net/private/myimage
        ports:
        - containerPort: 5035
      imagePullSecrets:
      - name: regcred
</code></pre>

<p>When i want to update my application, i push a new image on the repository.</p>

<p>I order to ask kubernetes to download this new image on pods, i run:</p>

<pre><code>kubectl rollout restart deployment/myapp-deployment
</code></pre>

<p>Is there a way for kubernetes to automaticly detect a new version of the image is present on the repository and auto update pods without having to launch kubectl rollout ?</p>

<p>Thanks</p>

Bob5421
<p>Kubernetes natively does not have this functionality.You can use <a href="https://github.com/GoogleContainerTools/skaffold" rel="nofollow noreferrer">Skaffold</a>, which automatically builds the image, pushes it the image registry and updates the corresponding pods/controllers. It can even watch for code changes and rebuild the image as soon as changes are saved with skaffold dev command. This only requires adding a simple skaffold.yaml that specifies the image on the registry and path to the Kubernetes manifests. This workflow is described in details in the <a href="https://skaffold.dev/docs/install/" rel="nofollow noreferrer">Getting Started guide</a>.</p>

<p>Edit: You can configure it with gitlab as below:</p>

<pre><code>services:
  - docker:dind

stages:
  - build

variables:
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: ""
  DOCKER_HOST: tcp://docker:2375
build:
  image:
    name: gcr.io/k8s-skaffold/skaffold:latest
  stage: build
  before_script:
    - docker info
  script:
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    - skaffold run
  only:
    - master
</code></pre>
