Author Archives: Niklas

Camel-k: Add multiple custom classes via .jar

I came across a use case where we needed a MapForce mapping in our Camel-K flow. MapForce generated Java code consists of many classes and it becomes overly cumbersome to add them all to the kamel run command. To solve this problem we put all the MapForce generated code into a .jar file and then added it to our cluster and referenced it in our kamel run command

1. First we made a .jar file out of the generated java code. For this we use the jar command that can be found in most java developer kits

jar cvf MapFormatAToFormatB.jar com/ se/

This creates a .jar file called MapFormatAToFormatB.jar with the contents of the generated code com/ and se/. Mapforce puts general classes into com/ package and our custom classes into your own packages, in our case se/.

2. Create a ConfigMap to hold our .jar so that Camel-K-Operator can use it

kubectl create configmap map-formata-to-formatb --from-file=MapFormatAToFormatB.jar

3. Reference the configmap in you kamel run command

kamel run src/main/java/myApp --resource configmap:map-formata-to-formatb

That´s it. In our code we reference these classes the same way we should have if the where part of our code base

import se.myorg.integration.MapFormatAToFormatB;

import org.apache.camel.builder.RouteBuilder;

public class AmbuReg extends RouteBuilder {
    public void configure() throws Exception {

Tested on Camel-K-Operator v1.11.1 and Kubernetes v1.24.11

My kubectl CheatSheet

List pods in current namespace

kubectl get pods

List pods i all namespaces

kubectl get pods -A

View details about a pod

kubectl describe pod <pod-name>

List ConfigMaps

kubectl get configmaps

View details about a ConfigMap

kubectl describe configmap <config-map-name>

Create a ConfigMap the holds a file

kubectl create configmap <config-map-name> --from-file=<file-name>

List Deployments

kubectl get deployments

View details about a Deployment

kubectl describe deployment <deployment-name>

List Services

kubectl get services

View details about a Service

kubectl describe service <service-name>

List ServiceAccounts

kubectl get serviceaccounts

View details about a ServiceAccount

kubectl describe serviceaccount <service-account-name>

List all secrets

kubectl get secrets

View details about a secret

kubectl describe secret <secret-name>

Get secret contents as JSON

kubectl get secret <secret-name> -o jsonpath='{.data}'

Create a secret

kubectl create secret generic <secret-name> --from-literal=username=<username> --from-literal=password='<password>'

Edit a secret

kubectl edit secrets <secret-name>

Delete a secret

kubectl delete secret <secret-name>

Get all objects of kind IntegrationPlattform

kubectl get IntegrationPlatform

View settings of the IntegrationPlattform

kubectl describe IntegrationPlatform

Setup Camel-K in VMware Tansu (Kubernetes) with a Harbor registry

Here is how I set up a Camel-K installation in VMware Tansu with a Harbor registry.

  1. Log into Harbor
  2. Got to your project
  3. Create a Robot Account with both push and pull permissions (you might need Admin permissions in the project for this)
  4. Copy the JWT at the end of the creation process
  5. Log into VMware Tansu CLI
  6. Create a secret with that JWT token
    kubectl create secret docker-registry camel-k-stage --docker-server=<Harbor adress> --docker-username="robot\$camel-k-stage" --docker-password='<JWT token>'
  7. Install Camel-K Operator
    kamel install --registry <Harbor adress> --organization <Harbor project name> --registry-secret camel-k-stage
  8. Your Camel-K operator is now ready for use

Tested on Harbor v2.0 and VMware Tansu Kubernetes v1.22