{"id":22611272,"url":"https://github.com/bzdgn/camel-k-introduction","last_synced_at":"2025-06-28T08:34:17.984Z","repository":{"id":81112546,"uuid":"371315037","full_name":"bzdgn/camel-k-introduction","owner":"bzdgn","description":"An Introduction with examples for Apache Camel K on MiniKube","archived":false,"fork":false,"pushed_at":"2021-05-27T20:47:20.000Z","size":8,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T08:29:32.150Z","etag":null,"topics":["apache-camel","camel-k","eip","enterprise-integration-patterns","java","kubernetes","kubernetes-native","middleware","minikube"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bzdgn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-05-27T09:17:19.000Z","updated_at":"2023-02-19T22:27:07.000Z","dependencies_parsed_at":"2023-09-24T08:26:39.731Z","dependency_job_id":null,"html_url":"https://github.com/bzdgn/camel-k-introduction","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bzdgn/camel-k-introduction","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bzdgn%2Fcamel-k-introduction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bzdgn%2Fcamel-k-introduction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bzdgn%2Fcamel-k-introduction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bzdgn%2Fcamel-k-introduction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bzdgn","download_url":"https://codeload.github.com/bzdgn/camel-k-introduction/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bzdgn%2Fcamel-k-introduction/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262401860,"owners_count":23305615,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache-camel","camel-k","eip","enterprise-integration-patterns","java","kubernetes","kubernetes-native","middleware","minikube"],"created_at":"2024-12-08T16:10:05.937Z","updated_at":"2025-06-28T08:34:17.977Z","avatar_url":"https://github.com/bzdgn.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"TOC\n---\n- [0  Introduction](#0-introduction) \u003cbr/\u003e\n- [1  Setup](#1-setup) \u003cbr/\u003e\n  * [1-a- MiniKube](#1-a-minikube) \u003cbr/\u003e\n  * [1-b- Camel-K Client](#1-b-camel-k-client) \u003cbr/\u003e\n- [2  Running An Integration Demo](#2-running-an-integration-demo) \u003cbr/\u003e\n- [3  Language Support](#3-language-support) \u003cbr/\u003e\n- [4  Developer Mode](#4-developer-mode) \u003cbr/\u003e\n- [5  A Rest API Example](#5-a-rest-api-example) \u003cbr/\u003e\n- [6  Final Words](#6-final-words) \u003cbr/\u003e\n- [7  Further Reading](#7-further-reading) \u003cbr/\u003e\n\n 0 Introduction\n---------------\n\nApache Camel is an integration framework that helps us to implement Enterprise Integration Patterns easily. Kubernetes on the other hand is not about building software development, but system for automating deployment and management of containerized applications. So, when we build an integration application with using Apache Camel and then deploy it in a Kubernetes environment, some of the tasks that we do is just the same or mostly similar to any other project. We start with a boilerplate code, write scripts and setup configuration to run it on kubernetes based environment.\n\nThe thing is, using apache maven as a build tool as an example, we start adding similar dependencies to the pom file, codewise, boilerplate part is almost starts the same with any other project. We copy and paste it as a start, or copy and update it. Also, we need to setup configuration on our kubernetes platform, make an image, write config maps, do configuration/dev ops stuff. They start mostly the same. So, what happens if we just want to make a simple route from and ftp endpoint, which polls file and put it to some folder? Actually our code will just be a simple route, using quartz, polling it from an ftp endpoint, and routing the received files to the target folder, a simple cron job. If we have a need to create a dozen of simple routes, cron jobs like these, everytime we create a project, we need to copy all the boilerplate code, the deployment scripts, configurations. That's where Camel K can help. It runs natively on Kubernetes, thus, we don't need to deal with writing the boilerplate code and excessive config. We just write and roun our route like this;\n\n```java\nimport org.apache.camel.builder.RouteBuilder;\n\npublic class Routing extends RouteBuilder {\n\n    @Override\n    public void configure() throws Exception {\n        from(\"timer:java?period=1000\")\n            .id(\"java-logger\")\n            .setBody()\n                .simple(\"Hello Camel K from route: ${routeId}\")\n            .to(\"log:info\")      \n    }\n\n}\n```\n\nAs you can see, what we have here above is just a simple route, being triggered for every second, creating a body and logging that, with INFO level. No pom or gradle file, no setup, we just need a simple route doing a simple job. With Apache Camel K, we can send this route without any boilerplate code, without any configuration directly to kubernetes.\n\n\n[Go back to TOC](#toc)\n\n 1 Setup\n--------\nIn order to run Apache Camel K, we need two things at first;\n\n1. Docker Desktop with Kubernetes context.\n2. MiniKube (or any equivalent)\n3. Camel K CLI\n\nI assume, you can find how to setup docker desktop very easily. Then you can setup MiniKube start it and have a kubernetes dashboard. I'm going to use this [source](https://minikube.sigs.k8s.io/docs/start/) to setup minikube. After you follow the referenced source to install minikube, we can start it as follows;\n\n\n[Go back to TOC](#toc)\n\n 1-a MiniKube\n-------------\n1. start minikube: ```minikube start```\n2. Interact with cluster: ```minikube cubectl get po -A```\n3. Start minikube dashboard: ```minikube dashboard```\n\nAfter you start the dashboard, a browser page should automatically pop up and you can see the kubernetes dashboard.\n\n\n[Go back to TOC](#toc)\n\n 1-b Camel-K Client\n-------------------\nYou need to download the Apache Camel K client from the followiing source;\n\n[source-for-apache-camel-client](https://github.com/apache/camel-k/releases)\n\nUnzip it, copy it to a folder, and either add this folder to your path, or copy it to /usr/bin or any equivalent based on your system. This optional configuraiton is just only to call it anywhere from terminal or command line. For windows, you can add an environmental variable which has the binary, and add this environmental variable to the PATH.\n\n\n[Go back to TOC](#toc)\n\n 2 Running An Integration Demo\n------------------------------\nIf your kubernetes dashboard runs locally, and your Camel-K client is ready then we can run a simple route example, the one that is shown in the introduction. You can check the file [here](https://github.com/bzdgn/camel-k-introduction/blob/main/sources/BasicRouting.java)\n\nThe files content is as below;\n\n```java\nimport org.apache.camel.builder.RouteBuilder;\n\npublic class Routing extends RouteBuilder {\n\n    @Override\n    public void configure() throws Exception {\n        from(\"timer:java?period=1000\")\n            .id(\"java-logger\")\n            .setBody()\n                .simple(\"Hello Camel K from route: ${routeId}\")\n            .to(\"log:info\")      \n    }\n\n}\n```\n\nWhat we are going to do is, just push it to the camel cluster, and the rest will be done automatically. To do this;\n\n1. Enable registry addon ```minikube addons enable registry```\n2. kamel install\n3. kamel run BasicRouting.java\n\nThen you can see in the log that the BasicRouting is created in the dashboard.\n\nYou can easily delete this route, by applying the following command;\n\n```kamel delete basic-routing```\n\n**Important Note**: All the integration java files must have the same naming with the class name!\n\n\n[Go back to TOC](#toc)\n\n 3 Language Support\n-------------------\n\nCamel K supports following languages;\n\n- Groovy\n- Kotlin\n- JavaScript\n- Java (JShell)\n- XML\n- YAML\n\nFor the simplicity, the following code is written in Java DSL\n\n```java\nimport org.apache.camel.builder.RouteBuilder;\n\npublic class TickerRoute extends RouteBuilder {\n\n    @Override\n    public void configure() throws Exception {\n        from(\"timer:tick\")\n            .setBody()\n                .simple(\"Hello Camel K! This written with Java DSL\")\n            .to(\"log:info\")      \n    }\n\n}\n\n```\n\nAnd the xml equivalent is as below;\n\n```xml\n\u003croutes xmlns=\"http://camel.apache.org/schema/spring\"\u003e\n    \u003croute\u003e\n        \u003cfrom uri=\"timer:tick\"/\u003e\n        \u003csetBody\u003e\n            \u003cconstant\u003eHello Camel K! This is written with XML\u003c/constant\u003e\n         \u003c/setBody\u003e\n        \u003cto uri=\"log:info\"/\u003e\n    \u003c/route\u003e\n\u003c/routes\u003e\n\n```\n\nYou can find these files under sources as below\n\n- [Java Example](https://github.com/bzdgn/camel-k-introduction/blob/main/sources/TickerRoute.java)\n- [XML Example ](https://github.com/bzdgn/camel-k-introduction/blob/main/sources/TickerRoute.xml)\n\n\n[Go back to TOC](#toc)\n\n 4 Developer Mode\n-----------------\nCamel K has a very nice option. You can run it on developer mode, and you can see the fast-redeploy mechanism of Camel K, as you make changes on your code.\n\nLet's run one of the examples we have mentioned earlier, the ticker;\n\n```java\nimport org.apache.camel.builder.RouteBuilder;\n\npublic class TickerRoute extends RouteBuilder {\n\n    @Override\n    public void configure() throws Exception {\n        from(\"timer:tick\")\n            .setBody()\n                .simple(\"Hello Camel K! This written with Java DSL\")\n            .to(\"log:info\")      \n    }\n\n}\n```\n\nThe file is located in [here](https://github.com/bzdgn/camel-k-introduction/blob/main/sources/TickerRoute.java), so to start this integration in developer mode, we should just add ```--dev``` to the end of the run command;\n\n```kamel run TickerRoute.java --dev```\n\nThen after some time, both ont MiniKube and in our terminal, we can see the logs in the terminal. Then we should just update our file as below;\n\n```java\nimport org.apache.camel.builder.RouteBuilder;\n\npublic class TickerRoute extends RouteBuilder {\n\n    @Override\n    public void configure() throws Exception {\n        from(\"timer:tick\")\n            .setBody()\n                .simple(\"Updated: Hello Camel K! This written with Java DSL and this line is updated!\")\n            .to(\"log:info\")      \n    }\n\n}\n```\n\nSoon after our change on the file, automatically the local logs will change in the log.\n\nBut also on the MiniKube (or remote Kubernetes environment), will create a new updated pod as the Camel Operator is triggered.\n\n\n[Go back to TOC](#toc)\n\n 5 A Rest API Example\n---------------------\nIn this example, a simple REST Api will be introduced. You can find the source of this integration [here](https://github.com/bzdgn/camel-k-introduction/blob/main/sources/Api.java).\n\nThe Api has 5 operations, basic CRUD operations as listed below;\n\n| Operation | HTTP Method | endpoint           |\n|-----------|-------------|--------------------|\n| Status    | GET         | /api/person/status | \n| Get       | GET         | /api/person/{id}   | \n| Get All   | GET         | /api/person/       |\n| Create    | POST        | /api/person/       |\n| Update    | PUT         | /api/person/       |\n| Delete    | DELETE      | /api/person/{id}   |\n\nTo play with the API and see how it works, we are going to use the following cURL commands within the terminal;\n\n```\ncurl localhost:8080/api/person/status\ncurl -H \"Content-Type: application/json\" -X POST -d \"{\\\"id\\\":12,\\\"name\\\":\\\"John\\\"}\" http://localhost:8080/api/person\ncurl -H \"Content-Type: application/json\" -X POST -d \"{\\\"id\\\":15,\\\"name\\\":\\\"Marry\\\"}\" http://localhost:8080/api/person\ncurl -H \"Content-Type: application/json\" -X PUT -d \"{\\\"id\\\":15,\\\"name\\\":\\\"Jane\\\"}\" http://localhost:8080/api/person\ncurl -H \"Content-Type: application/json\" -X DELETE http://localhost:8080/api/person/15\n```\n\nOptionally, we can to expose our service as below so that we can call our service outside the pod;\n\n```\nkubectl expose deployment api --type=LoadBalancer --name=my-service \n```\n\nThen we can run the following command to expose it via MiniKube and then we can change the cURL commands, localhost port with the external IP;\n\n```\nminikube service api\n```\n\n\n[Go back to TOC](#toc)\n\n 6 Final Words\n--------------\n\nThere are pros and cons for the Camel K. \n\nPros;\n-----\n- Fast deployment\n- Removal of the boilerplate code\n- Easy to write integrations\n- Native kubernetes\n\nCons;\n-----\n- Not enough resources for the complex examples\n- Still needs to get mature for complexer scenarios\n- Less control over the code\n- Unit testing\n\n\n[Go back to TOC](#toc)\n\n 7 Further Reading\n------------------\n\n[Apache Camel K Documentation](https://camel.apache.org/camel-k/latest/) \u003cbr/\u003e\n[Claus Ibsen Camel K Intro](https://youtu.be/d1Hr78a7Lww?t=630) \u003cbr/\u003e\n[Camel K in a Nutshell](https://www.youtube.com/watch?v=LaBvBonUC6g) \u003cbr/\u003e\n[MiniKube Documentation](https://minikube.sigs.k8s.io/docs/start/) \u003cbr/\u003e\n[Kubernetes Camel K Operator](https://operatorhub.io/operator/camel-k) \u003cbr/\u003e\n[Camel K Examples](https://github.com/apache/camel-k-examples/) \u003cbr/\u003e\n[Camel K Examples in Main Project](https://github.com/apache/camel-k/tree/main/examples) \u003cbr/\u003e\n\n\n[Go back to TOC](#toc)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbzdgn%2Fcamel-k-introduction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbzdgn%2Fcamel-k-introduction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbzdgn%2Fcamel-k-introduction/lists"}