Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Build and deploy a serverless app with Camel K and Red Hat OpenShift Serverless 1.5.0 Tech Preview

<p>&nbsp;</p> <quillbot-extension-portal></quillbot-extension-portal>

April 24, 2020
Shailendra Kumar Singh
Related topics:
JavaKubernetesOperatorsServerless
Related products:
Red Hat OpenShift

    Red Hat OpenShift Serverless 1.5.0 (currently in tech preview) runs on Red Hat OpenShift Container Platform 4.3. It enables stateful, stateless, and serverless workloads to all operate on a single multi-cloud container platform. Apache Camel K is a lightweight integration platform that runs natively on Kubernetes. Camel K has serverless superpowers.

    In this article, I will show you how to use OpenShift Serverless and Camel K to create a serverless Java application that you can scale up or down on demand.

    Prerequisites

    The following three technologies need to be installed before beginning this exercise:

    • Red Hat OpenShift Container Platform 4.3
    • Red Hat OpenShift Serverless 1.5.0 Tech Preview
    • Apache Camel K Operator 1.0.0 RC1

    Other technologies used

    Knative Serving and Kamel (the Camel K CLI tool) will be installed as part of this exercise. Knative Serving on OpenShift Container Platform 4.3 builds on Kubernetes and Kourier to support deploying and serving serverless applications. It creates a set of custom resource definitions (CRDs) that are used to define and control the behavior of serverless workloads on an OpenShift cluster.

    The kamel CLI tool interacts with the Camel K integration framework, letting us configure our clusters and run integrations. Together with Knative Serving, this tool helps us build and deploy serverless applications and test our integration. The Kamel CLI will run locally to deploy your Camel route directly onto a Kubernetes or OpenShift cluster.

    Install OpenShift Serverless Operator

    OpenShift Serverless 1.5.0 Tech Preview is compatible with OpenShift Container Platform (OCP) 4.3. Assuming that you have OpenShift Container Platform 4.3 in your development environment, navigate to OCP's OperatorHub in the web console. Select OpenShift Serverless Operator from the list of available operators, then click Install, as shown in Figure 1.

    A screenshot of the OperatorHub and OpenShiff

    Before we continue, let's verify that we've installed OpenShift Serverless Operator:

    $ oc get csv -n openshift-operators
    

    You should receive the following confirmation:

    NAME                       DISPLAY                       VERSION REPLACES                    PHASE
    serverless-operator.v1.5.0 OpenShift Serverless Operator 1.5.0    serverless-operator.v1.4.1 Succeeded
    

    Install Knative Serving

    Next, we'll install Knative Serving, which we'll use to deploy our serverless application. The serving.yaml file creates a KnativeServing object in the knative-serving namespace:

    apiVersion: v1
    kind: Namespace
    metadata:
      name: knative-serving
    ---
    apiVersion: operator.knative.dev/v1alpha1
    kind: KnativeServing
    metadata:
      name: knative-serving
      namespace: knative-serving
    

    Enter the following command to apply the object:

    $ oc apply -f serving.yaml
    namespace/knative-serving created
    knativeserving.operator.knative.dev/knative-serving created
    

    Check for pods

    After you have installed the KnativeServing object, check for pods in the new knative-serving-ingress and knative-serving namespaces:

    $ oc get pods -n knative-serving-ingress
    

    You should see the following pods created in the knative-serving-ingress namespace:

    NAME                                    READY STATUS  RESTARTS AGE
    3scale-kourier-control-568f886865-fptx4 1/1   Running 0        27m
    3scale-kourier-gateway-785c6bd959-b2t6c 1/1   Running 0        27m
    

    Now, check the knative-serving namespace:

    NAME                            READY STATUS   RESTARTS AGE
    activator-7cc6dbf497-4zwdf      1/1   Running  0        27m
    autoscaler-798cfcd656-gqkdc     1/1   Running  0        27m
    autoscaler-hpa-5cb5655744-cxff2 1/1   Running  0        27m
    controller-55c7dd95f6-9qftj     1/1   Running  0        27m
    webhook-769f994744-mjsrr        1/1   Running  0        27m
    

    You should also see a new Serverless tab in OpenShift Container Platform's Administrator console, as shown in Figure 2.

    A screenshot of the new Serverless tab in the console.

    Install the Camel K Operator

    Next, we'll install the Camel K Operator. Start by creating a new project for it:

    $ oc new-project camelknative
    

    Install the Camel K Operator from OpenShift Container Platform's OperatorHub, as shown in Figure 3.

    A screenshot of the Camel K operator in the OperatorHub.

    Select the camelknative namespace, as shown in Figure 4.

    A screenshot of options to configure a new operator namespace.

    Verify the installation status:

    $ oc get csv -n camelknative
    

    You should get a confirmation that the installation was successful:

    NAME                        DISPLAY          VERSION   REPLACES                    PHASE
    camel-k-operator.v1.0.0-rc2 Camel K Operator 1.0.0-rc2 camel-k-operator.v1.0.0-rc1 Succeeded
    

    Before we can continue, we need the kamel binary, which we'll use to configure our cluster and run integrations on it.

    Install kamel

    Check for the most recent kamel release here. Once you've downloaded kamel, add it to your system path. On Linux, this would be /usr/bin/kamel.

    Verify that you installed kamel:

    $ kamel version
    Camel K Client 1.0.0-M4
    

    Our development environment is complete. Next, we'll try out a simple deployment.

    Deploy a Camel route

    We'll start with a simple route that uses Undertow for its HTTP consumer:

    // Sample.java
    import org.apache.camel.builder.RouteBuilder;
    
    public class Sample extends RouteBuilder {
    
       @Override
       public void configure() throws Exception {
               from("undertow:http://0.0.0.0:8080/test")
              .setBody(constant("{{env:CAMEL_SETBODY}}"))
              .log("Hello Camel-K");
       }
    }
    

    Run the following to build and deploy the Sample.java route:

    $ kamel run Sample.java --name sample --dependency camel-undertow --env CAMEL_SETBODY="Response received from POD : {{env:HOSTNAME}}"
    integration "sample" created
    

    Test the integration

    Now we'll test our integration. To start, make sure it's running:

    $ oc get it

    You should see the following confirmation:

    NAME      PHASE     KIT                        REPLICAS
    sample    Running   kit-bppjp84iis5hj6nb3vk0   0
    

    Next, we call our pods:

    $ oc get pods
    

    None of the pods has served a request, so the integration is currently scaled to zero:

    NAME                                       READY     STATUS      RESTARTS   AGE
    camel-k-kit-bppjp84iis5hj6nb3vk0-1-build   0/1       Completed   0          18m
    camel-k-operator-775dfccddf-5r7zg          1/1       Running     0          56m
    
    $ oc get deployment sample-4srfn-deployment
    NAME                      READY     UP-TO-DATE   AVAILABLE   AGE
    sample-4srfn-deployment   0/0       0            0           8m3s
    

    When we send a request to the application, it automatically scales to one:

    $ curl http://sample.camelknative.apps.shsinghocp43.lab.com/test
    Response received from POD : sample-4srfn-deployment-5dfbf746c5-dw8wr
    

    Call $ oc get pods again, and you should see the following:

    NAME                                       READY     STATUS      RESTARTS   AGE
    camel-k-kit-bppjp84iis5hj6nb3vk0-1-build   0/1       Completed   0          28m
    camel-k-operator-775dfccddf-5r7zg          1/1       Running     0          66m
    sample-4srfn-deployment-5dfbf746c5-dw8wr   2/2       Running     0          14s
    

    The sample integration has scaled to one:

    $ oc get it
    NAME      PHASE     KIT                        REPLICAS
    sample    Running   kit-bppjp84iis5hj6nb3vk0   1
    
    $ oc get deployment sample-4srfn-deployment
    NAME                      READY     UP-TO-DATE   AVAILABLE   AGE
    sample-4srfn-deployment   1/1       1            1           14m
    

    Once a pod is ideal (when no traffic is served by the application), it automatically scales down to zero:

    NAME                                       READY     STATUS      RESTARTS   AGE
    camel-k-kit-bppjp84iis5hj6nb3vk0-1-build   0/1       Completed   0          31m
    camel-k-operator-775dfccddf-5r7zg          1/1       Running     0          69m
    
    $ oc get it
    NAME      PHASE     KIT                        REPLICAS
    sample    Running   kit-bppjp84iis5hj6nb3vk0   0
    

    Delete the application

    When you're done testing the integration, you can use kamel to delete the simple route we created with Camel K:

    $ kamel delete sample
    Integration sample deleted
    

    Conclusion

    I hope this article has given you a quick start on developing serverless applications with OpenShift Serverless and Camel K. Note again that Red Hat OpenShift Serverless 1.5.0 is currently in tech preview.

    Last updated: February 5, 2024

    Recent Posts

    • MCP servers vs. skills: Choosing the right context for your AI

    • How to route external and local LLMs with Models-as-a-Service

    • Protect data offloaded to GPU-accelerated environments with OpenShift sandboxed containers

    • Case study: Measuring energy efficiency on the x64 platform

    • How to prevent AI inference stack silent failures

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.