Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Ingress class param bug fixed #3514

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object IngressController extends Logger {

private[this] val VERSION_REGEXP = "(\\d+\\.\\d+)".r

private lazy val clusterVersion = using(new DefaultKubernetesClient()) {
lazy val clusterVersion = using(new DefaultKubernetesClient()) {
client => VERSION_REGEXP.findFirstIn(client.getVersion.getGitVersion).get.toDouble
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ trait IngressStrategy {
}

def buildIngressAnnotations(clusterId: String, namespace: String): Map[String, String] = {
val annotations = Map(
"kubernetes.io/ingress.class" -> ingressClass,
Map(
"nginx.ingress.kubernetes.io/rewrite-target" -> "/$2",
"nginx.ingress.kubernetes.io/proxy-body-size" -> "1024m",
"nginx.ingress.kubernetes.io/configuration-snippet" -> s"""rewrite ^(/$clusterId)$$ $$1/ permanent; sub_filter '<base href="./">' '<base href="/$namespace/$clusterId/">'; sub_filter_once off;"""
)
annotations
}

def buildIngressLabels(clusterId: String): Map[String, String] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class IngressStrategyV1 extends IngressStrategy {
throw new RuntimeException(s"[StreamPark] get ingressUrlAddress error: $e")
}.get
}

}

override def configureIngress(domainName: String, clusterId: String, nameSpace: String): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.apache.streampark.common.util.Utils
import io.fabric8.kubernetes.api.model.IntOrString
import io.fabric8.kubernetes.api.model.networking.v1beta1.IngressBuilder
import io.fabric8.kubernetes.client.DefaultKubernetesClient
import org.apache.commons.lang3.StringUtils
import org.apache.flink.client.program.ClusterClient

import scala.collection.JavaConverters._
Expand Down Expand Up @@ -50,6 +51,17 @@ class IngressStrategyV1beta1 extends IngressStrategy {
}
}

override def buildIngressAnnotations(
clusterId: String,
namespace: String): Map[String, String] = {
val map = super.buildIngressAnnotations(clusterId, namespace)
if (StringUtils.isNotBlank(ingressClass)) {
Map("kubernetes.io/ingress.class" -> ingressClass) ++ map
} else {
map
}
}

override def configureIngress(domainName: String, clusterId: String, nameSpace: String): Unit = {
Utils.using(new DefaultKubernetesClient) {
client =>
Expand All @@ -62,7 +74,6 @@ class IngressStrategyV1beta1 extends IngressStrategy {
.addToOwnerReferences(ownerReference)
.endMetadata()
.withNewSpec()
.withIngressClassName(ingressClass)
.addNewRule()
.withHost(domainName)
.withNewHttp()
Expand Down
Loading