Upgrade image in a Deployment's pods

I have a Deployment with 3 replicas of a pod running the image 172.20.20.20:5000/my_app, that is located in my private registry.

I want do a rolling-update in the deployment when I push a new latest version of that image to my registry.

I push the new image this way (tag v3.0 to latest):

$ docker tag 172.20.20.20:5000/my_app:3.0 172.20.20.20:5000/my_app
$ docker push 172.20.20.20:5000/my_app

But nothing happens. Pods' images are not upgraded. This is my deployment definition:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: myapp-deployment
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: app
        image: 172.20.20.20:5000/my_app:latest
        ports:
        - containerPort: 8080

Is there a way to do that automatically? Should I run a command like rolling-update like in ReplicaControllers?


Solution 1:

There is no reason to pull latest image from Kubernetes point of view - it's already available on the system and pods are in the declared state. Use proper image tagging and you will be OK.

There are some workarounds based on imagePullPolicy: Always, but IMO I don't like them: https://stackoverflow.com/questions/33112789/how-do-i-force-kubernetes-to-re-pull-and-image