Knative: Operator’s Handbook

Declarative vs imperative deployments

In this guide, we show how to deploy Knative services by writing YAML manifests and using kubectl apply command. These manifests can be stored in source control, such as git repositories.

Alternatively, Knative also offers a command-line tool called kn to create and manage Knative resources.

kn doesn't accept manifest files to read Service configuration from, everything is configured through command-line options, which can get lengthy.

Therefore, it's easier to use kn for first-time deployments or while playing with Knative. However, it's harder to use in your continuous deployment scripts.

For example, to create and update Knative Service using kn, first run:

$ kn service create hello \
    --image gcr.io/google-samples/hello-app:1.0

then run this to configure additional options (specified as –flags):

$ kn service update hello \
    --image gcr.io/google-samples/hello-app:2.0 \
    --max-scale 10 \
    --limits-memory 256Mi

Note: If you use Knative via Google Cloud Run: