To create a serverless application, you can create a YAML file and apply it using oc apply
.
You can create a YAML file by copying the following example:
Example Knative service YAML
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: hello
namespace: default
spec:
template:
spec:
containers:
- image: docker.io/openshift/hello-openshift
env:
- name: RESPONSE
value: "Hello Serverless!"
In this example, the YAML file is named hello-service.yaml
.
Procedure
-
Navigate to the directory where the hello-service.yaml
file is contained, and deploy the application by applying the YAML file:
$ oc apply --filename hello-service.yaml
After the service has been created and the application has been deployed, Knative will create a new immutable revision for this version of the application.
Knative will also perform network programming to create a route, ingress, service, and load balancer for your application, and will automatically scale your pods up and down based on traffic, including inactive Pods.