Specify HostPort when creating cluster
Discussed in https://github.com/apecloud/kubeblocks/discussions/9785
Originally posted by dudizimber September 30, 2025 We have a use case where we deploy multiple databases of the same type in a single k8s cluster. The database requires external access via HostNetwork. In our specific setup, the service port cannot be randomly generated and has to be specified when creating the Cluster, since not all databases will listen to the same port, even if they are of the same type.
While trying it out, I saw that the PortManager is the one that allocates a random port (not really random, but also not known before the allocation), and it does so by storing the allocated ports in a single configmap for the whole cluster, in the structure:
<pod>-<container>-<portName>: <portNumber>
Hence, in my interpretation, all databases in the k8s cluster of the same type (pod name) will receive the same port, as it always checks the name and returns the same port if it exists.
My question is if there's a way to accomplish that without modifying the operator. Meaning that, when using HostNetwork, the port could be defined on the Cluster manifest.
@dudizimber we can discuss the feature and impl here
cc @leon-inf
@dudizimber here is my understanding of the whole thing:
- users specify host port when creating cluster
- KB uses the ports insteading of allocating ports on demand
But one constraint still holds that Pods/Replicas from the same compont, e.g. falkordb, still share the same set of ports (as it is in KB now). Is it acceptable ?
@dudizimber here is my understanding of the whole thing:
- users specify host port when creating cluster
- KB uses the ports insteading of allocating ports on demand
But one constraint still holds that Pods/Replicas from the same compont, e.g. falkordb, still share the same set of ports (as it is in KB now). Is it acceptable ?
I believe that's not only acceptable but also required.
The question is whether the ideal place to put a hostPort parameter is in the componentSpecs or under componentSpecs.*.instances
in my understanding, place it to the componentSpecs level is better, it is a componet-layer setting. @leon-inf what do you think.
in my understanding, place it to the componentSpecs level is better, it is a componet-layer setting. @leon-inf what do you think.
Yeah, adding the parameter to 'spec.componentSpecs.network' is ideal. Meanwhile, there are some special details that should be taken into account, and I'll provide this feature in the next few days.
in my understanding, place it to the componentSpecs level is better, it is a componet-layer setting. @leon-inf what do you think.
Yeah, adding the parameter to 'spec.componentSpecs.network' is ideal. Meanwhile, there are some special details that should be taken into account, and I'll provide this feature in the next few days.
@leon-inf I'm working on this PR https://github.com/apecloud/kubeblocks/pull/9820 if you want to guide me.
This issue has been marked as stale because it has been open for 30 days with no activity