Knative Client
Knative Client is the command line utility aimed at enhancing the developer experience when doing Knative Serving and Eventing tasks.
At the end of this chapter you will be able to :
- 
Install Knative Client 
- 
Create, update, list and delete Knative service 
- 
Create, update, list and delete Knative service revisions 
- 
List Knative service routes 
| 
 | 
Install
Download the v1.8.1 Knative Client and add it to your PATH.
Verify installation by running the command:
kn versionThe above command will return a response like
Version:      v1.8.1
Build Date:   2021-12-14T12:31:50Z
Git Revision: 530841f1
Supported APIs:
* Serving
  - serving.knative.dev/v1 (knative-serving )
* Eventing
  - sources.knative.dev/v1 (knative-eventing )
  - eventing.knative.dev/v1 (knative-eventing )Knative Service Commands
Create Service
To create the greeter service using kn run the following command:
kn service create greeter \
  --image quay.io/rhdevelopers/knative-tutorial-greeter:quarkusA successful create of the greeter service should show a response like
Creating service 'greeter' in namespace 'knativetutorial':
  0.028s The Configuration is still working to reflect the latest desired specification.
  0.097s The Route is still working to reflect the latest desired specification.
  0.120s Configuration "greeter" is waiting for a Revision to become ready.
 12.075s ...
 12.128s Ingress has not yet been reconciled.
 12.223s unsuccessfully observed a new generation
 12.378s Ready to serve.
Service 'greeter' created to latest revision 'greeter-zyjrq-1' is available at URL:
http://greeter.knativetutorial.192.168.64.13.nip.ioList Knative Services
You can list the created services using the command:
kn service listNAME      URL                                                   LATEST            AGE   CONDITIONS   READY   REASON
greeter   http://greeter.knativetutorial.192.168.64.13.nip.io  greeter-sxnzq-1   10m   3 OK / 3     TrueInvoke Service
http $(kn service describe greeter -o url)export SVC_URL=`kubectl get rt greeter -o jsonpath={.status.url}` && \
http $SVC_URL| For all the examples in the tutorial we have configured the Ingress Controller and domain, which will use the domain suffix format like  If you have not using the Ingress controller configuration then the service has to be invoked like  | 
Update Knative Service
To create a new revision using kn is as easy as running another command.
In previous chapter we deployed a new revision of Knative service by adding an environment variable. Lets try do the same thing with kn to trigger a new deployment:
kn service update greeter --env "MESSAGE_PREFIX=Namaste"Updating Service 'greeter' in namespace 'knativetutorial':
  0.025s The Configuration is still working to reflect the latest desired specification.
  5.694s Traffic is not yet migrated to the latest revision.
  5.736s Ingress has not yet been reconciled.
  5.783s unsuccessfully observed a new generation
  5.971s Ready to serve.
Service 'greeter' updated to latest revision 'greeter-tmvxm-2' is available at URL:
http://greeter.knativetutorial.192.168.64.13.nip.ioNow Invoking the service will return me a response like:
Namaste  greeter => '9861675f8845' : 1Describe Knative Service
Sometime you wish you get the YAML of the Knative service to build a new service or to compare with with another service. kn makes it super easy for you to get the YAML:
kn service describe greeterThe describe should show you a short summary of your service :
Name:       greeter
Namespace:  knativetutorial
Age:        1m
URL:        http://greeter.knativetutorial.192.168.64.13.nip.io
Revisions:
  100%  @latest (greeter-twpgf-1) [1] (1m)
        Image:  quay.io/rhdevelopers/knative-tutorial-greeter:quarkus (pinned to 767e2f)
Conditions:
  OK TYPE                   AGE REASON
   Ready                  34s
   ConfigurationsReady    34s
  ++ RoutesReady            34sDescribe with verboisity
To list all the revisions as part of the describe command use:
kn service describe greeter -vName:         greeter
Namespace:    knativetutorial
Annotations:  serving.knative.dev/creator=minikube-user
              serving.knative.dev/lastModifier=minikube-user
Age:          14m
URL:          http://greeter.knativetutorial.192.168.64.13.nip.io
Cluster:      http://greeter.knativetutorial.svc.cluster.local
Revisions:
  100%  @latest (greeter-tmvxm-2) [2] (10m)
        Image:  quay.io/rhdevelopers/knative-tutorial-greeter:quarkus (pinned to 767e2f)
        Env:    MESSAGE_PREFIX=Namaste
     +  greeter-zyjrq-1 [1] (14m)
        Image:  quay.io/rhdevelopers/knative-tutorial-greeter:quarkus (pinned to 767e2f)
Conditions:
  OK TYPE                   AGE REASON
   Ready                  10m
   ConfigurationsReady    10m
  ++ RoutesReady            10mKnative Revision Commands
The kn revision commands are used to interact with revision(s) of Knative service.
List Revisions
You can list the available revisions of a Knative service using:
kn revision listNAME            SERVICE   TRAFFIC   TAGS   GENERATION   AGE     CONDITIONS   READY   REASON
greeter-00002   greeter   100%             2            3m37s   3 OK / 4     True
greeter-00001   greeter                    1            16m     3 OK / 4     TrueDescribe Revision
To get the details about a specific revision you can use the command:
kn revision describe greeter-00001Name:       greeter-00001
Namespace:  knativetutorial
Age:        17m
Image:      quay.io/rhdevelopers/knative-tutorial-greeter:quarkus (pinned to 767e2f)
Replicas:   0/0
Service:    greeter
Conditions:
  OK TYPE                  AGE REASON
  ++ Ready                 17m
  ++ ContainerHealthy      17m
  ++ ResourcesAvailable    17m
   I Active                16m NoTrafficKnative Route Commands
The kn revision commands are used to interact with route(s) of Knative service.
List Routes
kn route listNAME      URL                                                  READY
greeter   http://greeter.knativetutorial.192.168.64.13.nip.io   TrueDelete Knative Service
You can also use kn to delete the service that were created, to delete the service named greeter run the following command:
kn service delete greeterService 'greeter' successfully deleted in namespace 'knativetutorial'.Listing services you will notice that the greeter service no longer exists.