Write Kubernetes Native Application Using Camel K: Part 1
Join the DZone community and get the full member experience.Join For Free
Apache Camel K is integration framework based on ubiquitous Apache Camel. Camel K differs from Apache Camel, as Camel K is native to Kubernetes, while Apache Camel runs almost everywhere. But why Camel K is required? The following bullet points makes Camel K more favorable in Kubernetes or an OpenShift Environment:
- Low code and Quick deployment.
- Cloud Native Camel on Kubernetes
- Designed for Serverless and MicroService architecture.
- Exchange K-Native Eventing events.
I will try to write a series of Technology blogs on Camel K. This is the first one. This article would be simple but will cover important aspects.
Camel K provides a CLI tool, kamel, which can be run from Linux/Mac shell or Windows OS. It can be download from Camel K release page. It contains a binary named kamel that you should put into system path. For example, if you’re using Linux, you can put kamel in /usr/bin.
Step 1 : Firstly we have to install Camel-k operator with command "kamel install". This commands intall Camel-k operator and customer resources.
I have used Fedora 32 and minikube v1.9.2. So let us start actual work.
Step 2 : Deploy Camel K application.
Let us create a simple Camel K application in Java CamelkPoc.java.
Step 3 : Now, let us run the application in dev mode. In dev mode, we should not close the original terminal. That terminal which is running the application or integration will also undeploy as soon as it's closed. In dev mode, we can change integration at runtime.
Step 4: Let us now make changes to code at runtime.
Step 5 Camel K Resource Visualization: This application is running in dev mode, and any changes are reflected at runtime. The user or developer is only concerned with their application. Other details like Camel-k Operator and Custom Resource are abstracted away or hidden from the user. Some of these abstract components are described below.
Integration Platform (kubectl get ip): It is a one generic configuration for all the integrations. It is having information like maven's settings.xml from where the maven artifacts are installed. If we note below commands than we find that settings.xml is mounted as configmap camel-k-maven-settings.
Integration(kubectl get it): There is one integration for each of our application/integration installed. If we describe this integration than we will find that it contains the code(or camel route) details and also dependencies of application.
Step 6: Finally, we can close the terminal where we executed CamelkPoc.java in --dev mode. In production mode, we are going to run without --dev mode so that simply closing the terminal doesn't uninstall our integration.
Thanks so much for reading. I believe this article would have provided you insights about Camel-k and how it works. Stay tune for the next article in this series.
Opinions expressed by DZone contributors are their own.