Camel Kubernetes plugin
Export, build, push, and deploy Camel integrations to Kubernetes — develop locally with Camel CLI, then promote to any cluster.
Enable the plugin:
camel plugin add kubernetes Run camel kubernetes --help to see all subcommands. |
Kubernetes export
Export a Maven project with a Kubernetes manifest (kubernetes.yml) containing Deployment, Service, ConfigMap, and other resources:
camel kubernetes export route.yaml --dir some/path/to/project The default runtime is Quarkus (--runtime=quarkus). Build and deploy:
./mvnw package -Dquarkus.container-image.build=true
./mvnw package -Dquarkus.kubernetes.deploy=true The camel kubernetes run command combines export, build, push, and deploy into a single step. |
The export command provides several options to customize the project:
| Option | Description |
|---|---|
| The service account used to run the application. |
| Adds dependency that should be included, use "camel:" prefix for a Camel component, "mvn:org.my:app:1.0" for a Maven dependency. |
| Maven/Gradle build properties (syntax: --build-property=prop1=foo) |
| Add a runtime property or properties from a file (syntax: [my-key=my-value|file:/path/to/my-conf.properties,/path/to/my-conf.properties]). |
| Add a runtime configuration from a ConfigMap or a Secret (syntax: [configmap,secret]:name[/key], where name represents the configmap/secret name and key optionally represents the configmap/secret key to be filtered). |
| Add a runtime resource from a Configmap or a Secret (syntax: [configmap,secret]:name[/key][@path], where name represents the configmap/secret name, key optionally represents the configmap/secret key to be filtered and path represents the destination path). |
| Add an OpenAPI spec (syntax: [configmap,file]:name). |
| Set an environment variable in the integration container, for instance "-e MY_VAR=my-value". |
| Mount a volume into the integration container, for instance "-v pvcname:/container/path". |
| A Service that the integration should bind to, specified as [[apigroup/]version:]kind:[namespace/]name. |
| Add the source file to your integration, this is added to the list of files listed as arguments of the command. |
| Add an annotation to the integration. Use name values pairs like "--annotation my.company=hello". |
| Add a label to the integration. Use name values pairs like "--label my.company=hello". |
| Add a trait configuration to the integration. Use name values pairs like "--trait trait.name.config=hello". |
| An image built externally (for instance via CI/CD). Enabling it will skip the integration build phase. |
| The image registry to hold the app container image. |
| The image registry group used to push images to. |
| The image builder used to build the container image (e.g. docker, jib, s2i). |
| List of target platforms. Each platform is defined using os and architecture (e.g. linux/amd64). |
| The base image that is used to build the container image from (default is eclipse-temurin:<java-version>). |
| Optional Docker registry mirror where to pull images from when building the container image. |
| The target cluster type. Special configurations may be applied to different cluster types such as Kind or Minikube. |
| The developer profile to use a specific configuration in configuration files using the naming style |
Run camel kubernetes export --help for all options (includes inherited Camel CLI export options). |
Kubernetes manifest options
Customize the Kubernetes manifest using traits (from Camel K). Trait configuration precedence:
-
--traitcommand options -
Annotations with prefix
trait.camel.apache.org/* -
Properties in
application-<profile>.propertieswith prefixcamel.jbang.trait.* -
Properties in
application.propertieswith prefixcamel.jbang.trait.*
Container trait
Customize the container specification (image, ports, resources):
| Property | Type | Description |
|---|---|---|
|
| To configure a different port exposed by the container (default |
|
| To configure a different port name for the port exposed by the container. It defaults to |
|
| To configure under which service port the container port is to be exposed (default |
|
| To configure under which service port name the container port is to be exposed (default |
|
| The application container name. |
|
| The application container image to use for the Deployment. |
|
| The pull policy: Always|Never|IfNotPresent |
|
| The pull secrets for private registries |
|
| The minimum amount of CPU required. |
|
| The minimum amount of memory required. |
|
| The maximum amount of CPU required. |
|
| The maximum amount of memory required. |
Example:
camel kubernetes export Sample.java --trait container.name=my-container --trait container.port=8088 --trait container.request-cpu=0.005 --trait container.request-memory=100Mi CronJob trait
Generate a CronJob instead of a Deployment (requires enabled=true and schedule):
camel kubernetes export Sample.java --trait=cronjob.enabled=true --trait=cronjob.schedule="* * * * 2" | Property | Type | Description |
|---|---|---|
|
| To generate the CronJob manifest instead of Deployment. (default=false) |
|
| To set the schedule to run the workload following the crontab format. |
|
| To set the timezone to run the workload. |
|
| To set the |
|
| To set the |
|
| To set the |
|
| To set the |
Labels and annotations
By default, resources have the label camel.apache.org/integration set to the project name. Add custom labels and annotations:
camel kubernetes export Sample.java --annotation project.team=camel-experts --label env=staging Environment variables
Set environment variables with --trait environment.vars=KEY=VALUE or the shortcut --env KEY=VALUE:
camel kubernetes export Sample.java --env MY_ENV=foo --env FOO_ENV=bar Service trait
A Service resource is auto-generated when routes expose HTTP endpoints (e.g., platform-http). Customize it:
| Property | Type | Description |
|---|---|---|
|
| The type of service to be used, either 'ClusterIP', 'NodePort' or 'LoadBalancer'. |
|
| To configure under which service port the container port is to be exposed (default |
|
| To configure under which service port name the container port is to be exposed (default |
Knative service trait
Use Knative serving for serverless workloads with auto-scaling and scale-to-zero.
Disabled by default — enable with --trait knative-service.enabled=true. |
WARN: Currently does not work on OpenShift.
| Property | Type | Description |
|---|---|---|
|
| Can be used to enable or disable a trait. All traits share this common property. |
|
| The annotations added to route. This can be used to set knative service-specific annotations CLI usage example: -t "knative-service.annotations.'haproxy.router.openshift.io/balance'=true" |
|
| Configures the Knative autoscaling class property (e.g., to set Refer to the Knative documentation for more information. |
|
| Configures the Knative autoscaling metric property (e.g., to set Refer to the Knative documentation for more information. |
|
| Sets the allowed concurrency level or CPU percentage (depending on the autoscaling metric) for each Pod. Refer to the Knative documentation for more information. |
|
| The minimum number of Pods that should be running at any time for the integration. It’s zero by default, meaning that the integration is scaled down to zero when not used for a configured amount of time. Refer to the Knative documentation for more information. |
|
| An upper bound for the number of Pods that can be running in parallel for the integration. Knative has its own cap value that depends on the installation. Refer to the Knative documentation for more information. |
|
| Enables to gradually shift traffic to the latest Revision and sets the rollout duration. It’s disabled by default and must be expressed as a Golang |
|
| Setting Refer to the Knative documentation for more information. |
|
| The maximum duration in seconds that the request instance is allowed to respond to a request. This field propagates to the integration Pod’s terminationGracePeriodSeconds. Refer to the Knative documentation for more information. |
Knative component trait
Configure the Camel Knative component to interact with Knative eventing and Knative serving. The export auto-configures both the component and the Kubernetes manifest.
Disabled by default — enable with --trait knative.enabled=true. |
| Property | Type | Description |
|---|---|---|
|
| Can be used to enable or disable a trait. (default: true) |
|
| Can be used to inject a Knative complete configuration in JSON format |
|
| List of channels used as destination of camel routes. Can contain simple channel names or full Camel URIs. Refer to the Knative documentation for more information. |
|
| List of channels used as the source of camel routes. Can contain simple channel names or full Camel URIs. |
|
| List of endpoints used as destination of camel routes. Can contain simple endpoint names or full Camel URIs. |
|
| List of endpoints used as sources of camel routes. Can contain simple endpoint names or full Camel URIs. |
|
| List of endpoints used as destination of integration routes. Can contain simple endpoint names or full Camel URIs. |
|
| List of event types that the integration will be subscribed to. Can contain simple event types or full Camel URIs (to use a specific broker different from "default"). |
|
| Allows binding the integration to a sink via a Knative SinkBinding resource. This can be used when the integration targets a single sink. It’s enabled by default when the integration targets a single sink (except when the integration is owned by a Knative source). |
|
| Sets filter attributes on the event stream (such as event type, source, subject and so on). A list of key-value pairs that represent filter attributes and its values. The syntax is KEY=VALUE, e.g., source="my.source". Filter attributes get set on the Knative trigger that is being created as part of this integration. |
|
| Enables the default filtering for the Knative trigger using the event type If this is true, the created Knative trigger uses the event type as a filter on the event stream when no other filter criteria is given. (default: true) |
Knative trigger
When a route consumes from knative:event, the plugin automatically generates a Knative Trigger in the manifest:
- route:
from:
uri: knative:event/camel.evt.type
parameters:
name: my-broker
steps:
- to:
uri: log:info Export with camel kubernetes export knative-route.yaml — the trigger, service, and knative.json configuration are all generated automatically.
Knative channel subscription
Similarly, routes consuming from knative:channel/my-channel automatically generate a Knative Subscription in the manifest. The knative.json configuration is auto-generated.
Knative sink binding
Routes that produce to knative:event, knative:channel, or knative:endpoint automatically get a SinkBinding resource in the manifest. Knative injects the target URL via the K_SINK environment variable at deployment time, so the route doesn’t need to know the actual URL. === Mount trait
Configure volume mounts from ConfigMaps, Secrets, and PVCs. Shortcuts: --volume, --config, --resource.
| Property | Type | Description |
|---|---|---|
|
| A list of configuration pointing to configmap/secret. The configurations are expected to be UTF-8 resources as they are processed by runtime Camel Context and tried to be parsed as property files. They are also made available on the classpath to ease their usage directly from the Route. Syntax: [configmap|secret]:name[/key], where name represents the resource name and key optionally represents the resource key to be filtered |
|
| A list of resources (text or binary content) pointing to a configmap/secret. The resources are expected to be any resource type (text or binary content). The destination path can be either a default location or any path specified by the user. Syntax: [configmap|secret]:name[/key][@path], where name represents the resource name, key optionally represents the resource key to be filtered and path represents the destination path |
|
| A list of Persistent Volume Claims to be mounted. Syntax: [pvcname:/container/path] |
Example:
camel kubernetes export Sample.java --config secret:my-credentials --resource configmap:my-data --volume my-pvc:/container/path Mount paths follow Camel conventions: configs go to /etc/camel/conf.d/, resources to /etc/camel/resources.d/, and the application is auto-configured to read these paths.
Ingress trait
Add an Ingress resource to expose the application externally (requires a Service resource):
| Property | Type | Description |
|---|---|---|
|
| Can be used to enable or disable a trait. All traits share this common property (default |
|
| The annotations added to the ingress. This can be used to set controller-specific annotations, e.g., when using the NGINX Ingress controller. |
|
| To configure the host exposed by the ingress. |
|
| To configure the path exposed by the ingress (default |
|
| To configure the path type exposed by the ingress. One of Exact, Prefix, ImplementationSpecific (default to Prefix). |
|
| To automatically add an Ingress Resource whenever the route uses an HTTP endpoint consumer (default |
|
| To configure specific hosts exposed through SNI TLS extension by the ingess. |
|
| To indicate the secret containing the TLS private key and certificate to use for TLS. |
Example:
camel kubernetes export Sample.java --trait ingress.enabled=true --trait ingress.host=example.com --trait ingress.path=/sample Route trait (OpenShift)
Add an OpenShift Route resource to expose the application externally:
| Property | Type | Description |
|---|---|---|
|
| Can be used to enable or disable a trait. All traits share this common property (default |
|
| The annotations added to the route. This can be used to set openshift route specific annotations options. |
|
| To configure the host exposed by the route. |
|
| The TLS termination type, like |
|
| The TLS certificate contents or file ( |
|
| The TLS certificate key contents or file ( |
|
| The TLS CA certificate contents or file ( |
|
| The destination CA contents or file ( |
|
| To configure how to deal with insecure traffic, e.g. |
Example:
camel kubernetes export Sample.java --cluster-type=openshift --trait route.enabled=true --trait route.host=example.com --trait route.tls-termination=edge Jolokia trait
Enable JMX access via Jolokia (requires Jolokia configured in the application):
| Property | Type | Description |
|---|---|---|
|
| Can be used to enable or disable a trait. All traits share this common property. (default |
|
| To configure a different jolokia port exposed by the container (default |
|
| To configure a different port name for the port exposed by the container (default |
|
| Can be used to enable/disable exposure of jolokia via kubernetes Service. (default |
|
| To configure a different jolokia port exposed by the service (default |
|
| To configure a different port name for the port exposed by the service (default |
Example:
camel kubernetes export Sample.java --trait jolokia.enabled=true --trait jolokia.expose=true Deploy to OpenShift
Use --cluster-type=openshift to generate OpenShift-specific resources (Route, ImageStream, BuildConfig):
camel kubernetes export Sample.java --cluster-type=openshift The default image builder switches to S2I for OpenShift. Override with --image-builder=jib to push to an external registry instead.
With S2I, set --image-group to your OpenShift project/namespace name, since S2I uses it as part of the image coordinates: image-registry.openshift-image-registry.svc:5000/<project>/<name>:<tag> |
Kubernetes run
The run command exports, builds, pushes, and deploys in one step:
camel kubernetes run route.yaml --image-registry=kind The command auto-detects local clusters (kind, minikube, OpenShift) and configures the registry accordingly. Disable with --disable-auto.
Customize the image:
camel kubernetes run route.yaml --image-registry=kind --image-group camel-experts
camel kubernetes run route.yaml --image quay.io/camel-experts/demo-app:1.0 The run command supports the same trait options as export for customizing the Kubernetes manifest.
Auto reload with --dev
Watch for source file changes and automatically rebuild/redeploy:
camel kubernetes run route.yaml --image-registry=kind --dev Terminate the process to stop dev mode — the deployment is automatically removed on shutdown.
| On macOS, the file watch mechanism is slower due to limited native file operations for Java processes. |
Setting properties and resources at runtime
Set properties inline, from files, or from Kubernetes resources:
camel kubernetes run route.yaml --property my-key=my-val
camel kubernetes run route.yaml --property file:/some/directory/file.properties Properties from ConfigMaps and Secrets
Use --config to mount ConfigMap/Secret data as properties files, automatically configured for Camel property placeholders:
camel kubernetes run route.java --config configmap:game-config
camel kubernetes run route.java --config configmap:game-config/game.properties
camel kubernetes run route.java --config secret:my-credentials Mount paths: --config configmap: maps to /etc/camel/conf.d/_configmaps/<name>/<key>, --config secret: maps to /etc/camel/conf.d/_secrets/<name>/<key>. Each ConfigMap key becomes a file.
Mounting generic files
Use --resource to mount files without property placeholder configuration. Syntax: [configmap|secret]:name[/key][@path]:
camel kubernetes run route.java --resource configmap:my-data
camel kubernetes run route.java --resource configmap:my-data/config.xml@/etc/my-config.xml Mount paths: /etc/camel/resources.d/_configmaps/<name>/<key> (or _secrets). Use @path to override the destination.
Delete deployments
Remove a deployment and all its resources:
camel kubernetes delete --name=route
camel kubernetes delete --name=route --cluster-type=openshift If you used --cluster-type during export/run, you must specify it for delete as well. |
Minikube deployment tips
Quick start for local development with Minikube (Camel 4.10+):
minikube start --addons registry --driver=docker
eval $(minikube -p minikube docker-env)
camel kubernetes run demo.camel.yaml --cluster-type=minikube \
--build-property=quarkus.kubernetes.image-pull-policy=Never \
--image-registry "$(kubectl -n kube-system get service registry -o jsonpath='{.spec.clusterIP}')" \
--image-builder=docker The --build-property=quarkus.kubernetes.image-pull-policy=Never flag is required for Minikube deployments. |
| Docker multi-platform build is used. Follow the Docker multi-platform requirements. |