Reputation: 509
I have in openshift a deployment-config that will poll changes in the image stream & starts a new deployment whenever a new image is available. I have a requirement where I need to restart/redeploy same tag from the imagestream. I can achieve this by the deploy tab in the deployments section of the project in the openshift web console. Was checking for the cli version of the same. I am new to openshift & I couldn't find it out. I checked out the oc rollout option but it basically deploys the latest tag, but I need the existing tag itself to be redeployed.
Upvotes: 0
Views: 2485
Reputation: 334
Actually, you had the right answer from the start. The correct way to do this is oc rollout latest dc/dcname. This is equivalent to hitting the 'deploy' button in the UI. You don't need to modify the deployment to 'trick' it into redeploying.
When it says 'latest', it means the latest version of your deploy config, and not the latest version of whatever image is being deployed.
From the man page for oc rollout latest: "Start a new rollout for a deployment config with the latest state from its triggers"
Upvotes: 1
Reputation: 4606
If I properly understood the question, you want to re-deploy and restart the pod(s) using an image from the image stream that has a specific image tag.
A way to achieve that can be to update the image tag for the image in the DeploymentConfig by setting it to the desired tag. The update will trigger an automatic re-deploy and pod(s) restart if the DeploymentConfig has trigger of type "ConfigChange" defined. To update the DeploymentConfig, edit it (oc edit dc/<deployment_config>
) or patch it.
Otherwise, just like in the OpenShift web console, to roll back to a specific deployment revision, run:
oc rollout undo dc/<deployment-name> --to-revision=<revision-number>
Obviously, you would need to know the revision number. Type in oc rollout undo --help
to read about some intricacies of the command.
EDIT: The "OpenShift way" to have the pod(s) automatically restarted when the image they are based on changes in the image stream, is to use ImageChange trigger. An example from the docs is [here][3].
This may be convenient during development but in general, though, it is a best practice to tag each image version differently and not to use latest
when referencing an image by its tag.
Upvotes: 0