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

add ingress annotation: kubernetes.io/ingress.class #2999

Merged
merged 1 commit into from
Sep 1, 2023
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 @@ -56,6 +56,18 @@ object K8sFlinkConfig {
description = "retained tracking time for SILENT state flink tasks"
)

/**
* If an ingress controller is specified in the configuration, the ingress class
* kubernetes.io/ingress.class must be specified when creating the ingress, since there are often
* multiple ingress controllers in a production environment.
*/
val ingressClass: InternalOption = InternalOption(
key = "streampark.flink-k8s.ingress.class",
defaultValue = "streampark",
classType = classOf[java.lang.String],
description = "Direct ingress to the ingress controller."
)

/** kubernetes default namespace */
val DEFAULT_KUBERNETES_NAMESPACE = "default"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ streampark:
polling-interval-sec:
job-status: 2
cluster-metric: 3
# If you need to specify an ingress controller, you can use this.
ingress:
class: nginx

# packer garbage resources collection configuration
packer-gc:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.streampark.flink.kubernetes.ingress

import org.apache.streampark.common.conf.ConfigConst
import org.apache.streampark.common.conf.{ConfigConst, InternalConfigHolder, K8sFlinkConfig}

import io.fabric8.kubernetes.api.model.{OwnerReference, OwnerReferenceBuilder}
import io.fabric8.kubernetes.client.DefaultKubernetesClient
Expand Down Expand Up @@ -48,11 +48,16 @@ trait IngressStrategy {
}

def buildIngressAnnotations(clusterId: String): Map[String, String] = {
Map(
val annotations = Map(
"nginx.ingress.kubernetes.io/rewrite-target" -> "/$2",
"nginx.ingress.kubernetes.io/proxy-body-size" -> "1024m",
"nginx.ingress.kubernetes.io/configuration-snippet" -> ("rewrite ^(/" + clusterId + ")$ $1/ permanent;")
)
val ingressClass = InternalConfigHolder.get[String](K8sFlinkConfig.ingressClass)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be improved to make the logic clearer:

val ingressClass = InternalConfigHolder.get[String](K8sFlinkConfig.ingressClass)
if (ingressClass.nonEmpty) {
  annotations + ("kubernetes.io/ingress.class" -> ingressClass)
}
annotations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

if (ingressClass.nonEmpty) {
annotations + ("kubernetes.io/ingress.class" -> ingressClass)
}
annotations
}

def buildIngressLabels(clusterId: String): Map[String, String] = {
Expand Down
Loading