You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@streampark.apache.org by "wolfboys (via GitHub)" <gi...@apache.org> on 2023/04/25 06:32:31 UTC

[GitHub] [incubator-streampark] wolfboys commented on a diff in pull request #2697: [Improve]Ingress uses different versions of API according to differen…

wolfboys commented on code in PR #2697:
URL: https://github.com/apache/incubator-streampark/pull/2697#discussion_r1176058673


##########
streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/IngressController.scala:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.streampark.flink.kubernetes.ingress
+
+import org.apache.streampark.common.util.Logger
+
+import io.fabric8.kubernetes.client.DefaultKubernetesClient
+import org.apache.flink.client.program.ClusterClient
+
+import scala.language.postfixOps
+
+object IngressController extends Logger {
+
+  val ingressStrategy: IngressStrategy = {

Review Comment:
   ``` 
    private lazy val ingressStrategy: IngressStrategy = {
       val client = new DefaultKubernetesClient()
       val versionInfo = client.getVersion
       val version = s"${versionInfo.getMajor}.${versionInfo.getMajor}".toDouble
       if (version >= 1.19) {
         new IngressStrategyV1()
       } else {
         new IngressStrategyV1beta1()
       }
     }
   ```



##########
streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/BaseIngressStrategy.scala:
##########
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.streampark.flink.kubernetes.ingress
+
+import org.apache.streampark.common.util.Utils._
+
+import io.fabric8.kubernetes.client.DefaultKubernetesClient
+import org.apache.commons.io.FileUtils
+import org.apache.flink.client.program.ClusterClient
+import org.json4s.{DefaultFormats, JArray}
+import org.json4s.jackson.JsonMethods.parse
+
+import java.io.File
+import java.nio.file.{Files, Paths}
+
+import scala.language.postfixOps
+import scala.util.{Failure, Success, Try}
+
+abstract class BaseIngressStrategy extends IngressStrategy {
+  override def ingressUrlAddress(

Review Comment:
   This method is not suitable for writing here, should be subclasses(IngressStrategyV1 | IngressStrategyV1beta1) to implement



##########
streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/ingress/IngressController.scala:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.streampark.flink.kubernetes.ingress
+
+import org.apache.streampark.common.util.Logger
+
+import io.fabric8.kubernetes.client.DefaultKubernetesClient
+import org.apache.flink.client.program.ClusterClient
+
+import scala.language.postfixOps
+
+object IngressController extends Logger {
+
+  val ingressStrategy: IngressStrategy = {
+    if (getKubernetesVersion() >= 1.19) new IngressStrategyV1()
+    else new IngressStrategyV1beta1()
+  }
+
+  def configureIngress(domainName: String, clusterId: String, nameSpace: String): Unit = {
+    ingressStrategy.configureIngress(domainName, clusterId, nameSpace)
+  }
+
+  def ingressUrlAddress(
+      nameSpace: String,
+      clusterId: String,
+      clusterClient: ClusterClient[_]): String = {
+    ingressStrategy.ingressUrlAddress(nameSpace, clusterId, clusterClient)
+  }
+
+  def prepareIngressTemplateFiles(buildWorkspace: String, ingressTemplates: String): String = {
+    ingressStrategy.prepareIngressTemplateFiles(buildWorkspace, ingressTemplates)
+  }
+
+  def getKubernetesVersion(): Double = {

Review Comment:
   We can remove this method



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org