Skip to content

Consolidating the KafkaRebalance API for extensibility#216

Open
kyguy wants to merge 7 commits into
strimzi:mainfrom
kyguy:kr-restructure
Open

Consolidating the KafkaRebalance API for extensibility#216
kyguy wants to merge 7 commits into
strimzi:mainfrom
kyguy:kr-restructure

Conversation

@kyguy
Copy link
Copy Markdown
Member

@kyguy kyguy commented Apr 8, 2026

This proposal addresses the increasing complexity and limited extensibility of the KafkaRebalance custom resource API.

Signed-off-by: Kyle Liberti <kliberti.us@gmail.com>
@kyguy kyguy marked this pull request as ready for review April 14, 2026 00:15
@ppatierno
Copy link
Copy Markdown
Member

@kyguy is this ready to review? Should we add maintainers or are you still working on it?

Signed-off-by: Kyle Liberti <kliberti.us@gmail.com>
@kyguy kyguy changed the title Restructuring the KafkaRebalance API for extensibility Consolidating the KafkaRebalance API for extensibility Apr 15, 2026
@kyguy
Copy link
Copy Markdown
Member Author

kyguy commented Apr 15, 2026

@ppatierno yes, this is now ready for review! I'll request the maintainers as reviewers now

@kyguy kyguy requested a review from a team April 15, 2026 14:59
@ppatierno ppatierno requested review from Frawless, PaulRMellor, im-konge, katheris, ppatierno, scholzj, see-quick and tinaselenge and removed request for a team April 20, 2026 15:42
Comment thread 137-kafkarebalance-consolidation.md
Comment thread 137-kafkarebalance-consolidation.md Outdated
# Consolidating the KafkaRebalance API for extensibility

This proposal addresses the increasing complexity and limited extensibility of the `KafkaRebalance` custom resource API.
It introduces a `spec.parameters` map that replaces mode-specific primitive fields with their upstream Cruise Control key-value equivalents allowing users to consult Cruise Control documentation directly and enabling support for new parameters without Strimzi API changes.
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.

what about using spec.config as we have for other custom resources (i.e. Kafka, KafkaBridge, ...) ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

TBH in the original draft I had used spec.config for the sake of consistency with other custom resource configurations but then changed it to spec.parameters. I felt that using spec.parameters better emphasizes the distinction between configuration file properties and REST API query parameters. It should also help users avoid confusing these query parameters with the spec.cruiseControl.config options in the Kafka resource. WDYT?

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.

The KafkaRebalance is an abstraction on the top of the CC REST API so I can see your point of having a sort of 1:1 matching with the query parameters on the REST call ... but still not sure if having a more friendly and well-known name like "config" would be better for users in terms of UX. Let's see what others think before making any changes.

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.

I would personally go with .spec.config and have it consistent across all resources. Maybe it's just me, but I don't feel like we need to reflect the naming what we are using internally - and I think that users will not care that those are "parameters" for the REST API. So having parameters feels like it would be just something for us.

Copy link
Copy Markdown
Member Author

@kyguy kyguy Apr 21, 2026

Choose a reason for hiding this comment

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

Fair points, I switched it back to spec.config just to show what it would look like (I can easily change it back in a later commit) I'll leave this comment unresolved for now so people can see this conversation and add their thoughts whether it be for or against

Comment thread 137-kafkarebalance-consolidation.md Outdated
Comment thread 137-kafkarebalance-consolidation.md Outdated
Comment thread 137-kafkarebalance-consolidation.md Outdated
Signed-off-by: Kyle Liberti <kliberti.us@gmail.com>
Copy link
Copy Markdown
Member

@im-konge im-konge left a comment

Choose a reason for hiding this comment

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

Thanks for the proposal. I left few comments.

Comment thread 137-kafkarebalance-consolidation.md Outdated
# Consolidating the KafkaRebalance API for extensibility

This proposal addresses the increasing complexity and limited extensibility of the `KafkaRebalance` custom resource API.
It introduces a `spec.parameters` map that replaces mode-specific primitive fields with their upstream Cruise Control key-value equivalents allowing users to consult Cruise Control documentation directly and enabling support for new parameters without Strimzi API changes.
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.

I would personally go with .spec.config and have it consistent across all resources. Maybe it's just me, but I don't feel like we need to reflect the naming what we are using internally - and I think that users will not care that those are "parameters" for the REST API. So having parameters feels like it would be just something for us.

Comment thread 137-kafkarebalance-consolidation.md Outdated
- Strimzi will log a warning and write an error in the `KafkaRebalance` status when `brokers` or `volumes` are provided but irrelevant to the selected mode.

2. **Parameter field validation**:
- Strimzi does not pre-validate parameters entries.
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.

Maybe completely stupid question, but today we are pre-validating the parameters specified in the CR, right?
How it would work when you have some fields specified under old structure and some in new structure? Will it automatically skip the validation from now on or it will be semi-validated? (As I said, maybe completely stupid question, sorry).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not a stupid question at all.

Right now we only do loose validation on some of primitive fields that we’re planning to deprecate in favor of the new config. For example, we might enforce simple constraints like minimum values for fields such as concurrentPartitionMovementsPerBroker.

If a CR includes a mix of old and new structure, it won’t skip the validation of the deprecated primitive fields if they are included. That being said the parameters included as part of the new config will take preference. For example, if a primitive field is included with a valid value and it's equivalent field in the new config is included with an incorrect value, the KafkaRebalance resource will be put in the NotReady state and a condition with the error will be added.

Does that answer the question?

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.

Sorry I realized I didn't reply here - yeah it answers my question, thanks :)

Comment thread 137-kafkarebalance-consolidation.md
Signed-off-by: Kyle Liberti <kliberti.us@gmail.com>
Copy link
Copy Markdown
Contributor

@PaulRMellor PaulRMellor left a comment

Choose a reason for hiding this comment

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

The proposal is clear and well justified. I’ve added a few minor suggestions as I read through

Comment thread 137-kafkarebalance-consolidation.md Outdated
Comment thread 137-kafkarebalance-consolidation.md Outdated
Comment thread 137-kafkarebalance-consolidation.md Outdated
Comment thread 137-kafkarebalance-consolidation.md Outdated
Comment thread 137-kafkarebalance-consolidation.md Outdated
Comment thread 137-kafkarebalance-consolidation.md Outdated
Comment thread 137-kafkarebalance-consolidation.md Outdated
Comment thread 137-kafkarebalance-consolidation.md Outdated
Comment thread 137-kafkarebalance-consolidation.md Outdated
Comment thread 137-kafkarebalance-consolidation.md Outdated

2. **Parameter field validation**:
- Strimzi won't pre-validate new config parameter entries.
Strimzi will pass the config parameters as-is to the Cruise Control REST API.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any security considerations to mention here? Or how compatibility is handled between Strimzi and Cruise Control versions?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for raising this, there actually should be some parameter validation to mitigate users accidentally breaking the KafkaRebalance state machine and status. I have just added some notes on filtering parameters in the latest commit.

The parameter filtering should address any potential misuse or security concerns. As for compatibility between Strimzi and Cruise Control versions, a parameter that is unsupported by the bundle Cruise Control version will be rejected by Cruise Control at runtime and Strimzi will surface the error by transitioning the KafkaRebalance resource.

Did I understand/answer the question correctly @PaulRMellor?

kyguy and others added 2 commits April 23, 2026 14:06
Co-authored-by: PaulRMellor <47596553+PaulRMellor@users.noreply.github.com>
Signed-off-by: Kyle Liberti <kliberti@redhat.com>
Signed-off-by: Kyle Liberti <kliberti.us@gmail.com>
@kyguy
Copy link
Copy Markdown
Member Author

kyguy commented May 4, 2026

This is ready for another round of reviews whenever people have time of course!

@kyguy kyguy requested a review from fvaleri May 4, 2026 12:39
Comment thread 137-kafkarebalance-consolidation.md Outdated
Comment thread 137-kafkarebalance-consolidation.md Outdated
1. **Introduce the new `config` map and `volumes` field** while maintaining backward compatibility:
- Accept both old top-level primitive fields and new `config` map.
- Accept both `moveReplicasOffVolumes` and `volumes` (mapped to the same internal representation)
- If both old and new forms are provided, the new form takes precedence
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.

I think we could even log a warning that they are both set but the old form will be ignored.

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.

Also what happens in the following scenario?

spec:           
    concurrentPartitionMovementsPerBroker: 10  # old                                                                                                                                                                   
    config:                                         
      concurrent_leader_movements: "5"  # new but different field 

Is the logic going to ignore the old concurrentPartitionMovementsPerBroker because the resource has a spec.config field or it's going to make a merge because they are referring to two different fields?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It would make a merge, respecting both fields and values but a warning would still be logged for the usage of the old concurrentPartitionMovementsPerBroker form.

Copy link
Copy Markdown
Member Author

@kyguy kyguy May 4, 2026

Choose a reason for hiding this comment

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

Just updated some text here in to address the first comment in the latest commit, let me know what you think!

Copy link
Copy Markdown
Member

@ppatierno ppatierno May 5, 2026

Choose a reason for hiding this comment

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

I would expect a merge yes, but at the same time, if our goal is discourage the usage of the current properties in favor of the config section, we could also decide that if you set the config section, it's going to override everything else coming from the dedicated fields. It could be counterintuitive though. In the past we had something similar with templates across Kafka and KafkaNodePool and we moved from an override approach to a merge. Let's see what others think about this.

Comment thread 137-kafkarebalance-consolidation.md Outdated
Signed-off-by: Kyle Liberti <kliberti.us@gmail.com>
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.

4 participants