Init Containers Trait
The InitContainersTrait trait can be used to configure init containers
or sidecar containers
.
This trait is available in the following profiles: Kubernetes, Knative, OpenShift.
The init-containers trait is a platform trait and cannot be disabled by the user. |
Configuration
Trait properties can be specified when running any integration with the CLI:
$ kamel run --trait init-containers.[key]=[value] --trait init-containers.[key2]=[value2] integration.yaml
The following configuration options are available:
Property | Type | Description |
---|---|---|
|
| Deprecated: no longer in use. |
|
| To automatically enable the trait |
|
| A list of init tasks to be executed with format |
|
| A list of sidecar tasks to be executed with format |
An example init container
Create an Integration which read some value initialized by an init container. The following route takes care to read a file which is expected to be initialized by another process.
- route:
from:
# Read a file that should have been initialized
# by the initContainer
uri: file:/tmp
parameters:
fileName: init
steps:
- log:
message: "${body}"
The route is agnostic how this file is generated.
When creating the Integration, then, it should include an init container taking care to initialize such file, for example:
kamel run route.yaml -t mount.empty-dirs=common:/tmp -t init-containers.tasks="init;alpine;/bin/sh -c \"echo hello >> /tmp/init\""
As the file is shared between the containers you will need to provide a shared volume (an EmtpyDir
in this case).