mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 21:46:22 +01:00
96 lines
2.6 KiB
Plaintext
96 lines
2.6 KiB
Plaintext
// Module is included in the following assemblies:
|
|
//
|
|
// serverless/knative-client.adoc
|
|
|
|
[id="basic-workflow_{context}"]
|
|
= Basic workflow using Knative Client
|
|
|
|
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
|
|
Creating service 'hello' in namespace 'default':
|
|
|
|
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.
|
|
|
|
Service 'hello' created with latest revision 'hello-gsdks-1' and URL:
|
|
http://hello.default.apps-crc.testing
|
|
----
|
|
|
|
. List the service.
|
|
+
|
|
----
|
|
$ kn service list
|
|
NAME URL LATEST AGE CONDITIONS READY REASON
|
|
hello http://hello.default.apps-crc.testing hello-gsdks-1 8m35s 3 OK / 3 True
|
|
----
|
|
|
|
. 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
|
|
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.
|
|
|
|
Service 'hello' updated with latest revision 'hello-dghll-2' and URL:
|
|
http://hello.default.apps-crc.testing
|
|
----
|
|
+
|
|
The service's environment variable `TARGET` is now set to `Kn`.
|
|
|
|
|
|
. Describe the service.
|
|
+
|
|
----
|
|
$ kn service describe hello
|
|
Name: hello
|
|
Namespace: default
|
|
Age: 13m
|
|
URL: http://hello.default.apps-crc.testing
|
|
Address: http://hello.default.svc.cluster.local
|
|
|
|
Revisions:
|
|
100% @latest (hello-dghll-2) [2] (1m)
|
|
Image: gcr.io/knative-samples/helloworld-go (pinned to 5ea96b)
|
|
|
|
Conditions:
|
|
OK TYPE AGE REASON
|
|
++ Ready 1m
|
|
++ ConfigurationsReady 1m
|
|
++ RoutesReady 1m
|
|
----
|
|
|
|
. Delete the service.
|
|
+
|
|
----
|
|
$ kn service delete hello
|
|
Service 'hello' successfully deleted in namespace 'default'.
|
|
----
|
|
+
|
|
You can then verify that the `hello` service is deleted by attempting to `list` it.
|
|
+
|
|
----
|
|
$ kn service list hello
|
|
No services found.
|
|
----
|