Skip to content

[FLINK-37893][k8s] Make REST service port name configurable#28047

Open
1fanwang wants to merge 1 commit intoapache:masterfrom
1fanwang:FLINK-37893-rest-service-port-name
Open

[FLINK-37893][k8s] Make REST service port name configurable#28047
1fanwang wants to merge 1 commit intoapache:masterfrom
1fanwang:FLINK-37893-rest-service-port-name

Conversation

@1fanwang
Copy link
Copy Markdown

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

  • New config option kubernetes.rest-service.port-name in KubernetesConfigOptions (default "rest")
  • New getter KubernetesJobManagerParameters#getRestServicePortName()
  • ServiceType#buildUpExternalRestService uses the configured name instead of Constants.REST_PORT_NAME
  • 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 name without plumbing it through the abstract getRestEndpoint signature on ServiceType (which would change a public surface and require updating all subclasses).
  • KubernetesResourceManagerDriver#updateKubernetesServiceTargetPortIfNecessary reads the configured port name from flinkConfig when updating the rest service's target port in host-network mode

Verifying 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 unset
  • ExternalServiceDecoratorTest#testCustomRestServicePortName — verifies a custom port name ("flink-rest") propagates to the built Service
  • ServiceTypeTest#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 name
  • ServiceTypeTest#testGetRestPortFromExternalServiceFailsWhenNoPorts — verifies the error path when the Service has no ports
  • All 106 existing tests in the kubeclient/services/decorators packages continue to pass (mvn -pl flink-kubernetes -Dtest='*KubeClient*,*ServiceType*,*ServiceDecorator*,*JobManagerDecorator*,KubernetesResourceManagerDriverTest,KubernetesUtilsTest' test)

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): yes — KubernetesConfigOptions is @PublicEvolving. Adds a new option (additive).
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: yes — affects native Kubernetes JobManager Service builder and KubernetesResourceManagerDriver. No behavior change at default.
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? yes
  • If yes, how is the feature documented? config option withDescription (auto-generated into the Flink config docs)

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code (claude-opus-4-7)

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.
@1fanwang 1fanwang force-pushed the FLINK-37893-rest-service-port-name branch from fc792bc to 43d6396 Compare April 27, 2026 09:02
@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented Apr 27, 2026

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

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.

2 participants