zhisheng17/flink-learning · error · RuntimeException
Could not get the rest endpoint of ${clusterId}
Error message
Could not get the rest endpoint of ${clusterId} What it means
Thrown by KubernetesClusterDescriptor.createClusterClientProvider when the FlinkKubeClient returns no REST endpoint for the given clusterId, meaning the JobManager service exists but did not expose a usable REST endpoint. It wraps a ClusterRetrieveException inside a RuntimeException, aborting retrieval of a client for an existing cluster.
Source
Thrown at flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/KubernetesClusterDescriptor.java:98
"ClusterId must be specified!");
}
@Override
public String getClusterDescription() {
return CLUSTER_DESCRIPTION;
}
private ClusterClientProvider<String> createClusterClientProvider(String clusterId) {
return () -> {
final Configuration configuration = new Configuration(flinkConfig);
final Optional<Endpoint> restEndpoint = client.getRestEndpoint(clusterId);
if (restEndpoint.isPresent()) {
configuration.setString(RestOptions.ADDRESS, restEndpoint.get().getAddress());
configuration.setInteger(RestOptions.PORT, restEndpoint.get().getPort());
} else {
throw new RuntimeException(
new ClusterRetrieveException(
"Could not get the rest endpoint of " + clusterId));
}
try {
// Flink client will always use Kubernetes service to contact with jobmanager. So we have a pre-configured web
// monitor address. Using StandaloneClientHAServices to create RestClusterClient is reasonable.
return new RestClusterClient<>(
configuration,
clusterId,
new StandaloneClientHAServices(getWebMonitorAddress(configuration)));
} catch (Exception e) {
client.handleException(e);
throw new RuntimeException(new ClusterRetrieveException("Could not create the RestClusterClient.", e));
}
};
}
View on GitHub (pinned to d731cee761)
Solutions
- Wait for the JobManager pod and its REST service endpoints to become Ready before calling getRestEndpoint (kubectl get endpoints <clusterId>).
- Verify the clusterId matches an actually running Flink cluster (kubectl get svc | grep <clusterId>).
- Check JobManager pod logs/events for startup crashes and fix the underlying deployment failure.
- Inspect Kubernetes service labels/selectors — if the selector does not match the JobManager pod the service will have no endpoints.
- Increase timeout/retry logic around cluster retrieval in your launcher.
Example fix
// before: retrieve immediately after deploy
ClusterClient<String> client = descriptor.deploySessionCluster(spec).getClusterClient();
// after: wait for REST service endpoints first
await().atMost(2, MINUTES).until(() ->
kubeClient.getService(KubernetesService.ServiceType.REST_SERVICE, clusterId).isPresent()
&& kubectlEndpointsReady(clusterId));
ClusterClient<String> client = provider.getClusterClient(); Defensive patterns
Strategy: retry
Validate before calling
// verify REST service has endpoints before retrieval
Optional<KubernetesService> svc = kubeClient.getService(KubernetesService.ServiceType.REST_SERVICE, clusterId);
if (svc.isEmpty()) throw new IllegalStateException("REST service for " + clusterId + " missing"); Try / catch
try {
ClusterClient<String> client = provider.getClusterClient();
} catch (RuntimeException e) {
if (e.getCause() instanceof ClusterRetrieveException) {
// back off and retry until JobManager endpoints are Ready
}
} Prevention
- Wait for pod Ready + service endpoints before retrieving the client
- Confirm clusterId matches a live cluster
- Monitor JobManager startup logs
- Add bounded retry with backoff around cluster retrieval
When it happens
Trigger: Calling clusterClientProvider or deployClusterInternal after deployment when the Kubernetes REST service for clusterId was not found or had no endpoint addresses (e.g. service exists but JobManager pod not ready/no endpoints).
Common situations: Retrieving a cluster immediately after deploying before the JobManager pod becomes Ready; JobManager crashed after service creation; kube-proxy/DNS issues leaving the service with no endpoints; wrong clusterId pointing at a stale service.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Could not create the RestClusterClient.
- The Flink cluster ${clusterId} already exists.
- Couldn't deploy Kubernetes Application Cluster. Expected dep
- Per-Job Mode not supported by Active Kubernetes deployments.
- Could not create Kubernetes cluster "${clusterId}".
AI-assisted analysis of zhisheng17/flink-learning@d731cee761 (2026-09-06).
Data as JSON: /api/errors/53292dc8c4b95f2e.
Report an issue: GitHub.