1

We are using Openshift Online Pro.

I am wanting to document / script how to review openshift deployment revisions on the commandline to facilitate rolling back to specific revisions. On the Web Console there is a "History" tab for the deployment that shows the revision number and how long ago it was actioned:

https://www.dropbox.com/s/12z4gmuqdzlnurg/File%2005-03-2018%2C%2007%2048%2053.jpeg?dl=0

If I used the command line oc get dc/backend it only shows the current revision.

Is there a way on the commandine to get deployment history data to make it easy to script a rollback tool that goes back to specific revisions?

(Note: I am aware that oc rollback backend will rollback the previous version but in testing there are corner cases where that won't help and we would need to skip back two or more versions.)

simbo1905
  • 6,321
  • 5
  • 58
  • 86

1 Answers1

3

Use:

oc describe dc/prometheus

It will show you something like:

Deployment #11 (latest):
    Name:       prometheus-11
    Created:    3 hours ago
    Status:     Complete
    Replicas:   1 current / 1 desired
    Selector:   app=prometheus,deployment=prometheus-11,deploymentconfig=prometheus
    Labels:     app=prometheus,openshift.io/deployment-config.name=prometheus
    Pods Status:    1 Running / 0 Waiting / 0 Succeeded / 0 Failed
Deployment #10:
    Created:    5 hours ago
    Status:     Complete
    Replicas:   0 current / 0 desired
Deployment #9:
    Created:    6 hours ago
    Status:     Complete
    Replicas:   0 current / 0 desired

For condensed version, use:

oc rollout history dc/prometheus

This will give you:

deploymentconfigs "prometheus"
REVISION    STATUS      CAUSE
9       Complete    manual change
10      Complete    manual change
11      Complete    manual change
Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134