Docker image check before deploying to Kubernetes

12/17/2017

Assume I have a deployment/Pod with lets say a name "xyz" . I would like to check if this Pod has a specific image. If this image is different from what I have recently pulled from the docker registry only then deploy. Otherwise don't deploy. This is assuming that the tags are not updated. any ideas appreciated.

-- sbolla
docker
kubernetes

1 Answer

12/17/2017

Check this out this thread here is based on rolling update mechanism. Or directly set using the command line tool as kubectl,

$ kubectl set image deployment/auth-deployment auth=auth:2.1.0

Then you can simply check the status and deployment respectively to get the change by the above rollout. Details is in the link of comment given by Genti Saliu.

Note that a rollout process will trigger only and only if deployment's pod template is changed i.e. .spec.template is changed. Using the above set command will not guarantee a uptime until the rollout process is complete. So, it's just user in your dev environment.

For no downtime you have have to use the proper strategy as one below,

minReadySeconds: 7
strategy:
  type: RollingUpdate
  rollingUpdate:
    maxSurge: 1
    maxUnavailable: 1

As long as the maxUnavailable is set to zero, no existing pod will be replaced until the new pod was instantiated after minReadySeconds time over. This will not give any downtime. Hope this helps.

-- mohan08p
Source: StackOverflow