[FLINK-37893][k8s] Make REST service port name configurable#28047
Open
1fanwang wants to merge 1 commit intoapache:masterfrom
Open
[FLINK-37893][k8s] Make REST service port name configurable#280471fanwang wants to merge 1 commit intoapache:masterfrom
1fanwang wants to merge 1 commit intoapache:masterfrom
Conversation
The Kubernetes REST service exposed by the JobManager hardcodes its port name to "rest" (Constants.REST_PORT_NAME). Operators in environments that enforce port-naming policies (e.g., service meshes that route by port name, or organizations with strict port-name conventions) cannot align Flink with those policies. This change adds a new config option kubernetes.rest-service.port-name (string, default "rest") that controls the port name on the REST Service. The default preserves existing behavior, making this a purely additive change. ServiceType#getRestPortFromExternalService no longer filters ports by name. Flink always builds the rest Service with a single port, so the lookup can simply return that port; this lets the reader work for any configured port name without plumbing the name through the abstract getRestEndpoint signature on ServiceType. KubernetesResourceManagerDriver#updateKubernetesServiceTargetPortIfNecessary reads the configured port name from flinkConfig when updating the rest service's target port in host-network mode.
fc792bc to
43d6396
Compare
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What is the purpose of the change
The Kubernetes REST service exposed by the JobManager hardcodes its port name to
"rest"(Constants.REST_PORT_NAME). Operators in environments that enforce port-naming policies — for example, service meshes that route by port name, or organizations with strict port-name conventions — cannot align Flink's rest service with those policies.This change adds a new config option
kubernetes.rest-service.port-name(string, default"rest") that controls the port name on the REST Service. The default preserves existing behavior, making this a purely additive change.Brief change log
kubernetes.rest-service.port-nameinKubernetesConfigOptions(default"rest")KubernetesJobManagerParameters#getRestServicePortName()ServiceType#buildUpExternalRestServiceuses the configured name instead ofConstants.REST_PORT_NAMEServiceType#getRestPortFromExternalServiceno longer filters ports by name. Flink always builds the rest Service with a single port, so the lookup can simply return that port; this lets the reader work for any configured name without plumbing it through the abstractgetRestEndpointsignature onServiceType(which would change a public surface and require updating all subclasses).KubernetesResourceManagerDriver#updateKubernetesServiceTargetPortIfNecessaryreads the configured port name fromflinkConfigwhen updating the rest service's target port in host-network modeVerifying this change
This change added tests and can be verified as follows:
ExternalServiceDecoratorTest#testDefaultRestServicePortName— verifies the default port name"rest"is used when the option is unsetExternalServiceDecoratorTest#testCustomRestServicePortName— verifies a custom port name ("flink-rest") propagates to the built ServiceServiceTypeTest#testGetRestPortFromExternalServiceWithDefaultName— verifies the reader works for a Service with the default port name (back-compat)ServiceTypeTest#testGetRestPortFromExternalServiceWithCustomName— verifies the reader works for a Service with a custom port nameServiceTypeTest#testGetRestPortFromExternalServiceFailsWhenNoPorts— verifies the error path when the Service has no portsmvn -pl flink-kubernetes -Dtest='*KubeClient*,*ServiceType*,*ServiceDecorator*,*JobManagerDecorator*,KubernetesResourceManagerDriverTest,KubernetesUtilsTest' test)Does this pull request potentially affect one of the following parts:
@Public(Evolving): yes —KubernetesConfigOptionsis@PublicEvolving. Adds a new option (additive).KubernetesResourceManagerDriver. No behavior change at default.Documentation
withDescription(auto-generated into the Flink config docs)Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (claude-opus-4-7)