Unverified Commit 4f949d87 authored by gaoyan's avatar gaoyan Committed by GitHub

k8s operator支持 (#1704)

* k8s operator支持 * fix k8s-operator build err * fix fasterxml.jackson import wrong * fix npe at first submit operator * fix sql err * delete cluster before submit * Optimize Maven packaging by removing unnecessary k8s dependencies after packaging, and modify the k8s native mode connectivity detection logic to be compatible with operator. * add some custome option * add some custome option support custome yaml config jobmanager and taskmanager * optimize code * optimize code --------- Co-authored-by: 's avatar高岩 <34333571+ikiler@users.noreply.github.com>
parent fad64b4d
...@@ -192,6 +192,12 @@ ...@@ -192,6 +192,12 @@
<dependency> <dependency>
<groupId>org.dinky</groupId> <groupId>org.dinky</groupId>
<artifactId>dinky-gateway</artifactId> <artifactId>dinky-gateway</artifactId>
<exclusions>
<exclusion>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
package org.dinky.service.impl; package org.dinky.service.impl;
import static org.dinky.gateway.config.GatewayConfig.FLINK_VERSION;
import org.dinky.config.Docker; import org.dinky.config.Docker;
import org.dinky.db.service.impl.SuperServiceImpl; import org.dinky.db.service.impl.SuperServiceImpl;
import org.dinky.gateway.GatewayType; import org.dinky.gateway.GatewayType;
...@@ -30,6 +32,7 @@ import org.dinky.job.JobManager; ...@@ -30,6 +32,7 @@ import org.dinky.job.JobManager;
import org.dinky.mapper.ClusterConfigurationMapper; import org.dinky.mapper.ClusterConfigurationMapper;
import org.dinky.model.ClusterConfiguration; import org.dinky.model.ClusterConfiguration;
import org.dinky.model.FlinkClusterConfiguration; import org.dinky.model.FlinkClusterConfiguration;
import org.dinky.model.FlinkClusterConfiguration.Type;
import org.dinky.service.ClusterConfigurationService; import org.dinky.service.ClusterConfigurationService;
import org.dinky.utils.DockerClientUtils; import org.dinky.utils.DockerClientUtils;
...@@ -131,6 +134,10 @@ public class ClusterConfigurationServiceImpl ...@@ -131,6 +134,10 @@ public class ClusterConfigurationServiceImpl
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} else if (config.getType() == Type.KubernetesOperator) {
gatewayConfig.setType(GatewayType.KUBERNETES_APPLICATION_OPERATOR);
config.getKubernetesConfig().put(FLINK_VERSION, config.getFlinkVersion());
flinkConfig.setFlinkKubetnetsConfig(config.getKubernetesConfig());
} }
return JobManager.testGateway(gatewayConfig); return JobManager.testGateway(gatewayConfig);
......
...@@ -966,7 +966,9 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -966,7 +966,9 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
config.isUseRemote(), task.getClusterId())); config.isUseRemote(), task.getClusterId()));
} else if (Dialect.KUBERNETES_APPLICATION.equalsVal(task.getDialect()) } else if (Dialect.KUBERNETES_APPLICATION.equalsVal(task.getDialect())
// support custom K8s app submit, rather than clusterConfiguration // support custom K8s app submit, rather than clusterConfiguration
&& GatewayType.KUBERNETES_APPLICATION.equalsValue(config.getType())) { && (GatewayType.KUBERNETES_APPLICATION.equalsValue(config.getType())
|| GatewayType.KUBERNETES_APPLICATION_OPERATOR.equalsValue(
config.getType()))) {
Map<String, Object> taskConfig = Map<String, Object> taskConfig =
JSONUtil.toMap(task.getStatement(), String.class, Object.class); JSONUtil.toMap(task.getStatement(), String.class, Object.class);
Map<String, Object> clusterConfiguration = Map<String, Object> clusterConfiguration =
...@@ -979,7 +981,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -979,7 +981,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
clusterConfigurationService.getGatewayConfig(task.getClusterConfigurationId()); clusterConfigurationService.getGatewayConfig(task.getClusterConfigurationId());
// submit application type with clusterConfiguration // submit application type with clusterConfiguration
if (GatewayType.YARN_APPLICATION.equalsValue(config.getType()) if (GatewayType.YARN_APPLICATION.equalsValue(config.getType())
|| GatewayType.KUBERNETES_APPLICATION.equalsValue(config.getType())) { || GatewayType.KUBERNETES_APPLICATION.equalsValue(config.getType())
|| GatewayType.KUBERNETES_APPLICATION_OPERATOR.equalsValue(config.getType())) {
if (isJarTask) { if (isJarTask) {
Jar jar = jarService.getById(task.getJarId()); Jar jar = jarService.getById(task.getJarId());
Assert.check(jar); Assert.check(jar);
...@@ -1048,9 +1051,11 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1048,9 +1051,11 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
History history = historyService.getById(jobInstance.getHistoryId()); History history = historyService.getById(jobInstance.getHistoryId());
history.setConfig(JSONUtil.parseObject(history.getConfigJson())); history.setConfig(JSONUtil.parseObject(history.getConfigJson()));
if (Asserts.isNotNull(history.getClusterConfigurationId())) { if (Asserts.isNotNull(history.getClusterConfigurationId())) {
jobInfoDetail.setClusterConfiguration( ClusterConfiguration clusterConfigById =
clusterConfigurationService.getClusterConfigById( clusterConfigurationService.getClusterConfigById(
history.getClusterConfigurationId())); history.getClusterConfigurationId());
jobInfoDetail.setClusterConfiguration(clusterConfigById);
jobInfoDetail.getInstance().setType(history.getType());
} }
jobInfoDetail.setHistory(history); jobInfoDetail.setHistory(history);
jobInfoDetail.setJobHistory(jobHistoryService.getJobHistory(id)); jobInfoDetail.setJobHistory(jobHistoryService.getJobHistory(id));
...@@ -1405,14 +1410,30 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1405,14 +1410,30 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
Task updateTask = new Task(); Task updateTask = new Task();
updateTask.setId(jobInstance.getTaskId()); updateTask.setId(jobInstance.getTaskId());
updateTask.setJobInstanceId(0); updateTask.setJobInstanceId(0);
Integer jobInstanceId = jobInstance.getId();
// 获取任务历史信息
JobHistory jobHistory = jobHistoryService.getJobHistory(jobInstanceId);
// some job need do something on Done, example flink-kubernets-operator
if (GatewayType.isDeployCluster(jobInstance.getType())) {
JobConfig jobConfig = new JobConfig();
Map<String, Object> clusterConfig =
JSONUtil.toMap(
jobHistory.getClusterConfiguration().get("configJson").asText(),
String.class,
Object.class);
jobConfig.buildGatewayConfig(clusterConfig);
jobConfig.getGatewayConfig().setType(GatewayType.get(jobInstance.getType()));
jobConfig.getGatewayConfig().getFlinkConfig().setJobName(jobInstance.getName());
Gateway.build(jobConfig.getGatewayConfig())
.onJobFinishCallback(jobInstance.getStatus());
}
if (!JobLifeCycle.ONLINE.equalsValue(jobInstance.getStep())) { if (!JobLifeCycle.ONLINE.equalsValue(jobInstance.getStep())) {
updateById(updateTask); updateById(updateTask);
return; return;
} }
Integer jobInstanceId = jobInstance.getId();
// 获取任务历史信息
JobHistory jobHistory = jobHistoryService.getJobHistory(jobInstanceId);
ObjectNode jsonNodes = jobHistory.getJob(); ObjectNode jsonNodes = jobHistory.getJob();
if (jsonNodes.has("errors")) { if (jsonNodes.has("errors")) {
return; return;
......
...@@ -36,13 +36,15 @@ public class FlinkClusterConfiguration { ...@@ -36,13 +36,15 @@ public class FlinkClusterConfiguration {
private String flinkConfigPath; private String flinkConfigPath;
private String flinkLibPath; private String flinkLibPath;
private String userJarPath; private String userJarPath;
private String flinkVersion;
Map<String, String> flinkConfig; Map<String, String> flinkConfig;
Map<String, String> kubernetesConfig; Map<String, String> kubernetesConfig;
public static enum Type { public enum Type {
// //
Yarn, Yarn,
Kubernetes; Kubernetes,
KubernetesOperator;
} }
} }
...@@ -211,7 +211,8 @@ public class JobManager { ...@@ -211,7 +211,8 @@ public class JobManager {
public static boolean useGateway(String type) { public static boolean useGateway(String type) {
return (GatewayType.YARN_PER_JOB.equalsValue(type) return (GatewayType.YARN_PER_JOB.equalsValue(type)
|| GatewayType.YARN_APPLICATION.equalsValue(type) || GatewayType.YARN_APPLICATION.equalsValue(type)
|| GatewayType.KUBERNETES_APPLICATION.equalsValue(type)); || GatewayType.KUBERNETES_APPLICATION.equalsValue(type)
|| GatewayType.KUBERNETES_APPLICATION_OPERATOR.equalsValue(type));
} }
private Executor createExecutor() { private Executor createExecutor() {
......
...@@ -30,6 +30,11 @@ ...@@ -30,6 +30,11 @@
<name>Dinky : Gateway</name> <name>Dinky : Gateway</name>
<dependencies> <dependencies>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
<version>5.12.4</version>
</dependency>
<dependency> <dependency>
<groupId>org.dinky</groupId> <groupId>org.dinky</groupId>
<artifactId>dinky-common</artifactId> <artifactId>dinky-common</artifactId>
...@@ -130,8 +135,100 @@ for k8s commit tasks--> ...@@ -130,8 +135,100 @@ for k8s commit tasks-->
<artifactId>junit-jupiter</artifactId> <artifactId>junit-jupiter</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.dinky</groupId>
<artifactId>dinky-process</artifactId>
</dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>shade-dinky</id>
<goals>
<goal>shade</goal>
</goals>
<phase>package</phase>
<configuration>
<artifactSet>
<includes combine.children="append">
<include>io.fabric8:kubernetes-client</include>
<include>io.fabric8:kubernetes-model-*</include>
<include>io.fabric8:zjsonpatch</include>
<!-- Shade all the dependencies of kubernetes client -->
<include>com.fasterxml.jackson.core:jackson-core</include>
<include>com.fasterxml.jackson.core:jackson-annotations</include>
<include>com.fasterxml.jackson.core:jackson-databind</include>
<include>com.fasterxml.jackson.dataformat:jackson-dataformat-yaml</include>
<include>com.fasterxml.jackson.datatype:jackson-datatype-jsr310</include>
<include>com.squareup.okhttp3:*</include>
<include>com.squareup.okio:okio</include>
<include>org.yaml:*</include>
<include>dk.brics.automaton:*</include>
</includes>
</artifactSet>
<filters combine.children="append">
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>*.aut</exclude>
<exclude>META-INF/services/*com.fasterxml*</exclude>
<exclude>META-INF/proguard/**</exclude>
<exclude>OSGI-INF/**</exclude>
<exclude>schema/**</exclude>
<exclude>*.vm</exclude>
<exclude>*.properties</exclude>
<exclude>*.xml</exclude>
<exclude>META-INF/jandex.idx</exclude>
<exclude>license.header</exclude>
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>com.fasterxml.jackson</pattern>
<shadedPattern>org.dinky.gateway.kubernetes.operator.com.fasterxml.jackson</shadedPattern>
</relocation>
<relocation>
<pattern>okhttp3/internal/publicsuffix</pattern>
<shadedPattern>META-INF</shadedPattern>
<includes>
<include>**/NOTICE</include>
</includes>
</relocation>
<relocation>
<pattern>okhttp3</pattern>
<shadedPattern>org.dinky.gateway.kubernetes.operator.okhttp3</shadedPattern>
</relocation>
<relocation>
<pattern>okio</pattern>
<shadedPattern>org.dinky.gateway.kubernetes.operator.okio</shadedPattern>
</relocation>
<relocation>
<pattern>org.yaml</pattern>
<shadedPattern>org.dinky.gateway.kubernetes.operator.org.yaml</shadedPattern>
</relocation>
<relocation>
<pattern>dk.brics.automaton</pattern>
<shadedPattern>org.dinky.gateway.kubernetes.operator.dk.brics.automaton</shadedPattern>
</relocation>
<relocation>
<pattern>io.fabric8</pattern>
<shadedPattern>org.dinky.gateway.kubernetes.operator.io.fabric8</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles> <profiles>
<profile> <profile>
<id>flink-1.12</id> <id>flink-1.12</id>
......
...@@ -231,4 +231,9 @@ public abstract class AbstractGateway implements Gateway { ...@@ -231,4 +231,9 @@ public abstract class AbstractGateway implements Gateway {
} }
return clusterSpecificationBuilder; return clusterSpecificationBuilder;
} }
@Override
public boolean onJobFinishCallback(String status) {
return true;
}
} }
...@@ -86,5 +86,7 @@ public interface Gateway { ...@@ -86,5 +86,7 @@ public interface Gateway {
void killCluster(); void killCluster();
boolean onJobFinishCallback(String status);
GatewayResult deployCluster(); GatewayResult deployCluster();
} }
...@@ -34,7 +34,8 @@ public enum GatewayType { ...@@ -34,7 +34,8 @@ public enum GatewayType {
YARN_APPLICATION("ya", "yarn-application"), YARN_APPLICATION("ya", "yarn-application"),
YARN_PER_JOB("ypj", "yarn-per-job"), YARN_PER_JOB("ypj", "yarn-per-job"),
KUBERNETES_SESSION("ks", "kubernetes-session"), KUBERNETES_SESSION("ks", "kubernetes-session"),
KUBERNETES_APPLICATION("ka", "kubernetes-application"); KUBERNETES_APPLICATION("ka", "kubernetes-application"),
KUBERNETES_APPLICATION_OPERATOR("kao", "kubernetes-application-operator");
private final String value; private final String value;
private final String longValue; private final String longValue;
...@@ -80,6 +81,7 @@ public enum GatewayType { ...@@ -80,6 +81,7 @@ public enum GatewayType {
case YARN_APPLICATION: case YARN_APPLICATION:
case YARN_PER_JOB: case YARN_PER_JOB:
case KUBERNETES_APPLICATION: case KUBERNETES_APPLICATION:
case KUBERNETES_APPLICATION_OPERATOR:
return true; return true;
default: default:
return false; return false;
...@@ -101,6 +103,7 @@ public enum GatewayType { ...@@ -101,6 +103,7 @@ public enum GatewayType {
switch (value) { switch (value) {
case "ya": case "ya":
case "ka": case "ka":
case "kao":
return true; return true;
default: default:
return false; return false;
......
...@@ -48,6 +48,7 @@ public class FlinkConfig { ...@@ -48,6 +48,7 @@ public class FlinkConfig {
private SavePointType savePointType; private SavePointType savePointType;
private String savePoint; private String savePoint;
private Map<String, String> configuration = new HashMap<>(); private Map<String, String> configuration = new HashMap<>();
private Map<String, String> FlinkKubetnetsConfig = new HashMap<>();
private static final ObjectMapper mapper = new ObjectMapper(); private static final ObjectMapper mapper = new ObjectMapper();
......
...@@ -44,6 +44,7 @@ public class GatewayConfig { ...@@ -44,6 +44,7 @@ public class GatewayConfig {
public static final String FLINK_CONFIG_PATH = "flinkConfigPath"; public static final String FLINK_CONFIG_PATH = "flinkConfigPath";
public static final String FLINK_LIB_PATH = "flinkLibPath"; public static final String FLINK_LIB_PATH = "flinkLibPath";
public static final String FLINK_VERSION = "flinkVersion";
public static final String HADOOP_CONFIG_PATH = "hadoopConfigPath"; public static final String HADOOP_CONFIG_PATH = "hadoopConfigPath";
public static final String USER_JAR_PATH = "userJarPath"; public static final String USER_JAR_PATH = "userJarPath";
public static final String USER_JAR_MAIN_APP_CLASS = "userJarMainAppClass"; public static final String USER_JAR_MAIN_APP_CLASS = "userJarMainAppClass";
...@@ -87,10 +88,16 @@ public class GatewayConfig { ...@@ -87,10 +88,16 @@ public class GatewayConfig {
} }
final Map<String, String> configuration = fc.getConfiguration(); final Map<String, String> configuration = fc.getConfiguration();
final Map<String, String> k8sConfig = fc.getFlinkKubetnetsConfig();
if (config.containsKey(KUBERNETES_CONFIG)) { if (config.containsKey(KUBERNETES_CONFIG)) {
Map<String, String> kubernetesConfig = Map<String, String> kubernetesConfig =
(Map<String, String>) config.get(KUBERNETES_CONFIG); (Map<String, String>) config.get(KUBERNETES_CONFIG);
configuration.putAll(kubernetesConfig); k8sConfig.putAll(kubernetesConfig);
}
if (config.containsKey(FLINK_VERSION)) {
k8sConfig.put(FLINK_VERSION, String.valueOf(config.get(FLINK_VERSION)));
} }
// at present only k8s task have this // at present only k8s task have this
...@@ -98,7 +105,7 @@ public class GatewayConfig { ...@@ -98,7 +105,7 @@ public class GatewayConfig {
Map<String, Map<String, String>> taskCustomConfig = Map<String, Map<String, String>> taskCustomConfig =
(Map<String, Map<String, String>>) config.get(TASK_CUSTOM_CONFIG); (Map<String, Map<String, String>>) config.get(TASK_CUSTOM_CONFIG);
if (taskCustomConfig.containsKey(KUBERNETES_CONFIG)) { if (taskCustomConfig.containsKey(KUBERNETES_CONFIG)) {
configuration.putAll(taskCustomConfig.get(KUBERNETES_CONFIG)); k8sConfig.putAll(taskCustomConfig.get(KUBERNETES_CONFIG));
} }
if (taskCustomConfig.containsKey(FLINK_CONFIG)) { if (taskCustomConfig.containsKey(FLINK_CONFIG)) {
configuration.putAll(taskCustomConfig.get(FLINK_CONFIG)); configuration.putAll(taskCustomConfig.get(FLINK_CONFIG));
...@@ -138,7 +145,7 @@ public class GatewayConfig { ...@@ -138,7 +145,7 @@ public class GatewayConfig {
config.get(FLINK_LIB_PATH).toString(), config.get(FLINK_LIB_PATH).toString(),
config.get(HADOOP_CONFIG_PATH).toString()); config.get(HADOOP_CONFIG_PATH).toString());
} else { } else {
return ClusterConfig.build(config.get(FLINK_CONFIG_PATH).toString()); return ClusterConfig.build(String.valueOf(config.get(FLINK_CONFIG_PATH)));
} }
} }
} }
...@@ -40,12 +40,11 @@ import org.apache.flink.kubernetes.kubeclient.FlinkKubeClient; ...@@ -40,12 +40,11 @@ import org.apache.flink.kubernetes.kubeclient.FlinkKubeClient;
import org.apache.flink.kubernetes.kubeclient.FlinkKubeClientFactory; import org.apache.flink.kubernetes.kubeclient.FlinkKubeClientFactory;
import org.apache.flink.runtime.jobgraph.SavepointConfigOptions; import org.apache.flink.runtime.jobgraph.SavepointConfigOptions;
import java.lang.reflect.Method;
import java.util.Collections; import java.util.Collections;
import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.ReflectUtil;
import io.fabric8.kubernetes.client.NamespacedKubernetesClient;
import io.fabric8.kubernetes.client.VersionInfo;
/** /**
* KubernetesGateway * KubernetesGateway
...@@ -74,6 +73,9 @@ public abstract class KubernetesGateway extends AbstractGateway { ...@@ -74,6 +73,9 @@ public abstract class KubernetesGateway extends AbstractGateway {
config.getClusterConfig().getFlinkConfigPath()); config.getClusterConfig().getFlinkConfigPath());
final FlinkConfig flinkConfig = config.getFlinkConfig(); final FlinkConfig flinkConfig = config.getFlinkConfig();
if (flinkConfig.getFlinkKubetnetsConfig() != null) {
flinkConfig.getConfiguration().putAll(flinkConfig.getFlinkKubetnetsConfig());
}
if (Asserts.isNotNull(flinkConfig.getConfiguration())) { if (Asserts.isNotNull(flinkConfig.getConfiguration())) {
addConfigParas(flinkConfig.getConfiguration()); addConfigParas(flinkConfig.getConfiguration());
} }
...@@ -150,14 +152,13 @@ public abstract class KubernetesGateway extends AbstractGateway { ...@@ -150,14 +152,13 @@ public abstract class KubernetesGateway extends AbstractGateway {
try { try {
initKubeClient(); initKubeClient();
if (client instanceof Fabric8FlinkKubeClient) { if (client instanceof Fabric8FlinkKubeClient) {
VersionInfo kubernetesVersion = Object internalClient = ReflectUtil.getFieldValue(client, "internalClient");
((NamespacedKubernetesClient) Method method = ReflectUtil.getMethod(internalClient.getClass(), "getVersion");
ReflectUtil.getFieldValue(client, "internalClient")) Object versionInfo = method.invoke(internalClient);
.getVersion();
logger.info( logger.info(
"k8s cluster link successful ; k8s version: {} ; platform: {}", "k8s cluster link successful ; k8s version: {} ; platform: {}",
kubernetesVersion.getGitVersion(), ReflectUtil.getFieldValue(versionInfo, "gitVersion"),
kubernetesVersion.getPlatform()); ReflectUtil.getFieldValue(versionInfo, "platform"));
} }
logger.info("配置连接测试成功"); logger.info("配置连接测试成功");
return TestResult.success(); return TestResult.success();
......
/*
*
* 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.dinky.gateway.kubernetes.operator;
import org.dinky.assertion.Asserts;
import org.dinky.gateway.GatewayType;
import org.dinky.gateway.kubernetes.operator.api.FlinkDeployment;
import org.dinky.gateway.result.GatewayResult;
import org.dinky.gateway.result.KubernetesResult;
import org.dinky.process.model.ProcessEntity;
import org.dinky.utils.LogUtil;
import java.util.Collections;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.fabric8.kubernetes.api.model.ListOptions;
import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.ServiceList;
import io.fabric8.kubernetes.api.model.ServicePort;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientException;
public class KubetnetsApplicationOperatorGateway extends KubernetsOperatorGateway {
private static final Logger logger =
LoggerFactory.getLogger(KubetnetsApplicationOperatorGateway.class);
@Override
public GatewayType getType() {
return GatewayType.KUBERNETES_APPLICATION_OPERATOR;
}
@Override
public GatewayResult submitJar() {
ProcessEntity process = getProcess();
process.info(String.format("start submit flink jar use %s", getType()));
logger.info("start submit flink jar use {}", getType());
KubernetesResult result = KubernetesResult.build(getType());
try {
init();
KubernetesClient kubernetesClient = getKubernetesClient();
FlinkDeployment flinkDeployment = getFlinkDeployment();
process.info("start delete old cluster ");
kubernetesClient.resource(flinkDeployment).delete();
kubernetesClient
.resource(flinkDeployment)
.waitUntilCondition(Objects::isNull, 1, TimeUnit.MINUTES);
process.info("start create cluster ");
kubernetesClient.resource(flinkDeployment).createOrReplace();
FlinkDeployment flinkDeploymentResult =
kubernetesClient
.resource(flinkDeployment)
.waitUntilCondition(
flinkDeployment1 -> {
if (Asserts.isNull(flinkDeployment1.getStatus())) {
return false;
}
String status =
String.valueOf(
flinkDeployment1
.getStatus()
.getJobManagerDeploymentStatus());
logger.info("deploy kubernetes , status is : {}", status);
process.info(
String.format(
"deploy kubernetes , status is : %s",
status));
String error = flinkDeployment1.getStatus().getError();
if (Asserts.isNotNullString(error)) {
logger.info("deploy kubernetes error :{}", error);
process.info(
String.format(
"deploy kubernetes error :%s", error));
throw new RuntimeException(error);
}
if (status.equals("READY")) {
logger.info("deploy kubernetes success ");
process.info("deploy kubernetes success ");
String jobId =
flinkDeployment1
.getStatus()
.getJobStatus()
.getJobId();
result.setJids(Collections.singletonList(jobId));
return true;
}
return false;
},
2,
TimeUnit.MINUTES);
// sleep a time ,because some time the service will not be found
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// get jobmanager addr by service
ListOptions options = new ListOptions();
String serviceName = config.getFlinkConfig().getJobName() + "-rest";
options.setFieldSelector("metadata.name=" + serviceName);
ServiceList list = kubernetesClient.services().list(options);
StringBuilder ipPort = new StringBuilder();
for (Service item : list.getItems()) {
ipPort.append(item.getSpec().getClusterIP());
for (ServicePort servicePort : item.getSpec().getPorts()) {
if (servicePort.getName().equals("rest")) {
ipPort.append(":").append(servicePort.getPort());
}
}
}
result.setWebURL("http://" + ipPort);
result.setId(result.getJids().get(0) + System.currentTimeMillis());
result.success();
} catch (KubernetesClientException e) {
// some error while connecting to kube cluster
result.fail(LogUtil.getError(e));
process.error(LogUtil.getError(e));
e.printStackTrace();
}
logger.info(
"submit {} job finish, web url is {}, jobid is {}",
getType(),
result.getWebURL(),
result.getJids());
process.info(
String.format(
"submit %s job finish, web url is %s, jobid is %s",
getType(), result.getWebURL(), result.getJids()));
return result;
}
}
/*
*
* 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.dinky.gateway.kubernetes.operator.api;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.fabric8.kubernetes.api.model.Pod;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class AbstractPodSpec {
private Resource resource;
private int replicas = 1;
private Pod podTemplate;
public AbstractPodSpec() {}
@Data
@AllArgsConstructor
public static class Resource {
private Double cpu;
private String memory;
public Resource() {}
}
}
/*
*
* 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.dinky.gateway.kubernetes.operator.api;
import org.apache.flink.annotation.Experimental;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.fabric8.kubernetes.api.model.Namespaced;
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.model.annotation.Group;
import io.fabric8.kubernetes.model.annotation.ShortNames;
import io.fabric8.kubernetes.model.annotation.Version;
@Experimental
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonDeserialize()
@Group("flink.apache.org")
@Version("v1beta1")
@ShortNames({"flinkdep"})
public class FlinkDeployment extends CustomResource<FlinkDeploymentSpec, FlinkDeploymentStatus>
implements Namespaced {}
/*
*
* 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.dinky.gateway.kubernetes.operator.api;
import org.apache.flink.annotation.Experimental;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.fabric8.kubernetes.api.model.Pod;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@Experimental
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString(callSuper = true)
@SuperBuilder
@JsonIgnoreProperties(ignoreUnknown = true)
public class FlinkDeploymentSpec {
private JobSpec job;
private Long restartNonce;
private Map<String, String> flinkConfiguration;
private String image;
private String imagePullPolicy;
private String serviceAccount;
private String flinkVersion;
private Pod podTemplate;
private AbstractPodSpec jobManager;
private AbstractPodSpec taskManager;
private Map<String, String> logConfiguration;
}
/*
*
* 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.dinky.gateway.kubernetes.operator.api;
import org.apache.flink.annotation.Experimental;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.fabric8.kubernetes.model.annotation.PrinterColumn;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
@Experimental
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString(callSuper = true)
@SuperBuilder
@JsonIgnoreProperties(ignoreUnknown = true)
public class FlinkDeploymentStatus {
private JobStatus jobStatus = new JobStatus();
private String error;
private Map<String, String> clusterInfo = new HashMap<>();
private String jobManagerDeploymentStatus = "MISSING";
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public static class JobStatus {
private String jobName;
private String jobId;
@PrinterColumn(name = "Job Status")
private String state;
private String startTime;
private String updateTime;
}
}
/*
*
* 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.dinky.gateway.kubernetes.operator.api;
import org.apache.flink.annotation.Experimental;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@Experimental
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@EqualsAndHashCode
@JsonIgnoreProperties(ignoreUnknown = true)
public class JobSpec {
private String jarURI;
private int parallelism;
private String entryClass;
private String[] args = new String[0];
private Long savepointTriggerNonce;
private String initialSavepointPath;
private UpgradeMode upgradeMode = UpgradeMode.STATELESS;
private Boolean allowNonRestoredState;
}
/*
*
* 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.dinky.gateway.kubernetes.operator.api;
import org.apache.flink.annotation.Experimental;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
@Experimental
@JsonIgnoreProperties(ignoreUnknown = true)
public enum UpgradeMode {
@JsonProperty("savepoint")
SAVEPOINT,
@JsonProperty("last-state")
LAST_STATE,
@JsonProperty("stateless")
STATELESS
}
...@@ -3,3 +3,4 @@ org.dinky.gateway.yarn.YarnPerJobGateway ...@@ -3,3 +3,4 @@ org.dinky.gateway.yarn.YarnPerJobGateway
org.dinky.gateway.yarn.YarnSessionGateway org.dinky.gateway.yarn.YarnSessionGateway
org.dinky.gateway.kubernetes.KubernetesApplicationGateway org.dinky.gateway.kubernetes.KubernetesApplicationGateway
org.dinky.gateway.kubernetes.KubernetesSessionGateway org.dinky.gateway.kubernetes.KubernetesSessionGateway
org.dinky.gateway.kubernetes.operator.KubetnetsApplicationOperatorGateway
\ No newline at end of file
...@@ -129,8 +129,11 @@ const StudioKubernetes = (props: any) => { ...@@ -129,8 +129,11 @@ const StudioKubernetes = (props: any) => {
const values = getConfig(all) const values = getConfig(all)
let appConfig = {} let appConfig = {}
APP_CONFIG_LIST.forEach((value, index) => { APP_CONFIG_LIST.forEach((value, index) => {
if(all[APP_CONFIG_LIST[index].name]){
appConfig[APP_CONFIG_LIST[index].name] = all[APP_CONFIG_LIST[index].name] appConfig[APP_CONFIG_LIST[index].name] = all[APP_CONFIG_LIST[index].name]
}
}) })
setFormVals(all) setFormVals(all)
props.saveSql(JSON.stringify({...values,"appConfig":appConfig})) props.saveSql(JSON.stringify({...values,"appConfig":appConfig}))
} }
......
...@@ -48,12 +48,14 @@ const StudioKubernetesConfig = (props: any) => { ...@@ -48,12 +48,14 @@ const StudioKubernetesConfig = (props: any) => {
const getClusterConfigurationOptions = () => { const getClusterConfigurationOptions = () => {
const itemList = []; const itemList = [];
for (const item of clusterConfiguration) { for (const item of clusterConfiguration) {
const tag = (<><Tag color={item.enabled ? "processing" : "error"}>{item.type}</Tag>{item.name}</>); const tag = (<><Tag color={item.enabled ? "processing" : "error"}>{item.type}</Tag>{item.name}</>);
//opeartor mode can not have normal application config //opeartor mode can not have normal application config
if (current.task.type == 'kubernetes-application-operator' && item.type == 'FlinkKubernetesOperator'){ if (current.task.type == 'kubernetes-application-operator' && item.type == 'KubernetesOperator'){
itemList.push(<Option key={item.id} value={item.id} label={tag}>{tag}</Option>) itemList.push(<Option key={item.id} value={item.id} label={tag}>{tag}</Option>)
}else if (current.task.type != 'kubernetes-application-operator' && item.type != 'FlinkKubernetesOperator'){ }else if (current.task.type != 'kubernetes-application-operator' && item.type != 'KubernetesOperator'){
//if not operator mode , add it normal //if not operator mode , add it normal
itemList.push(<Option key={item.id} value={item.id} label={tag}>{tag}</Option>) itemList.push(<Option key={item.id} value={item.id} label={tag}>{tag}</Option>)
} }
...@@ -122,6 +124,7 @@ const StudioKubernetesConfig = (props: any) => { ...@@ -122,6 +124,7 @@ const StudioKubernetesConfig = (props: any) => {
> >
<Select defaultValue={RUN_MODE.KUBERNETES_APPLICATION} value={RUN_MODE.KUBERNETES_APPLICATION}> <Select defaultValue={RUN_MODE.KUBERNETES_APPLICATION} value={RUN_MODE.KUBERNETES_APPLICATION}>
<Option value={RUN_MODE.KUBERNETES_APPLICATION}>Kubernetes Application Native</Option> <Option value={RUN_MODE.KUBERNETES_APPLICATION}>Kubernetes Application Native</Option>
<Option value={RUN_MODE.KUBERNETES_APPLICATION_OPERATOR}>Kubernetes Application Operator</Option>
</Select> </Select>
</Form.Item> </Form.Item>
......
...@@ -163,6 +163,7 @@ const StudioSetting = (props: any) => { ...@@ -163,6 +163,7 @@ const StudioSetting = (props: any) => {
<Option value={RUN_MODE.YARN_APPLICATION}>Yarn Application</Option> <Option value={RUN_MODE.YARN_APPLICATION}>Yarn Application</Option>
<Option value={RUN_MODE.KUBERNETES_SESSION}>Kubernetes Session</Option> <Option value={RUN_MODE.KUBERNETES_SESSION}>Kubernetes Session</Option>
<Option value={RUN_MODE.KUBERNETES_APPLICATION}>Kubernetes Application</Option> <Option value={RUN_MODE.KUBERNETES_APPLICATION}>Kubernetes Application</Option>
<Option value={RUN_MODE.KUBERNETES_APPLICATION_OPERATOR}>Kubernetes Operator Application</Option>
</Select> </Select>
</Form.Item> </Form.Item>
{(current.task.type === RUN_MODE.YARN_SESSION || current.task.type === RUN_MODE.KUBERNETES_SESSION || current.task.type === RUN_MODE.STANDALONE) ? ( {(current.task.type === RUN_MODE.YARN_SESSION || current.task.type === RUN_MODE.KUBERNETES_SESSION || current.task.type === RUN_MODE.STANDALONE) ? (
...@@ -192,7 +193,8 @@ const StudioSetting = (props: any) => { ...@@ -192,7 +193,8 @@ const StudioSetting = (props: any) => {
</Form.Item> </Form.Item>
</Col> </Col>
</Row>) : undefined} </Row>) : undefined}
{(current.task.type === RUN_MODE.YARN_PER_JOB || current.task.type === RUN_MODE.YARN_APPLICATION || current.task.type === RUN_MODE.KUBERNETES_APPLICATION) ? ( {(current.task.type === RUN_MODE.YARN_PER_JOB || current.task.type === RUN_MODE.YARN_APPLICATION
|| current.task.type === RUN_MODE.KUBERNETES_APPLICATION|| current.task.type === RUN_MODE.KUBERNETES_APPLICATION_OPERATOR) ? (
<Row> <Row>
<Col span={24}> <Col span={24}>
<Form.Item label={l('pages.datastudio.label.jobConfig.clusterConfig')} <Form.Item label={l('pages.datastudio.label.jobConfig.clusterConfig')}
......
...@@ -26,6 +26,7 @@ export const RUN_MODE = { ...@@ -26,6 +26,7 @@ export const RUN_MODE = {
YARN_APPLICATION: 'yarn-application', YARN_APPLICATION: 'yarn-application',
KUBERNETES_SESSION: 'kubernetes-session', KUBERNETES_SESSION: 'kubernetes-session',
KUBERNETES_APPLICATION: 'kubernetes-application', KUBERNETES_APPLICATION: 'kubernetes-application',
KUBERNETES_APPLICATION_OPERATOR: 'kubernetes-application-operator',
}; };
export const DIALECT = { export const DIALECT = {
......
...@@ -102,6 +102,7 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props ...@@ -102,6 +102,7 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props
const submitForm = async () => { const submitForm = async () => {
const fieldsValue = await form.validateFields(); const fieldsValue = await form.validateFields();
const formValues = { const formValues = {
id: formVals.id, id: formVals.id,
name: fieldsValue.name, name: fieldsValue.name,
...@@ -110,6 +111,7 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props ...@@ -110,6 +111,7 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props
enabled: fieldsValue.enabled, enabled: fieldsValue.enabled,
configJson: JSON.stringify(getConfig(fieldsValue)), configJson: JSON.stringify(getConfig(fieldsValue)),
}; };
setFormVals(formValues); setFormVals(formValues);
handleSubmit(formValues); handleSubmit(formValues);
}; };
...@@ -204,6 +206,27 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props ...@@ -204,6 +206,27 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props
) )
} }
const renderFlinkKubernetesOperatorPage = (formValsPara: Partial<ClusterConfigurationTableListItem>) => {
return (
<>
<Divider>{l('pages.rc.clusterConfig.k8sConfig')}</Divider>
<Form.Item
name="flinkVersion"
label={l('pages.rc.clusterConfig.kubernets.version')}
>
<Select>
<Option value="v1_13">v1_13 ({l('pages.rc.clusterConfig.kubernets.unsupportBatch')})</Option>
<Option value="v1_14">v1_14 ({l('pages.rc.clusterConfig.kubernets.unsupportBatch')})</Option>
<Option value="v1_15">v1_15</Option>
<Option value="v1_16">v1_16</Option>
</Select>
</Form.Item>
{buildConfig(KUBERNETES_CONFIG_LIST, formValsPara)}
</>
)
}
const renderFlinkKubernetesNativePage = (formValsPara: Partial<ClusterConfigurationTableListItem>) => { const renderFlinkKubernetesNativePage = (formValsPara: Partial<ClusterConfigurationTableListItem>) => {
return ( return (
<> <>
...@@ -302,7 +325,7 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props ...@@ -302,7 +325,7 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props
<Select defaultValue="Yarn" value="Yarn"> <Select defaultValue="Yarn" value="Yarn">
<Option value="Yarn">Flink On Yarn</Option> <Option value="Yarn">Flink On Yarn</Option>
<Option value="Kubernetes">Flink Kubernetes Native</Option> <Option value="Kubernetes">Flink Kubernetes Native</Option>
{/*<Option value="FlinkKubernetesOperator">Flink Kubernetes Operator</Option>*/} <Option value="KubernetesOperator">Flink Kubernetes Operator</Option>
</Select> </Select>
</Form.Item> </Form.Item>
...@@ -310,6 +333,8 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props ...@@ -310,6 +333,8 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props
{formValsPara.type == 'Kubernetes' ? renderFlinkKubernetesNativePage(formValsPara) : undefined} {formValsPara.type == 'Kubernetes' ? renderFlinkKubernetesNativePage(formValsPara) : undefined}
{formValsPara.type == 'KubernetesOperator' ? renderFlinkKubernetesOperatorPage(formValsPara) : undefined}
<Divider orientation="left" plain>{l('pages.rc.clusterConfig.defineConfig.highPriority')}</Divider> <Divider orientation="left" plain>{l('pages.rc.clusterConfig.defineConfig.highPriority')}</Divider>
{buildConfig(FLINK_CONFIG_LIST, formValsPara)} {buildConfig(FLINK_CONFIG_LIST, formValsPara)}
......
...@@ -107,6 +107,30 @@ export const KUBERNETES_CONFIG_LIST: Config[] = [ ...@@ -107,6 +107,30 @@ export const KUBERNETES_CONFIG_LIST: Config[] = [
lable: 'kubernetes.config.file', lable: 'kubernetes.config.file',
showType: 'input', showType: 'input',
placeholder: l('pages.rc.clusterConfig.help.kubernetes.configfile'), placeholder: l('pages.rc.clusterConfig.help.kubernetes.configfile'),
},{
name: 'kubernetes.service.account',
lable: 'kubernetes.service.account',
placeholder: l('pages.rc.clusterConfig.help.kubernets.account'),
showType: 'input',
showOnSubmitType: 'KubernetesOperator'
},{
name: 'kubernetes.pod-template',
lable: 'kubernetes.pod-template',
placeholder: l('pages.rc.clusterConfig.help.kubernets.defaultTemplate'),
showType: 'textarea',
showOnSubmitType: 'KubernetesOperator'
},{
name: 'kubernetes.pod-template.jobmanager',
lable: 'kubernetes.pod-template.jobmanager',
placeholder: l('pages.rc.clusterConfig.help.kubernets.jobManagerTemplate'),
showType: 'textarea',
showOnSubmitType: 'KubernetesOperator'
},{
name: 'kubernetes.pod-template.taskmanager',
lable: 'kubernetes.pod-template.taskmanager',
placeholder: l('pages.rc.clusterConfig.help.kubernets.taskManagerTemplate'),
showType: 'textarea',
showOnSubmitType: 'KubernetesOperator'
} }
]; ];
export const FLINK_CONFIG_LIST: Config[] = [ export const FLINK_CONFIG_LIST: Config[] = [
......
...@@ -53,6 +53,20 @@ export function getConfig(values: any) { ...@@ -53,6 +53,20 @@ export function getConfig(values: any) {
userJarPath: values.userJarPath, userJarPath: values.userJarPath,
flinkConfig, flinkConfig,
}; };
}else if(values.type=='KubernetesOperator') {
let kubernetesConfig = addValueToMap(values, KUBERNETES_CONFIG_NAME_LIST());
addListToMap(values.kubernetesConfigList, kubernetesConfig);
let dockerConfig = addValueToMap(values, DOCKER_CONFIG_NAME_LIST());
let flinkVersion = values.flinkVersion
return {
flinkLibPath: values.flinkLibPath,
flinkConfigPath: values.flinkConfigPath,
kubernetesConfig,
dockerConfig,
userJarPath: values.userJarPath,
flinkConfig,
flinkVersion
};
} else { } else {
//all code paths must return a value. //all code paths must return a value.
return {} return {}
...@@ -79,12 +93,15 @@ function addValueToMap(values: {}, keys: string []) { ...@@ -79,12 +93,15 @@ function addValueToMap(values: {}, keys: string []) {
return config; return config;
} }
for (let i in keys) { for (let i in keys) {
if(values[keys[i]]){
config[keys[i]] = values[keys[i]]; config[keys[i]] = values[keys[i]];
} }
}
return config; return config;
} }
export function getConfigFormValues(values: any) { export function getConfigFormValues(values: any) {
if (!values.id) { if (!values.id) {
return {type: values.type}; return {type: values.type};
} }
...@@ -97,10 +114,12 @@ export function getConfigFormValues(values: any) { ...@@ -97,10 +114,12 @@ export function getConfigFormValues(values: any) {
'enabled', 'enabled',
]); ]);
let config = JSON.parse(values.configJson); let config = JSON.parse(values.configJson);
let configValues = addValueToMap(config, [ let configValues = addValueToMap(config, [
'hadoopConfigPath', 'hadoopConfigPath',
'flinkLibPath', 'flinkLibPath',
'flinkConfigPath', 'flinkConfigPath',
'flinkVersion',
]); ]);
let hadoopConfig = addValueToMap(config.hadoopConfig, HADOOP_CONFIG_NAME_LIST()); let hadoopConfig = addValueToMap(config.hadoopConfig, HADOOP_CONFIG_NAME_LIST());
let userJarPath = config.userJarPath; let userJarPath = config.userJarPath;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment