How to rolling update deployment in kubernetes?

4/10/2017
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: test
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app:  test
    spec:
      containers:
      - name:  test
        image: xxx:latest 
        ports:
        - containerPort: 80
        imagePullPolicy: Always
      imagePullSecrets:
      - name: aaaa

I use the tag "latest". When I update the image,and the new image is still "latest". When I "kubectl set image deployments/test test=xxx:latest",nothing happend. What should I do?

-- zeroten
kubernetes

2 Answers

4/10/2017

Rolling update depends on docker image tags. If you're using the latest tag in your deployment, you need to cut a new image with a new version.

The deployment resource can't determine if the images has changed if you're always using the latest tag. As far as k8s is concerned, you're already running an image with the tag latest, so it doesn't have anything to do.

It's highly recommended not to use latest for deployments for this reason. You'll have a much easier time if you version your docker images correctly.

-- jaxxstorm
Source: StackOverflow

4/10/2017

a RollingUpdate is always triggered when the PodTemplateSpec under template is changed.

While using the :latest tag is not suggested it can still work when using imagePullPolicy: Always and a label which is changed with every image adjustment. Sth like this:

kubectl patch deployment test -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\"‌​:\"$(date +%s)\"}}}}}"
-- pagid
Source: StackOverflow