Configuration via ConfigMap or Secret

Camel K allows to define property values using Kubernetes ConfigMap or Secrets.

For the sake of simplicity, consider the following integration:

props.groovy
from('timer:props?period=1s')
    .log('{{my.message}}')

In addition to command line property configuration, Camel K provides the following options.

Configuration via ConfigMap

You can create a ConfigMap containing your configuration properties and link it to a Camel K integration.

For example, you can define the following ConfigMap:

my-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: my-config
data:
  application.properties: |
    my.message=Hello World
    logging.level.org.apache.camel=DEBUG

In the ConfigMap above we’ve set both the value of the my.message property and also the logging level for the org.apache.camel package.

You need to create the ConfigMap first (in the same Kubernetes namespace):

kubectl apply -f my-config.yaml

You can now run the integration with the following command to reference the ConfigMap:

kamel run --configmap=my-config props.groovy

Configuration via Secret

Configuration via Secrets is similar to the configuration via ConfigMap. The difference is that you may need to base64 encode the content of the application.properties file inside the secret.

For example, the following Secret is equivalent to the previous ConfigMap:

my-secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: my-secret
data:
  application.properties: |
    bXkubWVzc2FnZT1IZWxsbyBXb3JsZAogICAgbG9nZ2luZy5sZXZlbC5vcmcuYXBhY2hlLmNhbWVs
    PURFQlVHCg==

You need to create the Secret first (in the same Kubernetes namespace):

kubectl apply -f my-secret.yaml

You can now run the integration with the following command to reference the Secret:

kamel run --secret=my-secret props.groovy