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 an API with Camel K on Red Hat OpenShift

April 25, 2019
Abdellatif Bouchama
Related topics:
ContainersKubernetesServerless
Related products:
Red Hat OpenShift

    With the growing number of APIs and microservices, the time given to creating and integrating them has become shorter and shorter. That's why we need an integration framework with tooling to quickly build an API and include capabilities for a full API life cycle. Camel K lets you build and deploy your API on Kubernetes or Red Hat OpenShift in less than a second. Unbelievable, isn't it?

    For those who are not familiar with it, Camel K is a subproject of Apache Camel with the target of building a lightweight runtime for running integration code directly on cloud platforms like Kubernetes and Red Hat OpenShift. It was inspired by serverless principles, and it will also target Knative shortly. The article by Nicola Ferraro will give you a good introduction.

    In this article, I'll show how to build an API with Camel K. For that, we will start first by designing our API using Apicurio Studio, which is based on the OpenAPI standard, and then we will provide the OpenAPI standard document to Camel K in order to implement the API and deploy it to Red Hat OpenShift.

    Design your API in Apicurio

    Apicurio is a web-based open source tool for designing based on the OpenAPI specification. Go to https://www.apicur.io/, then you can start by clicking on Create New API.

    Essentially, you need to:

    • Create the API
    • Create the data definitions
    • Add Paths, and define parameters, operations, and return responses to the path

    For each operation (GET, POST), you should configure the Operation ID. This field is used by Camel K at the build of the REST route in order to redirect this request to a direct endpoint with the same name as the Operation ID. That means your integration routes should start from a direct endpoint (like direct://getCustomer, direct://createCustomer) in order to apply the integration patterns and process those REST requests:

    Once you have finished the design of your API, download as a JSON file your API based on OpenAPI v2 specification. Here's an example of the OpenAPI standard specification of a CustomerAPI.

    Build your API using Camel K

    To start using Camel K, you need the kamel binary, which can be used to both configure the cluster and run integrations. Refer to the release page for latest version of the kamel tool.

    Once you have the kamel binary, log into your cluster using the standard oc (OpenShift) or kubectl (Kubernetes) client tool and execute the following command to install Camel K:

    kamel install

    At that point, you have just to develop your integration routes in the multiple languages supported by Camel K. In my example, CamelK-customerAPI, I use plain XML: customer-api.xml.

    You are ready now to build and to deploy your API:

    git clone https://github.com/abouchama/CamelK-customerAPI.git
    cd CamelK-customerAPI
    kamel run --dev --name customers --dependency camel-undertow --property camel.rest.port=8080 --open-api customer-api.json customer-api.xml

    You can check the status of your integration by running the following command:

    oc get it
    NAME      PHASE   CONTEXT
    customers Running  ctx-biq59ca78n55k4851cjg

    Logs show:

    Your first API was built and deployed on Red Hat OpenShift

    Congratulations! Your first API was built and deployed on Red Hat OpenShift in less than one second, as you can see from the last line of the log.

    Tips

    By setting the logging level to DEBUG, you can see the print of the rests routes converted from the provided OpenAPI specification in the parameter --open-api:

    kamel run --dev --name customers --dependency camel-undertow --property camel.rest.port=8080 --open-api customer-api.json --logging-level org.apache.camel.k=DEBUG customer-api.xml

    Camel K routes with Hawtio

    To monitor your Camel K routes with Hawtio, simply enable the jolokia trait (-t jolokia.enabled=true), and the button Open Java Console will appear. For monitoring with Prometheus, you can simply enable the prometheus trait (-t prometheus.enabled=true):

    kamel run --dev --name customers --dependency camel-undertow --property camel.rest.port=8080 -t jolokia.enabled=true -t prometheus.enabled=true -t prometheus.service-monitor=false --open-api customer-api.json --logging-level org.apache.camel.k=DEBUG customer-api.xml

    Thanks for reading, and I hope that you enjoyed this article.

    The video below walks through what I've covered in this article:

    Last updated: August 28, 2023

    Recent Posts

    • 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

    • Preventing GPU waste: A guide to JIT checkpointing with Kubeflow Trainer on OpenShift AI

    • How to manage TLS certificates used by OpenShift GitOps operator

    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.