Knative: Operator’s Handbook

Deployment readiness

In headless deployment tasks (such as CI/CD) you often need to know if the deployment succeeded.

However, when you deploy a Service with kubectl apply -f, the resource will be accepted, but you won't know if the application came up successfully and became ready.

You can use a procedure like the following to find if the latest deployed revision has succeeded:

  1. Deploy a Service:

    $ kubectl apply -f app.yaml
    
  2. Get the name of its latest created Revision:

    $ kubectl get -f app.yaml \
        --output=jsonpath='{.status.latestCreatedRevisionName}'
    
    hello-qsq6h
    
  3. Read Revision’s statuses to see if it has a type: Ready status periodically until it prints True (=Ready) or False (=Failed):

    $ kubectl get revision hello-qsq6h \
        --output=jsonpath="{.status.conditions[?(@.type=='Ready')].status}"
    True
    

    (If the readiness data is not yet prepared, it may print Unknown or empty string.)

  4. If there's a failure in previous step, you can find and print .reason of the type: Ready status:

    $ kubectl get revision hello-qsq6h \
        --output=jsonpath="{.status.conditions[?(@.type=='Ready')].reason}"
    ContainerMissing
    

To get this functionality out of the box, you need a tool or a script.