1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-07 00:48:01 +01:00
Files
openshift-docs/modules/kn-service-apply.adoc
2023-10-30 10:13:25 -04:00

37 lines
1.3 KiB
Plaintext

// Module included in the following assemblies:
//
// * serverless/reference/kn-serving-ref.adoc
:_mod-docs-content-type: REFERENCE
[id="kn-service-apply_{context}"]
= Applying service declarations
You can declaratively configure a Knative service by using the `kn service apply` command. If the service does not exist it is created, otherwise the existing service is updated with the options that have been changed.
The `kn service apply` command is especially useful for shell scripts or in a continuous integration pipeline, where users typically want to fully specify the state of the service in a single command to declare the target state.
When using `kn service apply` you must provide the full configuration for the Knative service. This is different from the `kn service update` command, which only requires you to specify in the command the options that you want to update.
.Example commands
* Create a service:
+
[source,terminal]
----
$ kn service apply <service_name> --image <image>
----
* Add an environment variable to a service:
+
[source,terminal]
----
$ kn service apply <service_name> --image <image> --env <key>=<value>
----
* Read the service declaration from a JSON or YAML file:
+
[source,terminal]
----
$ kn service apply <service_name> -f <filename>
----