In this section you will find examples about fine-tuning your Integration
using Container trait
capability.
The Container trait is a platform trait, it is enabled by default.
Read the general instructions in the root README.md file for setting up your environment and the Kubernetes cluster before looking at this example.
Make sure you've read the installation instructions for your specific cluster before starting the example.
To configure some custom values, run the integration
kamel run \
--name container \
Container.java \
--trait container.image-pull-policy=Always \
--trait container.request-cpu=0.005 \
--trait container.limit-cpu=0.2 \
--trait container.request-memory=100Mi \
--trait container.limit-memory=500Mi
When you check the values declared by the pod spec
kubectl get pods --selector="camel.apache.org/integration"="container" -o yaml
You should get a result with the values you defined
...
"imagePullPolicy": "Always",
...
"resources": {
"limits": {
"cpu": "200m",
"memory": "500Mi"
},
"requests": {
"cpu": "5m",
"memory": "100Mi"
}
}
...
The container and service port configuration needs the presence of a service, else it will be ignored.
For these example, we use an example route exposing some rest endpoint. This will enable the service and expose the container port by default.
Warning
Be careful when changing the default ports value and/or name as it can have some side effects.
To define a custom service port, run the integration
kamel run --name restcontainer \
RestDSL.java \
--trait service.enabled=true \
--trait container.service-port=8082 \
--trait container.service-port-name=myserviceport
When you check the values declared by the service spec
kubectl get service restcontainer -o jsonpath='{.spec.ports}'
You should get a result with the values you defined
[{"name":"myserviceport","port":8082,"protocol":"TCP","targetPort":"http"}]
For more details on the Service trait, see the example README.md file
The definition of a custom container port need some modification of quarkus default property to be effective.
kamel run \
--property quarkus.http.port=8081 \
--name restcontainer \
RestDSL.java \
--trait container.port=8081 \
--trait container.port-name=mycontainerport
kubectl get pods --selector="camel.apache.org/integration"="restcontainer" -o jsonpath='{.items[*].spec.containers[*].ports}'
You should get a result with the values you defined
[{"containerPort":8081,"name":"mycontainerport","protocol":"TCP"}]