Knative: Operator’s Handbook

Finding the latest ready Revision

If you are trying to automate releases and traffic splitting as described in (example), you might need an automated way of finding the latest Revision that's in “Ready” state.

You can then use the Revision’s name in a your release script that prepares your traffic splitting rules.

Assume you have these Revisions of your Knative Service:

$ kubectl get revision --selector serving.knative.dev/service=hello

NAME        SERVICE NAME   GENERATION   READY   REASON
hello-001   hello-001      1            True
hello-002   hello-002      2            True
hello-003                  3            False   ContainerMissing

You can use the following small command to locate hello-002, which is the latest “ready” Revision:

$ kubectl get ksvc hello \
    --output=jsonpath='{.status.latestReadyRevisionName}'

hello-002

To find the “last deployed” Revision, use:

$ kubectl get ksvc hello \
    --output=jsonpath='{.status.latestCreatedRevisionName}'

hello-003