# Basic Knative CLI Workflow

In this basic workflow we show the CRUD (create, read, update, delete) operations on applications, also called service in Knative. We use a well known simple Hello World service (opens new window) that reads the environment variable TARGET and prints it as output.

# Create an app from an image

$ kn service create hello --image gcr.io/knative-samples/helloworld-go --env TARGET=Knative

Creating service 'hello' in namespace 'demo':

  0.247s The Route is still working to reflect the latest desired specification.
  0.299s Configuration "hello" is waiting for a Revision to become ready.
 11.631s ...
 11.719s Ingress has not yet been reconciled.
 13.102s Ready to serve.

Service 'hello' created with latest revision 'hello-bxshg-1' and URL:
http://hello.demo.apps-crc.testing

# List apps / services

$ kn service list

NAME    URL                                LATEST          AGE     CONDITIONS   READY   REASON
hello   http://hello.demo.example.com   hello-dskww-1   2m42s   3 OK / 3     True

# Curl app endpoint

$ curl '-sS' '-H' 'Host: hello.demo.example.com' 'http://xxx.xx.xxx.xx   '

Hello Knative!

Where http://xxx.xx.xxx.xx is your Knative installation ingress that was created for you automatically.

# Update an app / service

$ kn service update hello --env TARGET=Kn

Updating Service 'hello' in namespace 'demo':

  3.559s Traffic is not yet migrated to the latest revision.
  3.624s Ingress has not yet been reconciled.
  3.770s Ready to serve.

Service 'hello' updated with latest revision 'hello-nhbwv-2' and URL:
http://hello.demo.example.com

The service's environment variable TARGET is now set to Kn.

# Describe an app / service

$ kn service describe hello

Name:       hello
Namespace:  demo
Age:        5m
URL:        http://hello.demo.example.com
Address:    http://hello.demo.svc.cluster.local

Revisions:
  100%  @latest (hello-nhbwv-2) [2] (50s)
        Image:  gcr.io/knative-samples/helloworld-go (pinned to 5ea96b)

Conditions:
  OK TYPE                   AGE REASON
  ++ Ready                  46s
  ++ ConfigurationsReady    46s
  ++ RoutesReady            46s

# Delete an app / service

$ kn service delete hello

Service 'hello' successfully deleted in namespace 'demo'.

You can then verify that the 'hello' service is deleted by trying to list it again.

$ kn service list hello

No services found.
Last Updated: 11/11/2021, 9:28:41 AM