mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
45 lines
1.7 KiB
Plaintext
45 lines
1.7 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * serverless/develop/serverless-applications.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="creating-serverless-apps-yaml_{context}"]
|
|
= Creating serverless applications using YAML
|
|
|
|
Creating Knative resources by using YAML files uses a declarative API, which enables you to describe applications declaratively and in a reproducible manner. To create a serverless application by using YAML, you must create a YAML file that defines a Knative `Service` object, then apply it by using `oc apply`.
|
|
|
|
After the service is created and the application is deployed, Knative creates an immutable revision for this version of the application. Knative also performs network programming to create a route, ingress, service, and load balancer for your application and automatically scales your pods up and down based on traffic.
|
|
|
|
.Prerequisites
|
|
|
|
* {ServerlessOperatorName} and Knative Serving are installed on your cluster.
|
|
* You have created a project or have access to a project with the appropriate roles and permissions to create applications and other workloads in {product-title}.
|
|
* Install the OpenShift CLI (`oc`).
|
|
|
|
.Procedure
|
|
|
|
. Create a YAML file containing the following sample code:
|
|
+
|
|
[source,yaml]
|
|
----
|
|
apiVersion: serving.knative.dev/v1
|
|
kind: Service
|
|
metadata:
|
|
name: event-delivery
|
|
namespace: default
|
|
spec:
|
|
template:
|
|
spec:
|
|
containers:
|
|
- image: quay.io/openshift-knative/knative-eventing-sources-event-display:latest
|
|
env:
|
|
- name: RESPONSE
|
|
value: "Hello Serverless!"
|
|
----
|
|
. Navigate to the directory where the YAML file is contained, and deploy the application by applying the YAML file:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc apply -f <filename>
|
|
----
|