Allow constraining dynamic listener ports to a specific port interval (range) #199
+126
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A common operating scheme for Kafka and Kafka-compatible systems like for example Redpanda, is to apply rolling upgrades with monotonically increasing broker IDs. In our specific use case, using Redpanda Cloud, it turned out that broker IDs are monotonically increasing with each version upgrade or replacement (e.g. if a broker is move to another machine). Broker IDs are implemented as signed 32-bit integers, and by conventions only zero and positive integers are used. TCP ports are 16-bit unsigned integers and thus we cannot simply increase port numbers beyond what fits into a 16-bit unsigned integer and we can also not use Broker IDs as port numbers (e.g. as is currently implemented for deterministic listeners).
Therefore with this PR we introduce the following backward compatible changes:
uint16
(instead ofint
).dynamic-sequential-max-ports
, specifying the maximum number of ports that can be used for dynamic listeners. Effectively, in combination withdynamic-sequential-min-port
allowing users to define a half open port interval[dynamic-sequential-min-port, dynamic-sequential-min-port + dynamic-sequential-max-ports)
, which is used to allocated dynamic ports.deterministic-listeners
ordynamic-sequential-max-ports
is set,dynamic-sequential-min-port
must also be set to a positive (non-zero) value.dynamic-sequential-max-ports
defaults to65536 - dynamic-sequential-min-port
ifdynamic-sequential-min-port
is set to a non-zero value.With those changes in place, dynamic port allocation will now only allocate ports from the above mentioned half open interval and will automatically wrap-over (safely-overflow) to the start of the interval when it reaches the end of the interval. The only exception is if
dynamic-sequential-min-port
is not set respectively is set to0
, in that case we still delegate allocation of (random) free ephemeral ports to the OS.Motivation for this PR
Why do we need this changes, which problems are we solving?
kafka-proxy
behind a Kubernetes Service, which needs explicit definition of all ports.