Lab Objective
In this lab, you will install and use OpenShift Serverless Functions on OpenShift Local.
You will create a simple Node.js serverless function, deploy it to OpenShift, invoke it using HTTP, verify the Knative resources created by OpenShift Serverless, and observe scale-to-zero behavior.
This lab is a modern replacement for the older โSetting up and using OpenShift Serverless Functionsโ article. The original article explains the concept, but this replacement provides a complete hands-on lab for students.
What You Will Learn
You will learn how to:
- Start OpenShift Local.
- Log in as both
developerandkubeadmin. - Install the OpenShift Serverless Operator.
- Install Knative Serving.
- Install and validate the Knative
knCLI. - Prepare an image registry for function images.
- Create a new project for functions.
- Create a Node.js function using
kn func. - Modify the function code.
- Deploy the function as a Knative Service.
- Invoke the function.
- Validate Knative Service, Revision, Configuration, and Route resources.
- Observe scale-to-zero and scale-from-zero.
- View function logs.
- Troubleshoot common OpenShift Serverless issues.
- Clean up the lab environment.
Lab Architecture
Developer Machine
|
| kn func create
| kn func deploy
| kn func invoke
v
OpenShift Local
|
v
OpenShift Serverless Operator
|
v
Knative Serving
|
v
Knative Service
|
v
Revision
|
v
Pod
|
v
Knative Route
|
v
Function URL
Code language: JavaScript (javascript)
What Is OpenShift Serverless?
OpenShift Serverless allows you to run applications and functions that automatically scale based on demand.
It is based on Knative.
In simple terms:
Normal Deployment:
Application pod usually keeps running.
Serverless Function:
Function pod starts when traffic arrives.
Function pod can scale down to zero when idle.
Code language: JavaScript (javascript)
What Is a Serverless Function?
A serverless function is a small piece of code that runs in response to a request or event.
Examples:
HTTP request
CloudEvent
Message from a queue
Kafka event
Webhook event
Code language: JavaScript (javascript)
In this beginner lab, you will use a simple HTTP function.
Important Concept: Function vs Deployment
| Area | Normal OpenShift Deployment | OpenShift Serverless Function |
|---|---|---|
| Main resource | Deployment | Knative Service |
| Scaling | Manual, HPA, or custom autoscaling | Automatic request-based scaling |
| Scale to zero | Not by default | Yes |
| Route handling | OpenShift Route | Knative Route |
| Build/deploy tool | oc, Git, pipelines, image deploy | kn func |
| Good for | Long-running apps | Event-driven or request-driven workloads |
Important Concept: Function vs Knative Service
A function is a developer workflow.
A Knative Service is the runtime resource created after the function is deployed.
Function source code
-> container image
-> Knative Service
-> Revision
-> Pod
-> URL
Code language: JavaScript (javascript)
When you run:
kn func deploy
OpenShift packages your function into a container image and deploys it as a Knative Service.
Important Lab Note: Admin and Student Responsibilities
This lab has two parts.
| Part | Who Runs It | Purpose |
|---|---|---|
| Admin setup | Instructor or cluster admin | Install OpenShift Serverless Operator and Knative Serving |
| Student lab | Developer user | Create, deploy, invoke, and observe a function |
A normal developer user cannot install cluster operators. The operator setup must be done by kubeadmin or another cluster administrator.
Part 1: Prerequisites
Required Software
You need:
- OpenShift Local installed.
crccommand available.occommand available.knCLI installed.- Podman or Docker installed.
- Browser access to OpenShift web console.
- Internet access from OpenShift Local.
- Red Hat pull secret configured for OpenShift Local.
- Enough CPU and memory for Serverless components.
Recommended OpenShift Local Resources
OpenShift Serverless needs more resources than a simple Deployment lab.
Recommended OpenShift Local configuration:
| Resource | Recommended |
|---|---|
| CPU | 6 cores |
| Memory | 16 GB |
| Disk | 50 GB |
Configure CRC before starting the cluster:
crc config set preset openshift
crc config set cpus 6
crc config set memory 16384
crc config set disk-size 50
Code language: JavaScript (javascript)
If CRC is already running, stop it first:
crc stop
Then start again after changing resources.
Part 2: Start OpenShift Local
Run:
crc version
Run setup:
crc setup
Start OpenShift Local:
crc start
View credentials:
crc console --credentials
Code language: JavaScript (javascript)
Open the console:
crc console
Code language: JavaScript (javascript)
Part 3: Configure the oc CLI
Run:
crc oc-env
On Linux or macOS:
eval $(crc oc-env)
Code language: JavaScript (javascript)
On Windows PowerShell, use the command printed by crc oc-env.
Log in as developer first:
oc login -u developer https://api.crc.testing:6443
Code language: JavaScript (javascript)
Verify:
oc whoami
Expected output:
developer
Now log in as kubeadmin for the admin setup section:
oc login -u kubeadmin https://api.crc.testing:6443
Code language: JavaScript (javascript)
Use the kubeadmin password from:
crc console --credentials
Code language: JavaScript (javascript)
Verify:
oc whoami
Expected output:
kubeadmin
Check the node:
oc get nodes
Code language: JavaScript (javascript)
Expected result:
crc-xxxxx-master-0 Ready
Part 4: Install the OpenShift Serverless Operator
This section must be done by kubeadmin or a cluster administrator.
You can install the Operator from the web console or CLI.
Option A: Install from the Web Console
- Log in to the OpenShift web console as
kubeadmin. - Switch to Administrator perspective.
- Go to Operators > OperatorHub.
- Search for:
OpenShift Serverless Operator
- Click the Operator.
- Click Install.
- Use these settings:
| Setting | Value |
|---|---|
| Installation mode | All namespaces on the cluster |
| Installed namespace | openshift-serverless |
| Update channel | stable |
| Approval strategy | Automatic |
- Click Install.
- Wait until the Operator status shows:
Succeeded
Option B: Install from CLI
Create the Operator subscription YAML:
cat <<'EOF' > serverless-operator.yaml
apiVersion: v1
kind: Namespace
metadata:
name: openshift-serverless
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: serverless-operators
namespace: openshift-serverless
spec: {}
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: serverless-operator
namespace: openshift-serverless
spec:
channel: stable
installPlanApproval: Automatic
name: serverless-operator
source: redhat-operators
sourceNamespace: openshift-marketplace
EOF
Code language: JavaScript (javascript)
Apply it:
oc apply -f serverless-operator.yaml
Code language: CSS (css)
Watch the installation:
oc get pods -n openshift-serverless
Code language: JavaScript (javascript)
Check ClusterServiceVersion status:
oc get csv -n openshift-serverless
Code language: JavaScript (javascript)
Wait until the CSV phase is:
Succeeded
You can watch it with:
watch oc get csv -n openshift-serverless
Code language: JavaScript (javascript)
If watch is not available, run this repeatedly:
oc get csv -n openshift-serverless
Code language: JavaScript (javascript)
Part 5: Install Knative Serving
OpenShift Serverless Operator alone is not enough. To run functions, you must install Knative Serving.
Knative Serving allows you to create Knative Services and serverless functions.
Option A: Install Knative Serving from Web Console
- Log in as
kubeadmin. - Switch to Administrator perspective.
- Go to Operators > Installed Operators.
- Select project:
knative-serving
If the project does not exist yet, create it from Home > Projects > Create Project.
- Click OpenShift Serverless Operator.
- Find Knative Serving under provided APIs.
- Click Create Knative Serving.
- Keep the default settings.
- Click Create.
Wait until the KnativeServing resource is ready.
Option B: Install Knative Serving from CLI
Create the knative-serving namespace and KnativeServing resource:
cat <<'EOF' > knative-serving.yaml
apiVersion: v1
kind: Namespace
metadata:
name: knative-serving
---
apiVersion: operator.knative.dev/v1beta1
kind: KnativeServing
metadata:
name: knative-serving
namespace: knative-serving
EOF
Code language: JavaScript (javascript)
Apply it:
oc apply -f knative-serving.yaml
Code language: CSS (css)
Verify the custom resource:
oc get knativeserving.operator.knative.dev knative-serving -n knative-serving
Code language: CSS (css)
Check Knative Serving conditions:
oc get knativeserving.operator.knative.dev knative-serving -n knative-serving \
--template='{{range .status.conditions}}{{printf "%s=%s\n" .type .status}}{{end}}'
Code language: PHP (php)
Expected result should show conditions with:
True
Code language: PHP (php)
Check pods:
oc get pods -n knative-serving
Code language: JavaScript (javascript)
You should see Knative Serving pods running.
Example components may include:
activator
autoscaler
controller
webhook
The exact pod names can vary by OpenShift Serverless version.
Part 6: Validate Serverless Installation
Run:
oc api-resources | grep -i knative
Check for Knative Service API:
oc api-resources | grep ksvc
Expected result should include:
services ksvc serving.knative.dev
Code language: CSS (css)
Check Knative Serving namespace:
oc get pods -n knative-serving
Code language: JavaScript (javascript)
Check OpenShift Serverless namespace:
oc get pods -n openshift-serverless
Code language: JavaScript (javascript)
If the Operator and Knative Serving pods are running, the platform setup is ready.
Part 7: Install and Validate the kn CLI
The kn CLI is the Knative command-line tool.
It is required for the kn func workflow.
Install from Web Console
- Open the OpenShift web console.
- Click the ? icon in the upper-right corner.
- Click Command Line Tools.
- Download the Knative CLI for your operating system.
- Extract the archive.
- Move the
knbinary into a directory on yourPATH.
On Linux or macOS, a typical location is:
/usr/local/bin
On Windows, put kn.exe in a folder included in your PATH.
Validate kn
Run:
kn version
Check that the function commands are available:
kn func --help
Expected result:
Available Commands:
build
create
deploy
invoke
run
delete
Code language: JavaScript (javascript)
The exact output may vary, but kn func should be recognized.
Part 8: Validate Podman or Docker
OpenShift Serverless Functions need a local container engine to build function images.
Podman is recommended for this lab.
Check Podman:
podman version
If you use Docker instead:
docker version
For macOS or Windows with Podman, make sure the Podman machine is running:
podman machine list
podman machine start
Code language: PHP (php)
If Podman or Docker is not working, kn func deploy will fail during the build step.
Part 9: Prepare an Image Registry
When you deploy a function, the function image must be pushed to a container image registry.
You have two options:
| Option | Best For |
|---|---|
| OpenShift internal registry | Local OpenShift lab |
| Quay.io or another external registry | Real team workflow or if internal registry is difficult |
For OpenShift Local classroom labs, use the OpenShift internal registry.
Option A: Use OpenShift Internal Registry
Log in as kubeadmin:
oc login -u kubeadmin https://api.crc.testing:6443
Code language: JavaScript (javascript)
Expose the default OpenShift image registry route:
oc patch configs.imageregistry.operator.openshift.io/cluster \
--type=merge \
-p '{"spec":{"defaultRoute":true}}'
Code language: JavaScript (javascript)
Wait for the default registry route:
oc get route default-route -n openshift-image-registry
Code language: JavaScript (javascript)
Save the registry hostname:
REGISTRY_HOST=$(oc get route default-route -n openshift-image-registry -o jsonpath='{.spec.host}')
echo "$REGISTRY_HOST"
Code language: PHP (php)
Log in to the registry with Podman:
podman login --tls-verify=false \
-u "$(oc whoami)" \
-p "$(oc whoami -t)" \
"$REGISTRY_HOST"
Code language: JavaScript (javascript)
If login succeeds, you are ready to push function images to the internal registry.
Option B: Use Quay.io
Use this option only if the OpenShift internal registry route does not work in your local environment.
Log in to Quay.io:
podman login quay.io
Code language: CSS (css)
When deploying the function later, use an image name such as:
quay.io/<your-quay-username>/lab14-hello-func:latest
Code language: HTML, XML (xml)
Replace <your-quay-username> with your actual Quay username.
Part 10: Create a Student Project
Log in as developer:
oc login -u developer https://api.crc.testing:6443
Code language: JavaScript (javascript)
Create a new project:
oc new-project lab14-serverless-functions
Code language: JavaScript (javascript)
Verify:
oc project
Expected output:
Using project "lab14-serverless-functions"
Code language: JavaScript (javascript)
Part 11: Create a Node.js Serverless Function
Create a function:
kn func create -l node -t http lab14-hello-func
Expected output:
Created node function in lab14-hello-func
Code language: JavaScript (javascript)
Go into the function directory:
cd lab14-hello-func
List the files:
ls -la
Expected files include:
func.yaml
index.js
package.json
README.md
test
Code language: CSS (css)
Part 12: Understand the Function Project
The function project contains:
| File or Directory | Purpose |
|---|---|
func.yaml | Function configuration |
index.js | Function source code |
package.json | Node.js dependencies and scripts |
README.md | Function documentation |
test/ | Unit and integration tests |
The most important files for this beginner lab are:
func.yaml
index.js
Code language: CSS (css)
Part 13: Replace the Function Code
Open index.js and replace the content with the following code.
cat <<'EOF' > index.js
const Function = {
handle: (context, body) => {
context.log.info('Lab 14 function was invoked');
return 'Hello from OpenShift Serverless Functions - Lab 14';
}
};
module.exports = Function;
EOF
Code language: JavaScript (javascript)
This function returns a simple text response.
Part 14: Review func.yaml
View the function configuration:
cat func.yaml
Code language: CSS (css)
You should see values such as:
name: lab14-hello-func
runtime: node
Code language: HTTP (http)
The exact content may vary depending on your kn version.
Do not manually change the file unless your instructor asks you to.
Part 15: Optional Local Run
You can run the function locally before deploying it.
This step requires Podman or Docker to work correctly.
Run:
kn func run
Open a second terminal and go into the same function directory:
cd lab14-hello-func
Invoke the local function:
kn func invoke
Expected response:
Hello from OpenShift Serverless Functions - Lab 14
Code language: JavaScript (javascript)
Stop the local function by pressing:
Ctrl + C
If local run does not work because of Podman or Docker networking, continue with cluster deployment.
Part 16: Deploy the Function to OpenShift
Make sure you are in the function directory:
pwd
Expected path should end with:
lab14-hello-func
Set the project:
oc project lab14-serverless-functions
Get the internal registry hostname if you are using the OpenShift internal registry:
REGISTRY_HOST=$(oc get route default-route -n openshift-image-registry -o jsonpath='{.spec.host}')
echo "$REGISTRY_HOST"
Code language: PHP (php)
Deploy the function:
kn func deploy -i "$REGISTRY_HOST/lab14-serverless-functions/lab14-hello-func:latest"
Code language: JavaScript (javascript)
Expected output should include:
Function deployed at:
Code language: JavaScript (javascript)
This command builds the function image, pushes it to the image registry, and deploys it as a Knative Service.
Quay.io Alternative
If you are using Quay.io instead of the OpenShift internal registry, run:
kn func deploy -i "quay.io/<your-quay-username>/lab14-hello-func:latest"
Code language: HTML, XML (xml)
Replace <your-quay-username> with your actual Quay username.
Part 17: Verify the Function Deployment
Check Knative Services:
oc get ksvc
Code language: JavaScript (javascript)
Expected output:
NAME URL LATESTCREATED LATESTREADY READY
lab14-hello-func http://lab14-hello-func-... lab14-hello-func-00001 lab14-hello-func-00001 True
Code language: JavaScript (javascript)
Check with kn:
kn service list
Code language: PHP (php)
Expected result should include:
lab14-hello-func
Check all related Knative resources:
oc get ksvc,revision,configuration,routes.serving.knative.dev
Code language: CSS (css)
You should see resources related to:
lab14-hello-func
Part 18: Get the Function URL
Get the function URL:
FUNC_URL=$(oc get ksvc lab14-hello-func -o jsonpath='{.status.url}')
echo "$FUNC_URL"
Code language: PHP (php)
Expected output:
http://lab14-hello-func-lab14-serverless-functions.apps-crc.testing
Code language: JavaScript (javascript)
The exact hostname may be different.
Part 19: Invoke the Function
Invoke using kn func:
kn func invoke
Expected response:
Hello from OpenShift Serverless Functions - Lab 14
Code language: JavaScript (javascript)
Invoke using curl:
curl -s "$FUNC_URL"
Code language: JavaScript (javascript)
Expected response:
Hello from OpenShift Serverless Functions - Lab 14
Code language: JavaScript (javascript)
If the first request is slow, that can be normal. A scaled-to-zero function may need a few seconds to start.
Part 20: View Function Logs
Check the Knative Service:
oc get ksvc lab14-hello-func
Code language: JavaScript (javascript)
Check pods:
oc get pods
Code language: JavaScript (javascript)
View logs from the function pod:
oc logs -l serving.knative.dev/service=lab14-hello-func
Expected log message:
Lab 14 function was invoked
Code language: JavaScript (javascript)
If no pod exists because the function scaled to zero, invoke the function again:
curl -s "$FUNC_URL"
Code language: JavaScript (javascript)
Then check logs again:
oc logs -l serving.knative.dev/service=lab14-hello-func
Part 21: Observe Scale-to-Zero
Knative Serving can scale a function down to zero pods when it is idle.
Run:
oc get pods -l serving.knative.dev/service=lab14-hello-func
Code language: JavaScript (javascript)
You should see a running pod shortly after invoking the function.
Now wait for a short idle period.
Run the command again:
oc get pods -l serving.knative.dev/service=lab14-hello-func
Code language: JavaScript (javascript)
After the function has been idle, the pod may disappear.
Expected result after scale-to-zero:
No resources found
The exact time can vary based on cluster configuration.
Part 22: Observe Scale-from-Zero
Invoke the function again:
curl -s "$FUNC_URL"
Code language: JavaScript (javascript)
Expected response:
Hello from OpenShift Serverless Functions - Lab 14
Code language: JavaScript (javascript)
Immediately check pods:
oc get pods -l serving.knative.dev/service=lab14-hello-func
Code language: JavaScript (javascript)
You should see a new pod created for the function.
This proves that the function can scale from zero when traffic arrives.
Part 23: Inspect the Knative Service
Describe the Knative Service:
oc describe ksvc lab14-hello-func
Look for:
URL
LatestCreatedRevisionName
LatestReadyRevisionName
Ready
RoutesReady
ConfigurationsReady
Check the latest revision:
oc get revision
Code language: JavaScript (javascript)
Check the Knative configuration:
oc get configuration
Code language: JavaScript (javascript)
Check the Knative route:
oc get routes.serving.knative.dev
Code language: CSS (css)
These resources are created and managed by Knative Serving.
Part 24: Update the Function
Modify the function response:
cat <<'EOF' > index.js
const Function = {
handle: (context, body) => {
context.log.info('Lab 14 function version 2 was invoked');
return 'Hello from OpenShift Serverless Functions - Lab 14 - Version 2';
}
};
module.exports = Function;
EOF
Code language: JavaScript (javascript)
Deploy again:
kn func deploy -i "$REGISTRY_HOST/lab14-serverless-functions/lab14-hello-func:latest"
Code language: JavaScript (javascript)
Invoke the function:
curl -s "$FUNC_URL"
Code language: JavaScript (javascript)
Expected response:
Hello from OpenShift Serverless Functions - Lab 14 - Version 2
Code language: JavaScript (javascript)
Check revisions:
oc get revision
Code language: JavaScript (javascript)
You should see more than one revision.
This shows that updating a function creates a new Knative revision.
Part 25: Validate from the Web Console
- Open the OpenShift web console.
- Log in as
developer. - Select project:
lab14-serverless-functions
- Switch to Developer perspective.
- Go to Topology.
- You should see:
lab14-hello-func
- Click the function.
- Check the Resources tab.
- Check pods, revisions, and routes if shown.
- Open the function URL from the console if available.
The web console layout can vary by OpenShift version, but the function should be visible as a serverless workload.
Part 26: Full Student Validation Script
Run this from the function directory:
oc project lab14-serverless-functions
echo "Checking Knative Service..."
oc get ksvc lab14-hello-func
echo "Checking URL..."
FUNC_URL=$(oc get ksvc lab14-hello-func -o jsonpath='{.status.url}')
echo "$FUNC_URL"
echo "Invoking function..."
curl -s "$FUNC_URL"
echo
echo "Checking Knative resources..."
oc get ksvc,revision,configuration,routes.serving.knative.dev
echo "Checking pods..."
oc get pods -l serving.knative.dev/service=lab14-hello-func
echo "Checking logs..."
oc logs -l serving.knative.dev/service=lab14-hello-func --tail=50
Code language: PHP (php)
Expected result:
- Knative Service exists.
- Function URL exists.
- Function returns a response.
- Revision exists.
- Configuration exists.
- Knative Route exists.
- Pod exists after invocation.
- Logs show invocation output.
Part 27: Troubleshooting
Problem 1: kn: command not found
Cause
The Knative CLI is not installed or not in your PATH.
Fix
Download kn from:
OpenShift web console > ? > Command Line Tools
Code language: JavaScript (javascript)
Move the binary to a directory in your PATH.
Verify:
kn version
Problem 2: kn func Is Not Recognized
Cause
You may have an older or incorrect kn binary.
Fix
Install the kn CLI version provided by your OpenShift Serverless installation.
Check:
kn func --help
If this fails, reinstall the CLI from the OpenShift web console Command Line Tools page.
Problem 3: OpenShift Serverless Operator Is Not Installed
Symptom
oc get pods -n openshift-serverless
Code language: JavaScript (javascript)
fails or shows no serverless operator pods.
Fix
Install the OpenShift Serverless Operator using OperatorHub or the CLI YAML from this lab.
Verify:
oc get csv -n openshift-serverless
Code language: JavaScript (javascript)
Expected phase:
Succeeded
Problem 4: Knative Serving Is Missing
Symptom
oc get ksvc
Code language: JavaScript (javascript)
returns an error such as:
the server doesn't have a resource type "ksvc"
Cause
Knative Serving is not installed.
Fix
Create the KnativeServing resource:
oc apply -f knative-serving.yaml
Code language: CSS (css)
Verify:
oc get pods -n knative-serving
oc api-resources | grep ksvc
Code language: JavaScript (javascript)
Problem 5: Function Build Fails
Possible Causes
- Podman or Docker is not running.
- Image registry login failed.
- Registry route is not exposed.
- TLS verification failed.
- Laptop does not have enough CPU or memory.
- Network/VPN blocks registry access.
Check
podman version
podman info
Check registry route:
oc get route default-route -n openshift-image-registry
Code language: JavaScript (javascript)
Check registry login:
REGISTRY_HOST=$(oc get route default-route -n openshift-image-registry -o jsonpath='{.spec.host}')
podman login --tls-verify=false \
-u "$(oc whoami)" \
-p "$(oc whoami -t)" \
"$REGISTRY_HOST"
Code language: PHP (php)
Try deploy again:
kn func deploy -i "$REGISTRY_HOST/lab14-serverless-functions/lab14-hello-func:latest"
Code language: JavaScript (javascript)
Problem 6: Function Deploy Fails with Registry Push Error
Cause
The function image cannot be pushed to the registry.
Fix Option 1: Re-login to OpenShift Registry
REGISTRY_HOST=$(oc get route default-route -n openshift-image-registry -o jsonpath='{.spec.host}')
podman login --tls-verify=false \
-u "$(oc whoami)" \
-p "$(oc whoami -t)" \
"$REGISTRY_HOST"
Code language: PHP (php)
Deploy again:
kn func deploy -i "$REGISTRY_HOST/lab14-serverless-functions/lab14-hello-func:latest"
Code language: JavaScript (javascript)
Fix Option 2: Use Quay.io
podman login quay.io
kn func deploy -i "quay.io/<your-quay-username>/lab14-hello-func:latest"
Code language: HTML, XML (xml)
Problem 7: Function URL Does Not Open
Check
oc get ksvc lab14-hello-func
oc describe ksvc lab14-hello-func
Code language: JavaScript (javascript)
Check URL:
oc get ksvc lab14-hello-func -o jsonpath='{.status.url}'
Code language: PHP (php)
Check Knative route:
oc get routes.serving.knative.dev
Code language: CSS (css)
Check pods:
oc get pods
Code language: JavaScript (javascript)
Invoke again:
curl -v "$FUNC_URL"
Code language: JavaScript (javascript)
If DNS fails on your laptop, check CRC status:
crc status
Problem 8: Function Returns Slowly on First Request
This can be normal.
If the function scaled to zero, the first request must start a new pod.
This is called:
scale-from-zero
Code language: JavaScript (javascript)
Second and later requests are usually faster while the pod is still running.
Problem 9: No Function Pod Is Running
This may be normal if the function scaled to zero.
Invoke the function:
curl -s "$FUNC_URL"
Code language: JavaScript (javascript)
Then check pods immediately:
oc get pods -l serving.knative.dev/service=lab14-hello-func
Code language: JavaScript (javascript)
Problem 10: Web Console Function Creation Is Not Available
The web console function workflow requires additional setup, including OpenShift Pipelines and function pipeline tasks.
For this lab, use the CLI workflow with:
kn func create
kn func deploy
kn func invoke
This is simpler and more reliable for beginner students.
Part 28: Cleanup Student Resources
Delete the function:
oc delete ksvc lab14-hello-func
Code language: JavaScript (javascript)
Or, from the function directory:
kn func delete
Code language: JavaScript (javascript)
Delete the project:
oc delete project lab14-serverless-functions
Code language: JavaScript (javascript)
Verify:
oc get project lab14-serverless-functions
Code language: JavaScript (javascript)
Expected result:
NotFound
Part 29: Optional Admin Cleanup
Only run this if the OpenShift Local cluster is used only for this lab.
Do not remove shared Serverless components from a classroom cluster unless the instructor confirms.
Log in as kubeadmin:
oc login -u kubeadmin https://api.crc.testing:6443
Code language: JavaScript (javascript)
Delete Knative Serving:
oc delete knativeserving.operator.knative.dev knative-serving -n knative-serving
Code language: CSS (css)
Delete Knative Serving namespace:
oc delete namespace knative-serving
Code language: JavaScript (javascript)
Delete the Serverless Operator subscription:
oc delete subscription serverless-operator -n openshift-serverless
Code language: JavaScript (javascript)
List CSVs:
oc get csv -n openshift-serverless
Code language: JavaScript (javascript)
Delete the Serverless CSV shown in the output if required:
oc delete csv <serverless-csv-name> -n openshift-serverless
Code language: HTML, XML (xml)
Delete the Serverless namespace:
oc delete namespace openshift-serverless
Code language: JavaScript (javascript)
Part 30: Lab Summary
In this lab, you installed and used OpenShift Serverless Functions.
You created:
| Resource | Purpose |
|---|---|
| OpenShift Serverless Operator | Manages Knative components |
| KnativeServing | Installs Knative Serving |
| Project | Isolated namespace for the function |
| Function source | Node.js function code |
| Container image | Built function runtime image |
| Knative Service | Serverless runtime resource |
| Revision | Immutable version of the function |
| Configuration | Knative configuration state |
| Knative Route | Function URL routing |
| Pod | Runtime instance created when traffic arrives |
You verified that:
- OpenShift Serverless is installed.
- Knative Serving is running.
kn funccan create functions.- A Node.js function can be deployed.
- The function can be invoked by URL.
- The function can scale to zero.
- The function can scale from zero when traffic arrives.
- Updating the function creates a new revision.
Part 31: Review Questions
Question 1
What is OpenShift Serverless based on?
Answer
Knative.
Question 2
Which OpenShift Serverless component is required to run functions?
Answer
Knative Serving.
Question 3
Which CLI command creates a function?
Answer
kn func create
Question 4
Which CLI command deploys a function?
Answer
kn func deploy
Question 5
Which CLI command invokes a function?
Answer
kn func invoke
Question 6
What OpenShift resource is created when a function is deployed?
Answer
A Knative Service.
Question 7
What command lists Knative Services?
Answer
oc get ksvc
Code language: JavaScript (javascript)
Question 8
What is scale-to-zero?
Answer
Scale-to-zero means the function pod is removed when the function is idle.
Question 9
What is scale-from-zero?
Answer
Scale-from-zero means a new function pod is created automatically when a request arrives.
Question 10
Why does the first request sometimes take longer?
Answer
Because the function may need to start from zero pods before it can serve the request.
Part 32: Instructor Notes
This lab intentionally uses the CLI-based kn func workflow instead of the web-console function creation workflow.
Reason:
The web-console function workflow requires additional setup such as OpenShift Pipelines and function-specific pipeline tasks. That is useful for an advanced lab, but it adds too much complexity for a first serverless functions lab.
Recommended follow-up labs:
- Create functions from the OpenShift web console.
- Install OpenShift Pipelines for function builds.
- Connect an event source to a function.
- Use Knative Eventing.
- Trigger functions from Kafka.
- Configure function environment variables.
- Use ConfigMaps and Secrets with functions.
- Configure function concurrency.
- Configure autoscaling.
- Configure custom domains and TLS.
- Observe serverless metrics.
- Deploy Quarkus, Python, Go, and TypeScript functions.
- Deploy serverless applications using GitOps.
Part 33: Instructor Pre-Validation Checklist
Before delivering this lab to students, run:
crc status
oc whoami
oc get nodes
Code language: JavaScript (javascript)
Validate Serverless Operator:
oc get csv -n openshift-serverless
Code language: JavaScript (javascript)
Validate Knative Serving:
oc get pods -n knative-serving
oc get knativeserving.operator.knative.dev knative-serving -n knative-serving \
--template='{{range .status.conditions}}{{printf "%s=%s\n" .type .status}}{{end}}'
Code language: PHP (php)
Validate CLI:
kn version
kn func --help
podman version
Validate registry route:
oc get route default-route -n openshift-image-registry
Code language: JavaScript (javascript)
Create a test function:
oc new-project lab14-validation
kn func create -l node -t http lab14-test-func
cd lab14-test-func
REGISTRY_HOST=$(oc get route default-route -n openshift-image-registry -o jsonpath='{.spec.host}')
kn func deploy -i "$REGISTRY_HOST/lab14-validation/lab14-test-func:latest"
FUNC_URL=$(oc get ksvc lab14-test-func -o jsonpath='{.status.url}')
curl -s "$FUNC_URL"
Code language: PHP (php)
Clean up:
cd ..
oc delete project lab14-validation
rm -rf lab14-test-func
Code language: JavaScript (javascript)
If the function deploys and responds successfully, the lab is ready for students.
Final Outcome
You have successfully completed OpenShift Lab 14.
You installed OpenShift Serverless, installed Knative Serving, created a Node.js serverless function, deployed it as a Knative Service, invoked it through a URL, checked the generated Knative resources, and observed serverless scale-to-zero behavior.
The final workflow is:
Function source code
-> kn func build/deploy
-> container image
-> Knative Service
-> Revision
-> Pod on demand
-> Function URL
-> scale to zero when idle
Code language: JavaScript (javascript)
This is one of the most important OpenShift developer workflows for event-driven and request-driven workloads.
Iโm a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at Cotocus. I share tech blog at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow , and SEO strategies at Wizbrand.
Do you want to learn Quantum Computing?
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at WIZBRAND
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals
The guide explains the deployment process for OpenShift Serverless Functions clearly, but it could also cover some production-oriented considerations. For workloads with unpredictable traffic patterns, tuning autoscaling behavior is important to balance resource efficiency against cold-start latency. Additionally, as serverless environments grow, having strong observability practicesโsuch as centralized logging, distributed tracing, and function-level metricsโbecomes essential for diagnosing failures and understanding event flows across services.