Skip to content

Support multiple containers in the Kubernetes Transport implementation#5306

Merged
oheger-bosch merged 8 commits into
eclipse-apoapsis:mainfrom
boschglobal:oheger-bosch/kubernetes_multiple_containers
Jun 23, 2026
Merged

Support multiple containers in the Kubernetes Transport implementation#5306
oheger-bosch merged 8 commits into
eclipse-apoapsis:mainfrom
boschglobal:oheger-bosch/kubernetes_multiple_containers

Conversation

@oheger-bosch

Copy link
Copy Markdown
Contributor

This PR extends the Kubernetes Transport to allow the declaration of multiple containers. This enables advanced use cases like defining init containers or sidecar containers. Refer to the single commits for further information.

@oheger-bosch oheger-bosch force-pushed the oheger-bosch/kubernetes_multiple_containers branch from c8c2395 to 076d2ae Compare June 18, 2026 07:25
@oheger-bosch

Copy link
Copy Markdown
Contributor Author

@mnonnenmacher, do you have an idea about the failing build health check? This may be related to the introduction of the fluent API client dependency in c170f77, but I have no idea why it now suddenly pops up.

Copilot says that client-java-api-fluent bundles model classes that are also contained in client-java-api, which is the cause of the failure, e.g.:

Source set: main
\--- compile classpath
     +--- io/kubernetes/client/openapi/models/V1EmptyDirVolumeSource is provided by multiple dependencies: [io.kubernetes:client-java-api-fluent:26.0.0, io.kubernetes:client-java-api:26.0.0]

According to the AI, there is no artifact available containing only the fluent builder classes; so no easy way to work around the duplicated classes issues except for avoiding the fluent API. It therefore suggests to rewrite the KubernetesMessageSender class to only use the basic API.

Do you agree to this approach or do you have a better proposal?

@mnonnenmacher

Copy link
Copy Markdown
Contributor

@mnonnenmacher, do you have an idea about the failing build health check? This may be related to the introduction of the fluent API client dependency in c170f77, but I have no idea why it now suddenly pops up.

Copilot says that client-java-api-fluent bundles model classes that are also contained in client-java-api, which is the cause of the failure, e.g.:

Source set: main
\--- compile classpath
     +--- io/kubernetes/client/openapi/models/V1EmptyDirVolumeSource is provided by multiple dependencies: [io.kubernetes:client-java-api-fluent:26.0.0, io.kubernetes:client-java-api:26.0.0]

According to the AI, there is no artifact available containing only the fluent builder classes; so no easy way to work around the duplicated classes issues except for avoiding the fluent API. It therefore suggests to rewrite the KubernetesMessageSender class to only use the basic API.

Do you agree to this approach or do you have a better proposal?

The warnings just are just noise that makes it harder to find the actual problem, I didn't find a way to suppress them:

Advice for :transport:kubernetes
Existing dependencies which should be modified to be as indicated:
api(libs.kubernetesClientApiFluent) (was implementation)

You can also auto-fix such errors using the fixDependencies task:
https://github.com/autonomousapps/dependency-analysis-gradle-plugin#fix-dependency-issues-automatically

The duplicate class issue was reported upstream but was auto-closed, so I don't expect that it will be fixed. But IIUC the classes are generated and identical so technically it should be fine.
kubernetes-client/java#2874

@oheger-bosch

Copy link
Copy Markdown
Contributor Author

Advice for :transport:kubernetes
Existing dependencies which should be modified to be as indicated:
api(libs.kubernetesClientApiFluent) (was implementation)

You can also auto-fix such errors using the fixDependencies task: https://github.com/autonomousapps/dependency-analysis-gradle-plugin#fix-dependency-issues-automatically

Great, this did the trick! Many thanks.

@oheger-bosch oheger-bosch marked this pull request as ready for review June 18, 2026 10:31
Comment on lines +318 to +326
imageName = System.getenv("${prefix}IMAGE_NAME") ?: mainContainer.imageName,
imagePullPolicy = System.getenv("${prefix}IMAGE_PULL_POLICY") ?: mainContainer.imagePullPolicy,
commands = System.getenv("${prefix}COMMANDS")?.splitAtWhitespace() ?: mainContainer.commands,
args = System.getenv("${prefix}ARGS")?.splitAtWhitespace() ?: mainContainer.args,
cpuLimit = System.getenv("${prefix}CPU_LIMIT"),
cpuRequest = System.getenv("${prefix}CPU_REQUEST"),
memoryLimit = System.getenv("${prefix}MEMORY_LIMIT"),
memoryRequest = System.getenv("${prefix}MEMORY_REQUEST"),
volumeMounts = System.getenv("${prefix}VOLUME_MOUNTS").splitAt(splitCommaListRegex)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this also use the Config abstraction for consistency and more importantly it would allow to configure this in other means than env variables.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the Config interface, there is no mechanism I am aware of that could handle lists of objects with an arbitrary number of elements, which would be needed to define the additional containers and their properties. Therefore, I went for the approach to have one property with a list of container names, and the properties of these containers then have to be looked up via environment variables.

Comment thread transport/kubernetes/src/main/kotlin/VolumeMounts.kt Outdated
@oheger-bosch oheger-bosch force-pushed the oheger-bosch/kubernetes_multiple_containers branch from 0cfff75 to f35968e Compare June 22, 2026 10:16
Comment thread transport/kubernetes/src/test/kotlin/KubernetesMessageSenderFactoryTest.kt Outdated
Comment thread transport/kubernetes/src/test/kotlin/KubernetesMessageSenderFactoryTest.kt Outdated
Comment thread transport/kubernetes/src/test/kotlin/KubernetesMessageSenderFactoryTest.kt Outdated
Comment thread transport/kubernetes/src/test/kotlin/KubernetesMessageSenderFactoryTest.kt Outdated
Comment thread website/docs/admin-guide/infrastructure/transport/kubernetes.md Outdated
Extract a common interface for volume mount declarations and move the
logic to generate the Kubernetes manifest to the concrete
implementations. This simplifies the handling of such mounts. It is also
a preparation for an upcoming extension of the Kubernetes transport
implementation to support the creation of multiple containers in a pod.

Signed-off-by: Oliver Heger <oliver.heger@bosch.com>
The declaration of a volume mount can now include an optional name
assignment. This is going to be used later to configure which volume
mount should be added to which container in the resulting pod.

Signed-off-by: Oliver Heger <oliver.heger@bosch.com>
This internal helper function from the `:utils:config` module is useful
in general. Therefore, convert it to an extension function for easy usage
and make it public.

Signed-off-by: Oliver Heger <oliver.heger@bosch.com>
@oheger-bosch oheger-bosch force-pushed the oheger-bosch/kubernetes_multiple_containers branch from f35968e to e10de3d Compare June 23, 2026 06:13
Collect the properties for a container to create in a separate data
class. This is a preparation to support the declaration of multiple
containers.

To make this possible, slightly rework the mechanism for variable
substitution. This is no longer done by the configuration, but by the
sender when creating the Kubernetes manifest. This simplifies the code a
bit because no copy of the configuration with variables for interpolation
has to be created.

Signed-off-by: Oliver Heger <oliver.heger@bosch.com>
It is now possible to declare additional containers with all supported
properties. This enables some advanced use cases like adding side-car
containers to the ORT Server workers.

Extend the declaration of volume mounts, so that named volume mounts can
be added to a subset of containers only. This makes it possible for
instance, to mount secrets only into specific containers.

Signed-off-by: Oliver Heger <oliver.heger@bosch.com>
Allow additional containers to be declared as init containers. Handle
them correctly when setting up the Kubernetes manifest.

This makes it possible to run some initialization tasks before an ORT
Server worker gets active.

Signed-off-by: Oliver Heger <oliver.heger@bosch.com>
Describe the newly added functionality for additional containers and
named volume mounts.

Restructure the documentation to distinguish between pod-related and
container-related configuration properties. Order the properties
alphabetically.

Signed-off-by: Oliver Heger <oliver.heger@bosch.com>
This is necessary to fix a failed build-health check.

Signed-off-by: Oliver Heger <oliver.heger@bosch.com>
@oheger-bosch oheger-bosch force-pushed the oheger-bosch/kubernetes_multiple_containers branch from e10de3d to ba1ad98 Compare June 23, 2026 08:35
@oheger-bosch oheger-bosch added this pull request to the merge queue Jun 23, 2026
Merged via the queue into eclipse-apoapsis:main with commit e629e1c Jun 23, 2026
34 of 35 checks passed
@oheger-bosch oheger-bosch deleted the oheger-bosch/kubernetes_multiple_containers branch June 23, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants