0

Right now our DC (deployment config) has this hardcoded it it:

/// dc.yaml

 image: containers.nabisco.com/cdt-org/cdt-dev:latest

then we roll out the dc with:

$ oc rollout latest dc/cdtcae-prod-deployment

however one problem I am noticing is that sometimes the "latest" tag refers to an old one and the newer one doesn't get pulled in - might be a bug with OpenShift or Kubernetes or what not.

we want to use git commit hashes to uniquely identify deployments, for the moment.

My question is - is there a way to override / update the image: line above, using the command line, so this line:

 image: containers.nabisco.com/cdt-org/cdt-dev:latest

would get overriden by something like this:

oc rollout --tag="$my_git_commit_hash" dc/cdtcae-prod-deployment
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
  • 1
    `image: containers.nabisco.com/cdt-org/cdt-dev:__TAG__` and then `sed -i 's/__TAG__/$my_git_commit_hash/' dc.yaml && ` – bits Apr 11 '18 at 23:35
  • yeah I knew there had to be right way to do this, that didn't involve what you rightly suggested. I added an answer, I think this is the way to do it. – Alexander Mills Apr 11 '18 at 23:48
  • There is the ``oc set image`` command. Bigger question is whether you are using an ``ImageStream`` and so also using a ``ImageChange`` trigger in the deployment configuration. Using these provides more flexibility on being able to update the image being used by a deployment, than the deployment configuration referencing an image in a remote registry directly. – Graham Dumpleton Apr 12 '18 at 00:37

1 Answers1

0

I heard that the best option would be to use the following setting in your yaml DC config:

 imagePullPolicy: "Always"

then you can just hard code some unique value

image: containers.nabisco.com/cdt-org/cdt-dev:foobarbaz

and it will always pull the latest one, instead of using the cache.

Alexander Mills
  • 90,741
  • 139
  • 482
  • 817