mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 21:46:22 +01:00
164 lines
3.0 KiB
Plaintext
164 lines
3.0 KiB
Plaintext
// Module is included in the following assemblies:
|
|
//
|
|
// serverless/knative_cli/knative-cli.adoc
|
|
|
|
[id="basic-workflow_{context}"]
|
|
= Basic workflow using `kn`
|
|
|
|
The following basic workflow deploys a simple `hello` service that reads the environment variable `RESPONSE` and prints its output.
|
|
|
|
You can use this guide as a reference to perform create, read, update, and delete (CRUD) operations on a service.
|
|
|
|
.Procedure
|
|
|
|
. Create a service in the `default` namespace from an image:
|
|
+
|
|
|
|
[source,terminal]
|
|
----
|
|
$ kn service create hello --image docker.io/openshift/hello-openshift --env RESPONSE="Hello Serverless!"
|
|
----
|
|
|
|
+
|
|
.Example output
|
|
+
|
|
|
|
[source,terminal]
|
|
----
|
|
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:
|
|
+
|
|
|
|
[source,terminal]
|
|
----
|
|
$ kn service list
|
|
----
|
|
|
|
+
|
|
.Example output
|
|
+
|
|
|
|
[source,terminal]
|
|
----
|
|
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:
|
|
+
|
|
|
|
[source,terminal]
|
|
----
|
|
$ curl http://hello-default.apps-crc.testing
|
|
----
|
|
|
|
+
|
|
.Example output
|
|
+
|
|
|
|
[source,terminal]
|
|
----
|
|
Hello Serverless!
|
|
----
|
|
|
|
. Update the service:
|
|
+
|
|
|
|
[source,terminal]
|
|
----
|
|
$ kn service update hello --env RESPONSE="Hello OpenShift!"
|
|
----
|
|
|
|
+
|
|
.Example output
|
|
+
|
|
|
|
[source,terminal]
|
|
----
|
|
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 `RESPONSE` is now set to "Hello OpenShift!".
|
|
|
|
. Describe the service.
|
|
+
|
|
|
|
[source,terminal]
|
|
----
|
|
$ kn service describe hello
|
|
----
|
|
|
|
+
|
|
.Example output
|
|
+
|
|
|
|
[source,terminal]
|
|
----
|
|
Name: hello
|
|
Namespace: default
|
|
Age: 13m
|
|
URL: http://hello-default.apps-crc.testing
|
|
|
|
Revisions:
|
|
100% @latest (hello-dghll-2) [2] (1m)
|
|
Image: docker.io/openshift/hello-openshift (pinned to 5ea96b)
|
|
|
|
Conditions:
|
|
OK TYPE AGE REASON
|
|
++ Ready 1m
|
|
++ ConfigurationsReady 1m
|
|
++ RoutesReady 1m
|
|
----
|
|
|
|
. Delete the service:
|
|
+
|
|
|
|
[source,terminal]
|
|
----
|
|
$ kn service delete hello
|
|
----
|
|
|
|
+
|
|
.Example output
|
|
+
|
|
|
|
[source,terminal]
|
|
----
|
|
Service 'hello' successfully deleted in namespace 'default'.
|
|
----
|
|
|
|
. Verify that the `hello` service is deleted by attempting to `list` it:
|
|
+
|
|
|
|
[source,terminal]
|
|
----
|
|
$ kn service list hello
|
|
----
|
|
|
|
+
|
|
.Example output
|
|
+
|
|
|
|
[source,terminal]
|
|
----
|
|
No services found.
|
|
----
|