Al-assad commented on code in PR #2584:
URL:
https://github.com/apache/incubator-streampark/pull/2584#discussion_r1160593852
##########
streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/IngressController.scala:
##########
@@ -122,17 +122,18 @@ object IngressController extends Logger {
def ingressUrlAddress(nameSpace: String, clusterId: String, clusterClient:
ClusterClient[_]): String = {
if (determineIfIngressExists(nameSpace, clusterId)) {
val client = new DefaultKubernetesClient
- val ingress =
client.network.ingress.inNamespace(nameSpace).withName(clusterId).get
- val publicEndpoints =
ingress.getMetadata.getAnnotations.get("field.cattle.io/publicEndpoints")
- IngressMeta.as(publicEndpoints) match {
- case Some(metas) =>
- val ingressMeta = metas.head
- val hostname = ingressMeta.hostname
- val path = ingressMeta.path
- logger.info(s"Retrieve flink cluster $clusterId successfully,
JobManager Web Interface: https://$hostname$path")
- s"https://$hostname$path"
- case None => throw new RuntimeException("[StreamPark] get
ingressUrlAddress error.")
- }
+ // for kubernetes 1.22+
+ val fromV1 =
Option(client.network.v1.ingresses.inNamespace(nameSpace).withName(clusterId).get)
+ .map(ingress => ingress.getSpec.getRules.get(0))
+ .map(rule => rule.getHost -> rule.getHttp.getPaths.get(0).getPath)
+ // for kubernetes 1.22-
+ val fromV1beta1 =
Option(client.network.v1beta1.ingresses.inNamespace(nameSpace).withName(clusterId).get)
+ .map(ingress => ingress.getSpec.getRules.get(0))
+ .map(rule => rule.getHost -> rule.getHttp.getPaths.get(0).getPath)
+ Try {
+ fromV1.orElse(fromV1beta1)
+ .map { case (host, path) => s"https://$host$path" }.get
Review Comment:
It is necessary to fallback to the native Flink web interface retrieval
method for `.getOrElse(clusterClient.getWebInterfaceURL)`, in the case where
there is no corresponding ingress object available through both v1 and v1beta.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]