You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/04/16 05:55:31 UTC
[GitHub] [flink] zhengcanbin commented on a change in pull request #11715:
[FLINK-16598][k8s] Respect the rest-port exposed by the external Service
when retrieving Endpoint
zhengcanbin commented on a change in pull request #11715: [FLINK-16598][k8s] Respect the rest-port exposed by the external Service when retrieving Endpoint
URL: https://github.com/apache/flink/pull/11715#discussion_r409299161
##########
File path: flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClient.java
##########
@@ -264,17 +263,32 @@ private void setOwnerReference(Deployment deployment, List<HasMetadata> resource
}
/**
- * To get nodePort of configured ports.
+ * Get rest port from the external Service.
*/
- private int getServiceNodePort(Service service, ConfigOption<Integer> configPort) {
- final int port = this.flinkConfig.getInteger(configPort);
- if (service.getSpec() != null && service.getSpec().getPorts() != null) {
- for (ServicePort p : service.getSpec().getPorts()) {
- if (p.getPort() == port) {
- return p.getNodePort();
- }
- }
+ private int getRestPortFromExternalService(Service externalService) {
+ final List<ServicePort> servicePortCandidates = externalService.getSpec().getPorts()
+ .stream()
+ .filter(x -> x.getName().equals(Constants.REST_PORT_NAME))
+ .collect(Collectors.toList());
+
+ if (servicePortCandidates.isEmpty()) {
+ throw new RuntimeException("Failed to find port \"" + Constants.REST_PORT_NAME + "\" in Service \"" +
+ KubernetesUtils.getRestServiceName(this.clusterId) + "\"");
+ }
+
+ final ServicePort externalServicePort = servicePortCandidates.get(0);
+
+ final KubernetesConfigOptions.ServiceExposedType externalServiceType =
+ KubernetesConfigOptions.ServiceExposedType.valueOf(externalService.getSpec().getType());
+
+ switch (externalServiceType) {
+ case ClusterIP:
+ case LoadBalancer:
Review comment:
If the cluster does not provide the LoadBalancer, I think we should throw Exception instead of return the NodePort URL. Can we separate the Service type more clearly?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services