User manual

Camel CLI - Kubernetes Plugin

You have Camel routes that run with camel run, and you want them running on Kubernetes. The Kubernetes plugin builds a Spring Boot, Quarkus or Camel Main application from your route files, packages it as a container image, and deploys it to the cluster — in one command, or as a Maven project you hand over to your CI/CD pipeline.

Prerequisites: kubectl installed and connected to a cluster (remote, Kind, or Minikube).

Enable the plugin:

camel plugin add kubernetes
Run camel kubernetes --help to see all subcommands.

Run on Kubernetes in one step

Given the routes of your application in the current folder:

camel kubernetes run * --runtime=spring-boot --name=my-app

This exports a Spring Boot project named my-app, builds the container image, pushes it, and deploys it to the cluster kubectl is connected to. The runtime is one of spring-boot, quarkus (the default) or main.

Local clusters (Kind, Minikube) and OpenShift are detected, and the image registry is configured for them. Use --cluster-type to set the cluster type explicitly, skipping auto-detection while still applying the cluster-specific defaults. For any other cluster, tell the plugin where to push the image:

camel kubernetes run * --runtime=spring-boot --image-registry=quay.io --image-group=my-team

Useful options of run:

Option Description

--namespace

The namespace to deploy to (default: the current namespace of kubectl).

--name

The application name, used for the image, the Deployment and all resources. Set it explicitly, otherwise it is derived from the files given.

--wait

Wait for the deployment to become ready.

--logs

Print the logs once the application has started.

--disable-auto

Do not detect the cluster type (Kind, Minikube, OpenShift).

--verbose

Show the output of the Maven build and the deployment.

Develop against the cluster with --dev

Watch the route files and rebuild and redeploy on every change:

camel kubernetes run * --runtime=spring-boot --dev

Stop the command (Ctrl+C) to end dev mode — the deployment is removed on shutdown.

On macOS, the file watch mechanism is slower due to limited native file operations for Java processes.

Export a Maven project

For a real deployment pipeline you want the project in source control. export writes a regular Maven project with the Kubernetes manifest included:

camel kubernetes export * --runtime=spring-boot --name=my-app --dir=../my-app

The project uses the Eclipse JKube Maven plugin, for all three runtimes. The package phase builds the container image, generates the Kubernetes manifest (target/kubernetes/kubernetes.yml: Deployment, Service, ConfigMaps, …​) and pushes the image. Deploy it with:

cd ../my-app
./mvnw package k8s:deploy

export takes the same options as run for the image, the configuration and the manifest, so the project deploys the same way camel kubernetes run would.

Run camel kubernetes export --help for all options, including the options inherited from camel export (Camel and Spring Boot versions, --gav, --dep, and so on). See Export to Maven for those.

Container image

By default the image is built with Jib, which needs no Docker daemon, from the eclipse-temurin base image of your Java version.

Option Description

--image-registry

The registry to push the image to, such as quay.io or kind for a local Kind cluster.

--image-group

The group (organization or project) in the registry.

--image

Use an image built elsewhere (for instance by your CI/CD pipeline), such as quay.io/my-team/my-app:1.0. The image build is skipped.

--image-builder

How to build the image: jib (default), docker or s2i.

--base-image

The base image to build from (default eclipse-temurin:<java-version>).

--image-platform

The target platforms of the image, such as linux/amd64,linux/arm64.

--image-push

Whether to push the image (default true).

--registry-mirror

A registry mirror to pull the base image from.

Configuration

Your application.properties is exported with the routes. Set or override properties when deploying:

camel kubernetes run * --property my-key=my-val
camel kubernetes run * --property file:/some/directory/file.properties

Use a profile to pick application-<profile>.properties:

camel kubernetes run * --profile=prod

Properties from ConfigMaps and Secrets

Keep cluster-specific configuration and credentials in the cluster. --config mounts a ConfigMap or Secret as properties files that Camel reads for its property placeholders:

camel kubernetes run * --config configmap:my-app-config
camel kubernetes run * --config configmap:my-app-config/app.properties
camel kubernetes run * --config secret:my-credentials

Each key becomes a file, mounted under /etc/camel/conf.d/_configmaps/<name>/<key> (or /etc/camel/conf.d/_secrets/<name>/<key>).

Other files

--resource mounts any file (text or binary) from a ConfigMap or Secret, without reading it as properties. Syntax: [configmap|secret]:name[/key][@path]:

camel kubernetes run * --resource configmap:my-data
camel kubernetes run * --resource configmap:my-data/config.xml@/etc/my-config.xml

The default location is /etc/camel/resources.d/_configmaps/<name>/<key> (or _secrets); @path overrides it.

Environment variables and volumes

camel kubernetes run * --env MY_ENV=foo --env OTHER_ENV=bar
camel kubernetes run * --volume my-pvc:/container/path

Health probes

The application includes camel-observability-services, and the Deployment gets liveness and readiness probes for it:

  • Spring Boot: /observe/health/liveness, /observe/health/readiness

  • Quarkus: /observe/health/live, /observe/health/ready, /observe/health/started

Exposing HTTP endpoints

When your routes consume HTTP (such as platform-http or the REST DSL), a Service is generated for the container port (8080) on service port 80. To reach the application from outside the cluster, change the Service type or add an Ingress:

camel kubernetes run * --trait service.type=LoadBalancer
camel kubernetes run * --trait ingress.enabled=true --trait ingress.host=my-app.example.com

On OpenShift, use a Route instead (see Deploy to OpenShift). All Service, Ingress and Route settings are listed in Kubernetes Plugin Advanced Options.

CPU and memory

Set the resource requests and limits of the container:

camel kubernetes run * --trait container.request-memory=256Mi --trait container.limit-memory=512Mi --trait container.request-cpu=0.5

Labels and annotations

Resources get the label app.kubernetes.io/name with the application name. Add your own:

camel kubernetes run * --label env=staging --annotation project.team=camel-experts

Service account

Run the application with a specific service account, for instance one allowed to read Secrets:

camel kubernetes run * --service-account=my-app

Show logs

Stream the logs of a deployed application:

camel kubernetes logs --name=my-app

Delete deployments

Remove the application and all its resources:

camel kubernetes delete --name=my-app

Deploy to OpenShift

Use --cluster-type=openshift (detected automatically by run) to build and deploy with the JKube OpenShift plugin and to push the image to the internal registry (image-registry.openshift-image-registry.svc:5000):

camel kubernetes export * --runtime=spring-boot --cluster-type=openshift

Deploy the exported project with ./mvnw package oc:deploy.

Use --image-builder=s2i to build the image in the cluster with Source-to-Image.

With S2I, set --image-group to your OpenShift project (namespace), since it is part of the image coordinates: image-registry.openshift-image-registry.svc:5000/<project>/<name>:<tag>. run uses the current namespace when it detects OpenShift.

Minikube

Quick start for local development with Minikube:

minikube start --addons registry --driver=docker
eval $(minikube -p minikube docker-env)
camel kubernetes run * --runtime=spring-boot

On Minikube the image is built with Docker straight into the Minikube Docker daemon, so nothing is pushed.

Troubleshooting

  • Add --verbose to camel kubernetes run to see the Maven build and deployment output.

  • run exports the project to .camel-jbang-run/<name>; look at the generated pom.xml and src/main/jkube there.

  • If building the image or deploying fails on a local cluster, try --disable-auto to switch off the cluster detection.

  • Building for several platforms (--image-platform) needs Docker set up for multi-platform builds.

Advanced options

Kubernetes Plugin Advanced Options covers the trait options inherited from Camel K: the full container, Service, Ingress and OpenShift Route settings, running as a CronJob, Knative serving and eventing, the Jolokia port, mounts, and OpenAPI specs from ConfigMaps.