Skip to content

[Enhancement]: Add Support for Configuring ContainerPorts #12232

@kincoy

Description

@kincoy

Related problem

In our deployment we need to expose additional container ports on the main Kafka container (for example, for custom monitoring endpoints and health checks on a slightly modified Kafka distribution).

With the current Strimzi configuration options, it does not seem possible to configure extra containerPorts on the Kafka container managed by the operator. The template.kafkaContainer section lets us customize some aspects of the container (env, etc.), but there is no way to add or override the ports list.

As a result, we cannot declare these extra ports in the Kafka CR, which makes it harder to integrate with Kubernetes-level tooling that relies on container ports (probes, NetworkPolicy, Service mesh sidecars, etc.).

Suggested solution

It would be very helpful if both Kafka.spec.kafka.template.kafkaContainer and KafkaNodePool.spec.template.kafkaContainer allowed configuring the container ports in a declarative way.

For example, something along the lines of:

apiVersion: kafka.strimzi.io/v1beta2
kind: Kafka
spec:
  kafka:
    template:
      kafkaContainer:
        ports:
          - name: custom-metrics
            containerPort: 8890
          - name: custom-health
            containerPort: 8891
---
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaNodePool
spec:
  # ...
  template:
    kafkaContainer:
      ports:
        - name: custom-metrics
          containerPort: 8890
        - name: custom-health
          containerPort: 8891

In both cases, template.kafkaContainer.ports would be treated as additional ports merged with the defaults, so that users only need to declare the extra ports they require.

Alternatives

None.

Additional context

  • Our Kafka image has some minor customizations (e.g. extra monitoring/health endpoints) that rely on these additional ports being declared in the container spec.
  • If you have a recommended pattern for this use case with the existing API and we have missed it, we would also appreciate any pointers to the documentation or examples.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions