{"id":50040,"date":"2025-07-11T03:34:07","date_gmt":"2025-07-11T03:34:07","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=50040"},"modified":"2025-07-12T05:56:29","modified_gmt":"2025-07-12T05:56:29","slug":"openshift-setting-up-and-using-openshift-serverless-functions","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/openshift-setting-up-and-using-openshift-serverless-functions\/","title":{"rendered":"Openshift: Lab 14 &#8211; Setting up and using OpenShift Serverless Functions"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>Manual &#8211; <a href=\"https:\/\/docs.redhat.com\/en\/documentation\/red_hat_openshift_serverless\/1.30\/html\/functions\/index\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.redhat.com\/en\/documentation\/red_hat_openshift_serverless\/1.30\/html\/functions\/index<\/a><\/p>\n\n\n\n<p><strong>OpenShift Serverless Function<\/strong> is a feature of Red Hat OpenShift that enables you to build, deploy, and manage <strong>event-driven serverless workloads<\/strong> using the Function-as-a-Service (FaaS) paradigm, directly on OpenShift. It is built on top of <strong>Knative<\/strong> (an open-source Kubernetes-based serverless framework), but provides a more developer-friendly and integrated experience for creating &#8220;functions&#8221;\u2014small, single-purpose pieces of code that run in response to events.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Key Points about OpenShift Serverless Function<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>What is a Serverless Function?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A <strong>serverless function<\/strong> is a small piece of code that is executed in response to an event (HTTP request, message in a queue, etc.).<\/li>\n\n\n\n<li>You don\u2019t manage the underlying servers; OpenShift\/Kubernetes automatically scales the function up or down (even to zero) based on demand.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>How does OpenShift Serverless Function work?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Functions<\/strong> are created using a CLI (<code>kn func<\/code> or <code>oc<\/code>) or the OpenShift web console.<\/li>\n\n\n\n<li>Functions can be written in languages like <strong>Node.js, Python, Go, Java, Quarkus, TypeScript, etc.<\/strong><\/li>\n\n\n\n<li>Code is packaged as a container image and deployed as a Knative Service.<\/li>\n\n\n\n<li>OpenShift automatically handles <strong>scaling, routing, and event integration<\/strong>.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong>Why use OpenShift Serverless Function?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Rapid development<\/strong>: Focus on writing business logic; the platform handles build, deployment, and scaling.<\/li>\n\n\n\n<li><strong>Event-driven<\/strong>: Functions can be triggered by events like HTTP requests, Kafka messages, or cloud events.<\/li>\n\n\n\n<li><strong>Efficient resource usage<\/strong>: Functions scale to zero when not in use, saving costs and resources.<\/li>\n\n\n\n<li><strong>Integrated developer experience<\/strong>: CLI and IDE tools help you scaffold, build, test, and deploy functions easily.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">4. <strong>How is it different from plain Knative?<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>OpenShift Serverless Function provides a <strong>streamlined developer workflow<\/strong> and <strong>templates<\/strong>, plus deeper integration with OpenShift features (e.g., pipelines, security, monitoring).<\/li>\n\n\n\n<li>Focuses on the <strong>function lifecycle<\/strong> (scaffolding, local development, automated builds) versus raw Knative, where you deal more with YAML and manual setup.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Typical Workflow<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Initialize a Function<\/strong>: <code>kn func create --runtime node --name hello-func<\/code><\/li>\n\n\n\n<li><strong>Develop Locally<\/strong>: Write your logic (e.g., <code>index.js<\/code> or <code>app.py<\/code>).<\/li>\n\n\n\n<li><strong>Build and Deploy<\/strong>: <code>kn func deploy<\/code>\n<ul class=\"wp-block-list\">\n<li>This builds the function, creates a container image, and deploys it as a Knative Service.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Trigger the Function<\/strong>: By HTTP request, event source, or via API gateway.<\/li>\n\n\n\n<li><strong>Auto-scaling<\/strong>: OpenShift will scale the function pods up\/down based on incoming events (can scale down to zero).<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Common Use Cases<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>API endpoints (microservices)<\/li>\n\n\n\n<li>Data transformation pipelines<\/li>\n\n\n\n<li>Event-driven automation (e.g., on new file upload, process file)<\/li>\n\n\n\n<li>Webhooks<\/li>\n\n\n\n<li>Lightweight background tasks<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Summary Table<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Feature<\/th><th>OpenShift Serverless Function<\/th><\/tr><\/thead><tbody><tr><td><strong>Underlying Tech<\/strong><\/td><td>Knative<\/td><\/tr><tr><td><strong>Languages<\/strong><\/td><td>Node.js, Python, Go, Java, etc.<\/td><\/tr><tr><td><strong>Trigger<\/strong><\/td><td>HTTP, Kafka, CloudEvents, etc.<\/td><\/tr><tr><td><strong>Scalability<\/strong><\/td><td>Auto, incl. scale to zero<\/td><\/tr><tr><td><strong>Deployment<\/strong><\/td><td>Via CLI or Web Console<\/td><\/tr><tr><td><strong>Integrations<\/strong><\/td><td>OpenShift Pipelines, Git, etc.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>References<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.openshift.com\/container-platform\/latest\/serverless\/functions\/serverless-functions-about.html\" target=\"_blank\" rel=\"noopener\">OpenShift Serverless Functions Official Docs<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/cloud.redhat.com\/blog\/openshift-serverless-functions-developer-preview\" target=\"_blank\" rel=\"noopener\">Red Hat Blog: Getting Started with OpenShift Functions<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/knative.dev\/docs\/functions\/\" target=\"_blank\" rel=\"noopener\">Knative Functions<\/a><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Manual &#8211; https:\/\/docs.redhat.com\/en\/documentation\/red_hat_openshift_serverless\/1.30\/html\/functions\/index OpenShift Serverless Function is a feature of Red Hat OpenShift that enables you to build, deploy, and manage event-driven serverless workloads using the Function-as-a-Service (FaaS) paradigm, directly&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5153],"tags":[],"class_list":["post-50040","post","type-post","status-publish","format-standard","hentry","category-openshift"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/50040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=50040"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/50040\/revisions"}],"predecessor-version":[{"id":50073,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/50040\/revisions\/50073"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=50040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=50040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=50040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}