Skip to main content

What is Apache Camel K?

Here we'll only be providing a brief introduction to Camel K along with some of the main benefits. For a full overview, architecture, and documentation, please refer to the official Camel K documentation.

camel-k-logo

Apache Camel K is a lightweight integration framework specifically designed for running serverless and microservice architectures natively in Kubernetes. It is built on top of Apache Camel which gives you access to hundreds of components to connect together virtually any of your data sources.

For more information regarding the Camel framework check out What is Apache Camel


How does Camel K work?#

Camel K works by taking your Camel DSL code and creating all of the necessary infrastrustucture to deploy your code as a microservice in Kubernetes. This is done with the help of the Camel K Operator, an application that follows the Kubernetes Operator design pattern.

The Camel K operator is the brains of Camel K and is responsible for many actions and creating several resources using the Kubernetes API. When you want to deploy an integration with Camel K, the operator will get to work by containerizing your integration code. Your containerized integration image will then get published to a container registry that you configure when installing Camel K.

You can configure Camel K to publish your container images to Docker, AWS, Azure, Google, and many similar registry providers!

The operator will then take care of building out your integration pod deployments and intelligently create additional resources like Services and Ingresses. This depends on the type of integration you're deploying. For example, if you deploy an integration that exposes an HTTP endpoint, the operator will automatically create a Service resource on your behalf, and if instructed to do so, will also create an Ingress to expose that service.

note

Most of the resources created by Camel K are CRD (Custom Resource Definitions), specific to the creation, deployment, and managment your Camel K integrations. These are not default resources offered by Kubernetes.

Below is a list of just some of the resources that the Camel K Operator will create for you when you provide a simple command to deploy an integration.

  • IntegrationKit: Describes the container image created by the Camel K Operator and container configurations
  • Integration: Contains your integration source code, resources, dependencies, configurations, etc.
  • Deployment: Describes a desired state of Pods and ReplicaSets
  • Service: Exposes an application running on a set of Pods as a network service
  • Ingress: Manages external access to the services in a cluster, typically HTTP
  • And more!
important

Of course, Camel K is doing far more than what is described above, but explaining each process is beyond the scope of this documentation. For a more in-depth explanation of each resource created and steps taken by the Camel K Operator, please refer to the official Camel K documentation](https://camel.apache.org/camel-k/latest/).


So why use Camel K?#

There are several reasons that make Camel K so powerful and useful for integration development in the cloud.

Code Focused#

With Camel K you only need to focus on thing: your integration code. You no longer need to spend time managing and worrying about the infrastructure surrounding your code. Simply create a file with your Camel DSL code, and run a single Camel K command: run, and watch as your integration is converted from just code into a fully deployed microservice handled automatically within Kubernetes.

Without Camel K if you were to try and deploy an integration as a containerized microservice, you'd most likely begin by

  • Setting up your coding environment (probably a Spring Boot application which can be easier said than done)
  • Ensure your dependencies are conflict-free
  • Coding your integration
  • Containerize your integration
  • Create your Kubernetes resources to handle your integration deployment

To create an fully managed integration deployed in Kubernetes there is just so much time spent things that are not your actual code. Camel K solves that problem by being code focused so that there's only one step you need to focus on and that's your actual integration code.

Built for the Cloud#

Camel K is intelligent enough to recognize when you need additional Kubernetes resources created on your behalf. For example, if you deploy an integration that exposes an HTTP endpoint, the operator will automatically create a Service resource on your behalf, and if instructed to do so, will also create an Ingress to expose that service.

Camel K's cloud intuition goes a step further with the example of using a Cron component within one of your integrations. Camel K can use the Kubernetes scheduler to trigger and activate your integration when required as defined by your cron expression. In other words your integration is only active when it needs to be. This can take your serverless architecture to a whole new level!

Lightning fast iterations#

With the help of the Camel K, applying updates to your integrations is fast and redeploying them in Kubernetes takes only moments. Updates can be applied to your integration routes by simply running the kamel run command with your updated code. Redeploying updates can be quite fast especially when your updates don't include the use of new components. This is because of Camel K's dependency management.

Intelligent dependency management#

Camel K uses a lazy load approach for including dependencies in your integration routes. Dependencies are only brought in when they are required by your integrations and Camel K automatically locates the associated libraries for you. This greatly reduces the risk of any dependency redundancies and version conflicts.

Built on Camel#

With Camel K you still get access to all of the benefits that come from using Camel. All the Camel components are available to you and all you need to provide is Camel DSL code which can be written in Java or Groovy, etc. Camel is a mature framework that is still receiving regular updates from a strong community of developers. Likewise, Camel K is also continously being improved upon and is only getting better with time.


An example of Camel K in action#

This example uses Kamel the CLI tool for Camel K which lets you fully manage all the integrations in your Kubernetes cluster.

Below we have an example route using Camel DSL and written in Groovy. The route simply prints the message Hello world from Camel K every 3 seconds.

from('timer:tick?period=3000')
.setBody().constant('Hello world from Camel K')
.to('log:info')

Save this route as a .groovy file, e.g. camel-k-example.groovy and run the following Camel K command

kamel run camel-k-example.groovy

That's it! All of the necessary Kubernetes resources will be built on your behalf and in just moments your code is fully deployed and managed in the cloud within Kubernetes.