2019-08-22 13:12:15 +01:00
// Module is included in the following assemblies:
//
2020-02-21 11:54:46 -06:00
// serverless/knative_cli/knative-cli.adoc
2019-08-22 13:12:15 +01:00
[id="basic-workflow_{context}"]
2020-02-21 11:54:46 -06:00
= Basic workflow using `kn`
2019-08-22 13:12:15 +01:00
Use this basic workflow to create, read, update, delete (CRUD) operations on a service. The following example deploys a link:https://github.com/knative/docs/tree/master/docs/serving/samples/hello-world/helloworld-go[simple Hello World service] that reads the environment variable `TARGET` and prints its output.
.Procedure
. Create a service in the `default` namespace from an image.
+
----
$ kn service create hello --image gcr.io/knative-samples/helloworld-go --env TARGET=Knative
2019-11-13 18:46:49 +05:30
Creating service 'hello' in namespace 'default':
2019-08-22 13:12:15 +01:00
2019-11-13 18:46:49 +05:30
0.085s The Route is still working to reflect the latest desired specification.
0.101s Configuration "hello" is waiting for a Revision to become ready.
11.590s ...
11.650s Ingress has not yet been reconciled.
11.726s Ready to serve.
2019-08-22 13:12:15 +01:00
2019-11-13 18:46:49 +05:30
Service 'hello' created with latest revision 'hello-gsdks-1' and URL:
2019-08-22 13:12:15 +01:00
http://hello.default.apps-crc.testing
----
. List the service.
+
----
$ kn service list
2019-11-13 18:46:49 +05:30
NAME URL LATEST AGE CONDITIONS READY REASON
hello http://hello.default.apps-crc.testing hello-gsdks-1 8m35s 3 OK / 3 True
2019-08-22 13:12:15 +01:00
----
. Check if the service is working by using the `curl` service endpoint command:
+
----
$ curl http://hello.default.apps-crc.testing
Hello Knative!
----
. Update the service.
+
----
$ kn service update hello --env TARGET=Kn
2019-11-13 18:46:49 +05:30
Updating Service 'hello' in namespace 'default':
10.136s Traffic is not yet migrated to the latest revision.
10.175s Ingress has not yet been reconciled.
10.348s Ready to serve.
2019-08-22 13:12:15 +01:00
2019-11-13 18:46:49 +05:30
Service 'hello' updated with latest revision 'hello-dghll-2' and URL:
http://hello.default.apps-crc.testing
2019-08-22 13:12:15 +01:00
----
+
The service's environment variable `TARGET` is now set to `Kn`.
. Describe the service.
+
----
$ kn service describe hello
2019-11-13 18:46:49 +05:30
Name: hello
Namespace: default
Age: 13m
URL: http://hello.default.apps-crc.testing
Address: http://hello.default.svc.cluster.local
2019-08-22 13:12:15 +01:00
2020-02-21 11:54:46 -06:00
Revisions:
2019-11-13 18:46:49 +05:30
100% @latest (hello-dghll-2) [2] (1m)
Image: gcr.io/knative-samples/helloworld-go (pinned to 5ea96b)
2020-02-21 11:54:46 -06:00
Conditions:
2019-08-22 13:12:15 +01:00
OK TYPE AGE REASON
2020-02-21 11:54:46 -06:00
++ Ready 1m
++ ConfigurationsReady 1m
++ RoutesReady 1m
2019-08-22 13:12:15 +01:00
----
. Delete the service.
+
----
$ kn service delete hello
Service 'hello' successfully deleted in namespace 'default'.
----
+
2019-11-13 21:01:15 +05:30
You can then verify that the `hello` service is deleted by attempting to `list` it.
2019-08-22 13:12:15 +01:00
+
----
$ kn service list hello
No services found.
----