Unverified Commit 0bac91f0 authored by 高岩's avatar 高岩 Committed by GitHub

Optimize k8s submission pages (#1283)

* Optimize k8s submission pages * Optimize k8s submission pages Co-authored-by: steve <woai1998>
parent d7963f03
...@@ -819,8 +819,12 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -819,8 +819,12 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
// support custom K8s app submit, rather than clusterConfiguration // support custom K8s app submit, rather than clusterConfiguration
else if (Dialect.KUBERNETES_APPLICATION.equalsVal(task.getDialect()) else if (Dialect.KUBERNETES_APPLICATION.equalsVal(task.getDialect())
&& GatewayType.KUBERNETES_APPLICATION.equalsValue(config.getType())) { && GatewayType.KUBERNETES_APPLICATION.equalsValue(config.getType())) {
Map<String, Object> gatewayConfig = JSONUtil.toMap(task.getStatement(), String.class, Object.class); Map<String, Object> taskConfig = JSONUtil.toMap(task.getStatement(), String.class, Object.class);
config.buildGatewayConfig(gatewayConfig); Map<String, Object> clusterConfiguration =
clusterConfigurationService.getGatewayConfig(task.getClusterConfigurationId());
clusterConfiguration.putAll((Map<String, Object>) taskConfig.get("appConfig"));
clusterConfiguration.put("taskCustomConfig", taskConfig);
config.buildGatewayConfig(clusterConfiguration);
} else { } else {
Map<String, Object> gatewayConfig = Map<String, Object> gatewayConfig =
clusterConfigurationService.getGatewayConfig(task.getClusterConfigurationId()); clusterConfigurationService.getGatewayConfig(task.getClusterConfigurationId());
...@@ -867,6 +871,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -867,6 +871,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
config.setSavePointPath(null); config.setSavePointPath(null);
} }
config.setVariables(fragmentVariableService.listEnabledVariables()); config.setVariables(fragmentVariableService.listEnabledVariables());
config.getGatewayConfig().getAppConfig().setParallelism(task.getParallelism());
return config; return config;
} }
......
...@@ -239,10 +239,17 @@ public class JobConfig { ...@@ -239,10 +239,17 @@ public class JobConfig {
gatewayConfig.setFlinkConfig(FlinkConfig.build((Map<String, String>) config.get("flinkConfig"))); gatewayConfig.setFlinkConfig(FlinkConfig.build((Map<String, String>) config.get("flinkConfig")));
} }
if (config.containsKey("kubernetesConfig")) { if (config.containsKey("kubernetesConfig")) {
Map<String, Object> kubernetesConfig = (Map<String, Object>) config.get("kubernetesConfig"); Map<String, String> kubernetesConfig = (Map<String, String>) config.get("kubernetesConfig");
// 构建GatewayConfig时,将k8s集群默认配置和自定义参数配置加载到FlinkConfig里 gatewayConfig.getFlinkConfig().getConfiguration().putAll(kubernetesConfig);
for (Map.Entry<String, Object> entry : kubernetesConfig.entrySet()) { }
gatewayConfig.getFlinkConfig().getConfiguration().put(entry.getKey(), entry.getValue().toString()); // at present only k8s task have this
if (config.containsKey("taskCustomConfig")) {
Map<String, Map<String, String>> taskCustomConfig = (Map<String, Map<String, String>>) config.get("taskCustomConfig");
if (taskCustomConfig.containsKey("kubernetesConfig")) {
gatewayConfig.getFlinkConfig().getConfiguration().putAll(taskCustomConfig.get("kubernetesConfig"));
}
if (taskCustomConfig.containsKey("flinkConfig")) {
gatewayConfig.getFlinkConfig().getConfiguration().putAll(taskCustomConfig.get("flinkConfig"));
} }
} }
} }
......
...@@ -36,6 +36,7 @@ public class AppConfig { ...@@ -36,6 +36,7 @@ public class AppConfig {
private String userJarPath; private String userJarPath;
private String[] userJarParas; private String[] userJarParas;
private String userJarMainAppClass; private String userJarMainAppClass;
private Integer parallelism;
public AppConfig() { public AppConfig() {
} }
......
...@@ -25,9 +25,7 @@ import {useState} from "react"; ...@@ -25,9 +25,7 @@ import {useState} from "react";
import { import {
APP_CONFIG_LIST, APP_CONFIG_LIST,
Config, Config,
FLINK_CONFIG_LIST,
FLINK_CONFIG_NAME_LIST, FLINK_CONFIG_NAME_LIST,
KUBERNETES_CONFIG_LIST,
KUBERNETES_CONFIG_NAME_LIST KUBERNETES_CONFIG_NAME_LIST
} from "@/pages/ClusterConfiguration/conf"; } from "@/pages/ClusterConfiguration/conf";
import {MinusCircleOutlined, PlusOutlined} from "@ant-design/icons"; import {MinusCircleOutlined, PlusOutlined} from "@ant-design/icons";
...@@ -50,6 +48,34 @@ const StudioKubernetes = (props: any) => { ...@@ -50,6 +48,34 @@ const StudioKubernetes = (props: any) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const CUSTOM_KUBERNETS_CONFIG_LIST: Config[] = [
{
name: 'kubernetes.jobmanager.cpu',
lable: 'kubernetes.jobmanager.cpu',
showType: 'input',
placeholder: l('pages.registerCenter.clusterConfig.help.kubernets.jmcpu'),
}, {
name: 'kubernetes.taskmanager.cpu',
lable: 'kubernetes.taskmanager.cpu',
showType: 'input',
placeholder: l('pages.registerCenter.clusterConfig.help.kubernets.tmcpu'),
},
];
const CUSTOM_FLINK_CONFIG_LIST: Config[] = [
{
name: 'jobmanager.memory.process.size',
lable: 'jobmanager.memory.process.size',
placeholder: l('pages.registerCenter.clusterConfig.help.kubernets.jobManagerMemory'),
}, {
name: 'taskmanager.memory.process.size',
lable: 'taskmanager.memory.process.size',
placeholder: l('pages.registerCenter.clusterConfig.help.kubernets.taskManagerMemory'),
}, {
name: 'taskmanager.numberOfTaskSlots',
lable: 'taskmanager.numberOfTaskSlots',
placeholder: '',
}
];
//Separate normal configuration and user-defined configuration. //Separate normal configuration and user-defined configuration.
function addMapToList(map: Record<string, unknown>, keys: string[]) { function addMapToList(map: Record<string, unknown>, keys: string[]) {
const list = []; const list = [];
...@@ -86,14 +112,12 @@ const StudioKubernetes = (props: any) => { ...@@ -86,14 +112,12 @@ const StudioKubernetes = (props: any) => {
if (config["flinkConfig"]) { if (config["flinkConfig"]) {
initValues = mergeConfig(initValues, config["flinkConfig"]) initValues = mergeConfig(initValues, config["flinkConfig"])
} }
//App config is mix in flink config , need separated if (config["appConfig"]) {
APP_CONFIG_LIST.forEach((value, index) => { initValues = mergeConfig(initValues, config["appConfig"])
initValues[APP_CONFIG_LIST[index].name] = config[APP_CONFIG_LIST[index].name] }
})
//user custom config set //user custom config set
initValues["flinkConfigList"] = addMapToList(config["flinkConfig"], FLINK_CONFIG_NAME_LIST()) initValues["flinkConfigList"] = addMapToList(config["flinkConfig"], FLINK_CONFIG_NAME_LIST())
initValues["kubernetesConfigList"] = addMapToList(config["kubernetesConfig"], KUBERNETES_CONFIG_NAME_LIST()) initValues["kubernetesConfigList"] = addMapToList(config["kubernetesConfig"], KUBERNETES_CONFIG_NAME_LIST())
initValues["flinkConfigPath"] = config["flinkConfigPath"]
return initValues; return initValues;
} }
...@@ -103,11 +127,12 @@ const StudioKubernetes = (props: any) => { ...@@ -103,11 +127,12 @@ const StudioKubernetes = (props: any) => {
const onValuesChange = (change: any, all: any) => { const onValuesChange = (change: any, all: any) => {
all.type = "Kubernetes" all.type = "Kubernetes"
const values = getConfig(all) const values = getConfig(all)
let appConfig = {}
APP_CONFIG_LIST.forEach((value, index) => { APP_CONFIG_LIST.forEach((value, index) => {
values[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)) props.saveSql(JSON.stringify({...values,"appConfig":appConfig}))
} }
// build pre-defined config item // build pre-defined config item
...@@ -120,9 +145,7 @@ const StudioKubernetes = (props: any) => { ...@@ -120,9 +145,7 @@ const StudioKubernetes = (props: any) => {
label={configItem.lable} label={configItem.lable}
help={configItem.help} help={configItem.help}
> >
<Input placeholder={configItem.placeholder} <Input placeholder={configItem.placeholder}/>
// defaultValue={configItem.defaultValue}
/>
</Form.Item>) </Form.Item>)
}); });
...@@ -171,24 +194,16 @@ const StudioKubernetes = (props: any) => { ...@@ -171,24 +194,16 @@ const StudioKubernetes = (props: any) => {
const renderContent = () => { const renderContent = () => {
return ( return (
<> <>
<Divider>Kubernetes 配置(必选)</Divider> <Divider>{l('pages.registerCenter.clusterConfig.appConfig')}</Divider>
{buildConfig(KUBERNETES_CONFIG_LIST)}
{buildOtherConfig("其他配置", "kubernetesConfigList", "添加一个自定义项")}
<Divider>App 配置(必选)</Divider>
<Form.Item
name="flinkConfigPath"
label="配置文件路径"
rules={[{required: true, message: '请输入 flink-conf.yaml 路径!'}]}
help="指定 flink-conf.yaml 的路径(末尾无/)"
>
<Input placeholder="值如 /opt/flink/conf"/>
</Form.Item>
{buildConfig(APP_CONFIG_LIST)} {buildConfig(APP_CONFIG_LIST)}
<Divider>{l('pages.registerCenter.clusterConfig.k8sConfig')}</Divider>
{buildConfig(CUSTOM_KUBERNETS_CONFIG_LIST)}
<Divider>{l('pages.registerCenter.clusterConfig.flinkConfig')}</Divider>
{buildConfig(CUSTOM_FLINK_CONFIG_LIST)}
{buildOtherConfig(l('pages.registerCenter.clusterConfig.otherConfig'),
"flinkConfigList",
l('pages.registerCenter.clusterConfig.addDefineConfig'))}
<Divider>其他配置(可选)</Divider>
{buildConfig(FLINK_CONFIG_LIST)}
{buildOtherConfig("其他配置", "flinkConfigList", "添加一个自定义项")}
</> </>
); );
}; };
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
import {connect} from "umi"; import {connect} from "umi";
import {StateType} from "@/pages/DataStudio/model"; import {StateType} from "@/pages/DataStudio/model";
import {Button, Col, Form, Input, Row, Select, Tooltip} from "antd"; import {Button, Col, Form, Input, InputNumber, Row, Select, Tag, Tooltip} from "antd";
import {MinusSquareOutlined} from "@ant-design/icons"; import {MinusSquareOutlined} from "@ant-design/icons";
import styles from "./index.less"; import styles from "./index.less";
import {useEffect} from "react"; import {useEffect} from "react";
...@@ -33,7 +33,33 @@ import {l} from "@/utils/intl"; ...@@ -33,7 +33,33 @@ import {l} from "@/utils/intl";
const {Option} = Select; const {Option} = Select;
const StudioKubernetesConfig = (props: any) => { const StudioKubernetesConfig = (props: any) => {
const {current, form, dispatch, tabs, group, toolHeight} = props; const {
sessionCluster,
clusterConfiguration,
current,
form,
dispatch,
tabs,
currentSession,
env,
group,
toolHeight
} = props;
const getClusterConfigurationOptions = () => {
const itemList = [];
for (const item of clusterConfiguration) {
const tag = (<><Tag color={item.enabled ? "processing" : "error"}>{item.type}</Tag>{item.alias === "" ? item.name : item.alias}</>);
//opeartor mode can not have normal application config
if (current.task.type == 'kubernetes-application-operator' && item.type == 'FlinkKubernetesOperator'){
itemList.push(<Option key={item.id} value={item.id} label={tag}>{tag}</Option>)
}else if (current.task.type != 'kubernetes-application-operator' && item.type != 'FlinkKubernetesOperator'){
//if not operator mode , add it normal
itemList.push(<Option key={item.id} value={item.id} label={tag}>{tag}</Option>)
}
}
return itemList;
};
const getGroupOptions = () => { const getGroupOptions = () => {
...@@ -49,8 +75,6 @@ const StudioKubernetesConfig = (props: any) => { ...@@ -49,8 +75,6 @@ const StudioKubernetesConfig = (props: any) => {
}; };
useEffect(() => { useEffect(() => {
//Force set type k8s
current.task.type = RUN_MODE.KUBERNETES_APPLICATION
form.setFieldsValue(current.task); form.setFieldsValue(current.task);
}, [current.task]); }, [current.task]);
...@@ -92,6 +116,42 @@ const StudioKubernetesConfig = (props: any) => { ...@@ -92,6 +116,42 @@ const StudioKubernetesConfig = (props: any) => {
className={styles.form_setting} className={styles.form_setting}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
> >
<Form.Item
label="执行模式" className={styles.form_item} name="type"
tooltip='指定 Flink 任务的执行模式,默认为 KUBERNETES_APPLICATION'
>
<Select defaultValue={RUN_MODE.KUBERNETES_APPLICATION} value={RUN_MODE.KUBERNETES_APPLICATION}>
<Option value={RUN_MODE.KUBERNETES_APPLICATION}>Kubernetes Application Native</Option>
</Select>
</Form.Item>
<Row>
<Col span={24}>
<Form.Item label="Flink集群配置"
tooltip={`选择Flink集群配置进行 ${current.task.type} 模式的远程提交任务`}
name="clusterConfigurationId"
className={styles.form_item}>
<Select
style={{width: '100%'}}
placeholder="选择Flink集群配置"
optionLabelProp="label"
>
{getClusterConfigurationOptions()}
</Select>
</Form.Item>
</Col>
</Row>
<Row>
<Col span={12}>
<Form.Item
label="任务并行度" className={styles.form_item} name="parallelism"
tooltip="设置Flink任务的并行度,最小为 1"
>
<InputNumber min={1} max={9999} defaultValue={1}/>
</Form.Item>
</Col>
</Row>
<Form.Item <Form.Item
label="SavePoint策略" className={styles.form_item} name="savePointStrategy" label="SavePoint策略" className={styles.form_item} name="savePointStrategy"
tooltip='指定 SavePoint策略,默认为禁用' tooltip='指定 SavePoint策略,默认为禁用'
......
...@@ -321,6 +321,26 @@ export default { ...@@ -321,6 +321,26 @@ export default {
'pages.registerCenter.clusterConfig.flinkConfigPathPlaceholder': 'Please enter the flink-conf.yaml path! Values like /opt/module/flink/conf ', 'pages.registerCenter.clusterConfig.flinkConfigPathPlaceholder': 'Please enter the flink-conf.yaml path! Values like /opt/module/flink/conf ',
'pages.registerCenter.clusterConfig.flinkConfigPathHelp': 'Please enter the flink-conf.yaml path! Values like /opt/module/flink/conf ', 'pages.registerCenter.clusterConfig.flinkConfigPathHelp': 'Please enter the flink-conf.yaml path! Values like /opt/module/flink/conf ',
// kubernets page
'pages.registerCenter.clusterConfig.appConfig': 'App Config',
'pages.registerCenter.clusterConfig.kubernets.version': 'Flink Version',
'pages.registerCenter.clusterConfig.kubernets.unsupportBatch': 'Not support batch',
'pages.registerCenter.clusterConfig.submit.type': 'Deploy mode',
'pages.registerCenter.clusterConfig.jar.path': 'jar path in image',
'pages.registerCenter.clusterConfig.jar.class': 'main class',
'pages.registerCenter.clusterConfig.jar.args': 'app args',
'pages.registerCenter.clusterConfig.help.kubernets.namespace': 'kubernets namespace',
'pages.registerCenter.clusterConfig.help.kubernets.image': 'Flink image',
'pages.registerCenter.clusterConfig.help.kubernets.jmcpu': 'jobmanager cpu config',
'pages.registerCenter.clusterConfig.help.kubernets.tmcpu': 'taskmanager cpu config',
'pages.registerCenter.clusterConfig.help.kubernets.account': 'kubernets account,default is default',
'pages.registerCenter.clusterConfig.help.kubernets.defaultTemplate': 'Optional,default JobManager,TaskManager template conf!',
'pages.registerCenter.clusterConfig.help.kubernets.jobManagerTemplate': 'Optional,JobManager template ',
'pages.registerCenter.clusterConfig.help.kubernets.taskManagerTemplate': 'Optional,TaskManager template',
'pages.registerCenter.clusterConfig.help.kubernets.jobManagerMemory': 'Optional,JobManager memory',
'pages.registerCenter.clusterConfig.help.kubernets.taskManagerMemory': 'Optional,taskManagerMemory memory',
'pages.registerCenter.alert.instanceManagement': 'Alarm Instance Management', 'pages.registerCenter.alert.instanceManagement': 'Alarm Instance Management',
'pages.registerCenter.alert.instance.name': 'Name', 'pages.registerCenter.alert.instance.name': 'Name',
......
...@@ -324,6 +324,27 @@ export default { ...@@ -324,6 +324,27 @@ export default {
'pages.registerCenter.clusterConfig.flinkConfigPathPlaceholder': '请输入 flink-conf.yaml 路径!值如 /opt/module/flink/conf ', 'pages.registerCenter.clusterConfig.flinkConfigPathPlaceholder': '请输入 flink-conf.yaml 路径!值如 /opt/module/flink/conf ',
'pages.registerCenter.clusterConfig.flinkConfigPathHelp': '请输入 flink-conf.yaml 路径!值如 /opt/module/flink/conf ', 'pages.registerCenter.clusterConfig.flinkConfigPathHelp': '请输入 flink-conf.yaml 路径!值如 /opt/module/flink/conf ',
// K8s页面相关
'pages.registerCenter.clusterConfig.appConfig': 'App 配置',
'pages.registerCenter.clusterConfig.kubernets.version': 'Flink 版本',
'pages.registerCenter.clusterConfig.kubernets.unsupportBatch': '不支持批任务',
'pages.registerCenter.clusterConfig.submit.type': '部署方式',
'pages.registerCenter.clusterConfig.jar.path': '镜像内Jar路径',
'pages.registerCenter.clusterConfig.jar.class': '启动类',
'pages.registerCenter.clusterConfig.jar.args': '启动参数',
'pages.registerCenter.clusterConfig.help.kubernets.namespace': 'kubernets命名空间',
'pages.registerCenter.clusterConfig.help.kubernets.image': 'Flink镜像地址',
'pages.registerCenter.clusterConfig.help.kubernets.jmcpu': 'jobmanager cpu配置',
'pages.registerCenter.clusterConfig.help.kubernets.tmcpu': 'taskmanager cpu配置',
'pages.registerCenter.clusterConfig.help.kubernets.account': 'kubernets 提交使用的账号,默认default',
'pages.registerCenter.clusterConfig.help.kubernets.defaultTemplate': '可选,默认JobManager,TaskManager 的template配置!',
'pages.registerCenter.clusterConfig.help.kubernets.jobManagerTemplate': '可选,JobManager 的template配置! 会覆盖kubernetes.pod-template配置',
'pages.registerCenter.clusterConfig.help.kubernets.taskManagerTemplate': '可选,TaskManager 的template配置!会覆盖kubernetes.pod-template配置',
'pages.registerCenter.clusterConfig.help.kubernets.jobManagerMemory': '可选,JobManager 的内存配置',
'pages.registerCenter.clusterConfig.help.kubernets.taskManagerMemory': '可选,taskManagerMemory 的内存配置',
'pages.registerCenter.alert.instanceManagement': '报警实例管理', 'pages.registerCenter.alert.instanceManagement': '报警实例管理',
'pages.registerCenter.alert.instance.name': '名称', 'pages.registerCenter.alert.instance.name': '名称',
'pages.registerCenter.alert.instance.namePleaseHolder': '请输入告警实例名称', 'pages.registerCenter.alert.instance.namePleaseHolder': '请输入告警实例名称',
......
...@@ -27,6 +27,7 @@ import {testClusterConfigurationConnect} from "@/pages/ClusterConfiguration/serv ...@@ -27,6 +27,7 @@ import {testClusterConfigurationConnect} from "@/pages/ClusterConfiguration/serv
import type {ClusterConfigurationTableListItem} from "@/pages/ClusterConfiguration/data"; import type {ClusterConfigurationTableListItem} from "@/pages/ClusterConfiguration/data";
import {CODE} from "@/components/Common/crud"; import {CODE} from "@/components/Common/crud";
import {l} from "@/utils/intl"; import {l} from "@/utils/intl";
import TextArea from "antd/lib/input/TextArea";
export type ClusterConfigurationFormProps = { export type ClusterConfigurationFormProps = {
onCancel: (flag?: boolean) => void; onCancel: (flag?: boolean) => void;
...@@ -71,15 +72,21 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props ...@@ -71,15 +72,21 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props
setFlinkConfigPath(all['flinkConfigPath']); setFlinkConfigPath(all['flinkConfigPath']);
}; };
const buildConfig = (config: Config[]) => { const buildConfig = (config: Config[], formValsPara: any) => {
const itemList: JSX.Element[] = []; const itemList: JSX.Element[] = [];
config.forEach(configItem => { config.forEach(configItem => {
itemList.push(<Form.Item if (configItem.showOnSubmitType != undefined && configItem.showOnSubmitType != formValsPara.type) {
name={configItem.name} // pass
label={configItem.lable} } else {
> if (configItem.showType == 'input' || configItem.showType == undefined) {
<Input placeholder={configItem.placeholder} defaultValue={configItem.defaultValue}/> itemList.push(<Form.Item name={configItem.name} label={configItem.lable}>
</Form.Item>) <Input placeholder={configItem.placeholder} defaultValue={configItem.defaultValue}/></Form.Item>)
} else {
itemList.push(<Form.Item name={configItem.name} label={configItem.lable}>
<TextArea rows={5} placeholder={configItem.placeholder} defaultValue={configItem.defaultValue}/></Form.Item>)
}
}
}); });
return itemList; return itemList;
}; };
...@@ -150,123 +157,113 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props ...@@ -150,123 +157,113 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props
} }
}; };
const renderContent = (formValsPara: Partial<ClusterConfigurationTableListItem>) => { const buildOtherConfig = (itemName: string, configName: string, addDescription: string) => {
return (
<Form.Item
label={itemName}
>
<Form.List name={configName}>
{(fields, {add, remove}) => (
<>
{fields.map(({key, name, fieldKey, ...restField}) => (
<Space key={key} style={{display: 'flex'}} align="baseline">
<Form.Item
{...restField}
name={[name, 'name']}
fieldKey={[fieldKey, 'name']}
>
<Input placeholder="name"/>
</Form.Item>
<Form.Item
{...restField}
name={[name, 'value']}
fieldKey={[fieldKey, 'value']}
>
<Input placeholder="value"/>
</Form.Item>
<MinusCircleOutlined onClick={() => remove(name)}/>
</Space>
))}
<Form.Item>
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined/>}>
{addDescription}
</Button>
</Form.Item>
</>
)}
</Form.List>
</Form.Item>
)
}
const renderFlinkKubernetesNativePage = (formValsPara: Partial<ClusterConfigurationTableListItem>) => {
return ( return (
<> <>
<Divider>{l('pages.registerCenter.clusterConfig.k8sConfig')}</Divider>
{buildConfig(KUBERNETES_CONFIG_LIST, formValsPara)}
{buildOtherConfig(l('pages.registerCenter.clusterConfig.otherConfig'),
"kubernetesConfigList",
l('pages.registerCenter.clusterConfig.addDefineConfig'))}
<Divider>{l('pages.registerCenter.clusterConfig.flinkConfig')}</Divider>
<Form.Item <Form.Item
name="type" name="flinkConfigPath"
label={l('pages.registerCenter.clusterConfig.type')} label={l('pages.registerCenter.clusterConfig.flinkConfigPath')}
rules={[{required: true, message: l('pages.registerCenter.clusterConfig.flinkConfigPathPlaceholder')}]}
help={l('pages.registerCenter.clusterConfig.flinkConfigPathHelp')}
> >
<Select defaultValue="Yarn" value="Yarn"> <Input placeholder={l('pages.registerCenter.clusterConfig.flinkConfigPathPlaceholder')} addonAfter={
<Option value="Yarn">Flink On Yarn</Option> <Form.Item name="suffix" noStyle>
<Option value="Kubernetes">Flink On Kubernetes</Option> <Upload {...getUploadProps(flinkConfigPath)}>
</Select> <UploadOutlined/>
</Upload>
</Form.Item>}/>
</Form.Item> </Form.Item>
{formValsPara.type == 'Yarn' ? <> </>)
<Divider>{l('pages.registerCenter.clusterConfig.hadoopConfig')}</Divider> }
<Form.Item
name="hadoopConfigPath" const renderYarnPage = (formValsPara: Partial<ClusterConfigurationTableListItem>) => {
label={l('pages.registerCenter.clusterConfig.hadoopConfigPath')} return (
rules={[{required: true, message: l('pages.registerCenter.clusterConfig.hadoopConfigPathPlaceholder')}]} <>
help={l('pages.registerCenter.clusterConfig.hadoopConfigPathHelp')} <Divider>{l('pages.registerCenter.clusterConfig.hadoopConfig')}</Divider>
> <Form.Item
<Input placeholder={l('pages.registerCenter.clusterConfig.hadoopConfigPath')} addonAfter={ name="hadoopConfigPath"
<Form.Item name="suffix" noStyle> label={l('pages.registerCenter.clusterConfig.hadoopConfigPath')}
<Upload {...getUploadProps(hadoopConfigPath)} multiple> rules={[{required: true, message: l('pages.registerCenter.clusterConfig.hadoopConfigPathPlaceholder')}]}
<UploadOutlined/> help={l('pages.registerCenter.clusterConfig.hadoopConfigPathHelp')}
</Upload> >
</Form.Item>}/> <Input placeholder={l('pages.registerCenter.clusterConfig.hadoopConfigPath')} addonAfter={
</Form.Item> <Form.Item name="suffix" noStyle>
<Divider orientation="left" plain>{l('pages.registerCenter.clusterConfig.defineConfig.highPriority')}</Divider> <Upload {...getUploadProps(hadoopConfigPath)} multiple>
{buildConfig(HADOOP_CONFIG_LIST)} <UploadOutlined/>
<Form.Item </Upload>
label={l('pages.registerCenter.clusterConfig.otherConfig')} </Form.Item>}/>
> </Form.Item>
<Form.List name="hadoopConfigList"> <Divider orientation="left" plain>{l('pages.registerCenter.clusterConfig.defineConfig.highPriority')}</Divider>
{(fields, {add, remove}) => ( {buildConfig(HADOOP_CONFIG_LIST, formValsPara)}
<>
{fields.map(({key, name, fieldKey, ...restField}) => ( {buildOtherConfig(l('pages.registerCenter.clusterConfig.otherConfig'),
<Space key={key} style={{display: 'flex'}} align="baseline"> "hadoopConfigList",
<Form.Item l('pages.registerCenter.clusterConfig.addDefineConfig'))}
{...restField}
name={[name, 'name']}
fieldKey={[fieldKey, 'name']}
>
<Input placeholder="name"/>
</Form.Item>
<Form.Item
{...restField}
name={[name, 'value']}
fieldKey={[fieldKey, 'value']}
>
<Input placeholder="value"/>
</Form.Item>
<MinusCircleOutlined onClick={() => remove(name)}/>
</Space>
))}
<Form.Item>
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined/>}>
{l('pages.registerCenter.clusterConfig.addDefineConfig')}
</Button>
</Form.Item>
</>
)}
</Form.List>
</Form.Item></> : undefined}
{formValsPara.type == 'Kubernetes' ? <>
<Divider>{l('pages.registerCenter.clusterConfig.k8sConfig')}</Divider>
{buildConfig(KUBERNETES_CONFIG_LIST)}
<Form.Item
label={l('pages.registerCenter.clusterConfig.otherConfig')}
>
<Form.List name="kubernetesConfigList">
{(fields, {add, remove}) => (
<>
{fields.map(({key, name, fieldKey, ...restField}) => (
<Space key={key} style={{display: 'flex'}} align="baseline">
<Form.Item
{...restField}
name={[name, 'name']}
fieldKey={[fieldKey, 'name']}
>
<Input placeholder="name"/>
</Form.Item>
<Form.Item
{...restField}
name={[name, 'value']}
fieldKey={[fieldKey, 'value']}
>
<Input placeholder="value"/>
</Form.Item>
<MinusCircleOutlined onClick={() => remove(name)}/>
</Space>
))}
<Form.Item>
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined/>}>
{l('pages.registerCenter.clusterConfig.addDefineConfig')}
</Button>
</Form.Item>
</>
)}
</Form.List>
</Form.Item>
</> : undefined}
<Divider>{l('pages.registerCenter.clusterConfig.flinkConfig')}</Divider> <Divider>{l('pages.registerCenter.clusterConfig.flinkConfig')}</Divider>
{formValsPara.type == 'Yarn' ? <>
<Form.Item <Form.Item
name="flinkLibPath" name="flinkLibPath"
label={l('pages.registerCenter.clusterConfig.libPath')} label={l('pages.registerCenter.clusterConfig.libPath')}
rules={[{required: true, message: l('pages.registerCenter.clusterConfig.libPathPlaceholder')}]} rules={[{required: true, message: l('pages.registerCenter.clusterConfig.libPathPlaceholder')}]}
help={l('pages.registerCenter.clusterConfig.libPathHelp')} help={l('pages.registerCenter.clusterConfig.libPathHelp')}
> >
<Input placeholder={l('pages.registerCenter.clusterConfig.libPathPlaceholder')} addonAfter={ <Input placeholder={l('pages.registerCenter.clusterConfig.libPathPlaceholder')} addonAfter={
<Form.Item name="suffix" noStyle> <Form.Item name="suffix" noStyle>
<Upload {...getUploadHdfsProps(flinkLibPath)} multiple> <Upload {...getUploadHdfsProps(flinkLibPath)} multiple>
<UploadOutlined/> <UploadOutlined/>
</Upload> </Upload>
</Form.Item>}/> </Form.Item>}/>
</Form.Item> </Form.Item>
</> : undefined}
<Form.Item <Form.Item
name="flinkConfigPath" name="flinkConfigPath"
label={l('pages.registerCenter.clusterConfig.flinkConfigPath')} label={l('pages.registerCenter.clusterConfig.flinkConfigPath')}
...@@ -280,42 +277,36 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props ...@@ -280,42 +277,36 @@ const ClusterConfigurationForm: React.FC<ClusterConfigurationFormProps> = (props
</Upload> </Upload>
</Form.Item>}/> </Form.Item>}/>
</Form.Item> </Form.Item>
<Divider orientation="left" plain>{l('pages.registerCenter.clusterConfig.defineConfig.highPriority')}</Divider> </>
{buildConfig(FLINK_CONFIG_LIST)} )
}
const renderContent = (formValsPara: Partial<ClusterConfigurationTableListItem>) => {
return (
<>
<Form.Item <Form.Item
label={l('pages.registerCenter.clusterConfig.otherConfig')} name="type"
label={l('pages.registerCenter.clusterConfig.type')}
> >
<Form.List name="flinkConfigList"> <Select defaultValue="Yarn" value="Yarn">
{(fields, {add, remove}) => ( <Option value="Yarn">Flink On Yarn</Option>
<> <Option value="Kubernetes">Flink Kubernetes Native</Option>
{fields.map(({key, name, fieldKey, ...restField}) => ( {/*<Option value="FlinkKubernetesOperator">Flink Kubernetes Operator</Option>*/}
<Space key={key} style={{display: 'flex', marginBottom: 8}} align="baseline"> </Select>
<Form.Item
{...restField}
name={[name, 'name']}
fieldKey={[fieldKey, 'name']}
>
<Input placeholder="name"/>
</Form.Item>
<Form.Item
{...restField}
name={[name, 'value']}
fieldKey={[fieldKey, 'value']}
>
<Input placeholder="value"/>
</Form.Item>
<MinusCircleOutlined onClick={() => remove(name)}/>
</Space>
))}
<Form.Item>
<Button type="dashed" onClick={() => add()} block icon={<PlusOutlined/>}>
{l('pages.registerCenter.clusterConfig.addDefineConfig')}
</Button>
</Form.Item>
</>
)}
</Form.List>
</Form.Item> </Form.Item>
{formValsPara.type == 'Yarn' ? renderYarnPage(formValsPara) : undefined}
{formValsPara.type == 'Kubernetes' ? renderFlinkKubernetesNativePage(formValsPara) : undefined}
<Divider orientation="left" plain>{l('pages.registerCenter.clusterConfig.defineConfig.highPriority')}</Divider>
{buildConfig(FLINK_CONFIG_LIST, formValsPara)}
{buildOtherConfig(l('pages.registerCenter.clusterConfig.otherConfig'),
"flinkConfigList",
l('pages.registerCenter.clusterConfig.addDefineConfig'))}
<Divider>{l('pages.registerCenter.clusterConfig.baseConfig')}</Divider> <Divider>{l('pages.registerCenter.clusterConfig.baseConfig')}</Divider>
<Form.Item <Form.Item
name="name" name="name"
......
...@@ -25,6 +25,8 @@ export type Config = { ...@@ -25,6 +25,8 @@ export type Config = {
placeholder: string placeholder: string
defaultValue?: string defaultValue?: string
help?: string help?: string
showOnSubmitType?: string
showType?: string
} }
export const HADOOP_CONFIG_LIST: Config[] = [{ export const HADOOP_CONFIG_LIST: Config[] = [{
...@@ -35,74 +37,73 @@ export const HADOOP_CONFIG_LIST: Config[] = [{ ...@@ -35,74 +37,73 @@ export const HADOOP_CONFIG_LIST: Config[] = [{
export const KUBERNETES_CONFIG_LIST: Config[] = [{ export const KUBERNETES_CONFIG_LIST: Config[] = [{
name: 'kubernetes.namespace', name: 'kubernetes.namespace',
lable: 'kubernetes.namespace', lable: 'kubernetes.namespace',
placeholder: 'dlink', placeholder: l('pages.registerCenter.clusterConfig.help.kubernets.namespace'),
showType: 'input'
},{ },{
name: 'kubernetes.container.image', name: 'kubernetes.container.image',
lable: 'kubernetes.container.image', lable: 'kubernetes.container.image',
placeholder: 'dlink', placeholder: l('pages.registerCenter.clusterConfig.help.kubernets.image'),
showType: 'input'
},{ },{
name: 'kubernetes.rest-service.exposed.type', name: 'kubernetes.rest-service.exposed.type',
lable: 'kubernetes.rest-service.exposed.type', lable: 'kubernetes.rest-service.exposed.type',
placeholder: 'NodePort', placeholder: 'NodePort',
defaultValue: 'NodePort', defaultValue: '',
}]; showType: 'input',
showOnSubmitType: 'Kubernetes'
},{
name: 'kubernetes.jobmanager.cpu',
lable: 'kubernetes.jobmanager.cpu',
showType: 'input',
placeholder: l('pages.registerCenter.clusterConfig.help.kubernets.jmcpu'),
}, {
name: 'kubernetes.taskmanager.cpu',
lable: 'kubernetes.taskmanager.cpu',
showType: 'input',
placeholder: l('pages.registerCenter.clusterConfig.help.kubernets.tmcpu'),
}
];
export const FLINK_CONFIG_LIST: Config[] = [ export const FLINK_CONFIG_LIST: Config[] = [
{ {
name: 'kubernetes.pod-template-file',
lable: 'kubernetes.pod-template-file',
placeholder: 'pod-template-file path',
help: '可选,如果配置需要指定到具体文件'
},{
name: 'jobmanager.memory.process.size', name: 'jobmanager.memory.process.size',
lable: 'jobmanager.memory.process.size', lable: 'jobmanager.memory.process.size',
placeholder: '1600m jobmanager內存設置', placeholder: l('pages.registerCenter.clusterConfig.help.kubernets.jobManagerMemory'),
}, { }, {
name: 'taskmanager.memory.process.size', name: 'taskmanager.memory.process.size',
lable: 'taskmanager.memory.process.size', lable: 'taskmanager.memory.process.size',
placeholder: '2048m taskmanager內存設置', placeholder: l('pages.registerCenter.clusterConfig.help.kubernets.taskManagerMemory'),
}, { }, {
name: 'taskmanager.memory.framework.heap.size', name: 'taskmanager.memory.framework.heap.size',
lable: 'taskmanager.memory.framework.heap.size', lable: 'taskmanager.memory.framework.heap.size',
placeholder: '1024m', placeholder: '',
}, { }, {
name: 'taskmanager.numberOfTaskSlots', name: 'taskmanager.numberOfTaskSlots',
lable: 'taskmanager.numberOfTaskSlots', lable: 'taskmanager.numberOfTaskSlots',
placeholder: '1', placeholder: '',
}, {
name: 'kubernetes.jobmanager.cpu',
lable: 'kubernetes.jobmanager.cpu',
placeholder: '1',
}, {
name: 'kubernetes.taskmanager.cpu',
lable: 'kubernetes.taskmanager.cpu',
placeholder: '1',
}, {
name: 'parallelism.default',
lable: 'parallelism.default',
placeholder: '1',
}, { }, {
name: 'state.savepoints.dir', name: 'state.savepoints.dir',
lable: 'state.savepoints.dir', lable: 'state.savepoints.dir',
placeholder: 'hdfs:///flink/savepoints/', placeholder: 'hdfs:///flink/savepoints/',
}, {
name: 'state.checkpoints.dir',
lable: 'state.checkpoints.dir',
placeholder: 'hdfs:///flink/savepoints/',
} }
]; ];
export const APP_CONFIG_LIST: Config[] = [{ export const APP_CONFIG_LIST: Config[] = [{
name: 'userJarPath', name: 'userJarPath',
lable: '镜像内Jar路径', lable: l('pages.registerCenter.clusterConfig.jar.path'),
placeholder: 'local:///opt/example.jar', placeholder: 'local:///opt/example.jar',
}, { }, {
name: 'userJarMainAppClass', name: 'userJarMainAppClass',
lable: '启动类', lable: l('pages.registerCenter.clusterConfig.jar.class'),
placeholder: 'com.example.app', placeholder: 'com.example.app',
}, { }, {
name: 'userJarParas', name: 'userJarParas',
lable: '启动参数', lable: l('pages.registerCenter.clusterConfig.jar.args'),
placeholder: '值如 -conf test.properties', placeholder: 'example: -conf test.properties',
},{
name: 'state.savepoints.dir',
lable: 'state.savepoints.dir',
placeholder: 'hdfs:///flink/savepoints/',
} }
]; ];
......
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