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

Flink k8s v2 #2975

Closed
wants to merge 2 commits into from
Closed
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 @@ -51,6 +51,13 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.streampark</groupId>
<artifactId>streampark-flink-kubernetes-core_${scala.binary.version}</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-yarn${scala.binary.flink.version}</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ import org.apache.streampark.common.util.Utils
import org.apache.streampark.flink.client.`trait`.KubernetesNativeClientTrait
import org.apache.streampark.flink.client.bean._
import org.apache.streampark.flink.packer.pipeline.DockerImageBuildResponse

import com.google.common.collect.Lists
import org.apache.commons.lang3.StringUtils
import org.apache.flink.client.deployment.application.ApplicationConfiguration
import org.apache.flink.client.program.ClusterClient
import org.apache.flink.configuration.{Configuration, DeploymentOptions, PipelineOptions}
import org.apache.flink.kubernetes.KubernetesClusterDescriptor
import org.apache.flink.kubernetes.configuration.KubernetesConfigOptions
import org.apache.flink.v1beta1.FlinkDeploymentSpec.FlinkVersion
import org.apache.streampark.flink.kubernetes.v2.model.{FlinkDeploymentDef, JobDef, JobManagerDef, TaskManagerDef}
import org.apache.streampark.flink.kubernetes.v2.observer.FlinkK8sObserver
import org.apache.streampark.flink.kubernetes.v2.operator.FlinkK8sOperator

/** kubernetes native application mode submit */
object KubernetesNativeApplicationClient extends KubernetesNativeClientTrait {
Expand Down Expand Up @@ -66,9 +69,15 @@ object KubernetesNativeApplicationClient extends KubernetesNativeClientTrait {
val (descriptor, clusterSpecification) = getK8sClusterDescriptorAndSpecification(flinkConfig)
clusterDescriptor = descriptor
val applicationConfig = ApplicationConfiguration.fromConfiguration(flinkConfig)
clusterClient = clusterDescriptor
.deployApplicationCluster(clusterSpecification, applicationConfig)
.getClusterClient
// clusterClient = clusterDescriptor
// .deployApplicationCluster(clusterSpecification, applicationConfig)
// .getClusterClient

val spec = convertFlinkDeploymentDef(submitRequest)

for {
_ <- FlinkK8sOperator.deployApplicationJob(114514, spec)
} yield ()

val clusterId = clusterClient.getClusterId
val result = SubmitResponse(
Expand Down Expand Up @@ -103,4 +112,34 @@ object KubernetesNativeApplicationClient extends KubernetesNativeClientTrait {
flinkConf.safeSet(DeploymentOptions.TARGET, ExecutionMode.KUBERNETES_NATIVE_APPLICATION.getName)
super.doTriggerSavepoint(request, flinkConf)
}

def convertFlinkDeploymentDef(submitRequest: SubmitRequest): FlinkDeploymentDef ={
val spec = FlinkDeploymentDef (
name = submitRequest.appName,
namespace = submitRequest.k8sSubmitParam.kubernetesNamespace,
image = "flink:" + submitRequest.flinkVersion.version,
flinkVersion = convertflinkVersion(submitRequest.flinkVersion.version),
jobManager = JobManagerDef(cpu = 1, submitRequest.properties.get("jobmanager.memory.process.size").toString),
taskManager = TaskManagerDef(cpu = 1, submitRequest.properties.get("taskmanager.memory.process.size").toString),
job = Some(
JobDef(
jarURI = submitRequest.userJarFile.getAbsolutePath,
parallelism = submitRequest.properties.get("parallelism.default").asInstanceOf[Int]
))
)
spec
}

def convertflinkVersion(version: String) : FlinkVersion ={
val parts = version.split("\\.")
val extracted = parts(0) + parts(1)
extracted match {
case "1.17" => FlinkVersion.V1_17
case "1.16" => FlinkVersion.V1_16
case "1.15" => FlinkVersion.V1_15
case "1.14" => FlinkVersion.V1_14
case "1.13" => FlinkVersion.V1_13
case _ => null
}
}
}
Loading