提交 e60953bd 编写于 作者: 偏锋书生's avatar 偏锋书生

支持helm charts的离线下载

上级 0b46d6fe
...@@ -25,7 +25,7 @@ public enum DeployType implements IEnumCombobox { ...@@ -25,7 +25,7 @@ public enum DeployType implements IEnumCombobox {
return TaskStatus.other.retStatusMessage(keyObj); return TaskStatus.other.retStatusMessage(keyObj);
} }
} }
}), },4),
docker("docker环境", new IConvertValue<String>() { docker("docker环境", new IConvertValue<String>() {
...@@ -41,7 +41,7 @@ public enum DeployType implements IEnumCombobox { ...@@ -41,7 +41,7 @@ public enum DeployType implements IEnumCombobox {
return TaskStatus.noExit.retStatusMessage(null); return TaskStatus.noExit.retStatusMessage(null);
} }
} }
}), },0),
host("centos7主机", new IConvertValue<String>() { host("centos7主机", new IConvertValue<String>() {
...@@ -55,7 +55,7 @@ public enum DeployType implements IEnumCombobox { ...@@ -55,7 +55,7 @@ public enum DeployType implements IEnumCombobox {
return TaskStatus.noExit.retStatusMessage(keyObj); return TaskStatus.noExit.retStatusMessage(keyObj);
} }
} }
}); },0);
/**** /****
* 必须要英文 * 必须要英文
...@@ -82,32 +82,32 @@ public enum DeployType implements IEnumCombobox { ...@@ -82,32 +82,32 @@ public enum DeployType implements IEnumCombobox {
/*** /***
* 返回配置文件的形态, * 返回配置文件的形态,
* *
* @param commandType
* @param datamap * @param datamap
* @param retract 缩进的值
* @return * @return
*/ */
public static String formateConfig(DeployType deployType, Map<String, Object> datamap) { public String formateConfig(Map<String, Object> datamap,int retract) {
String propString = ""; int retractTrue=retract<0?this.retract:retract;//有指定缩进的值
switch (deployType) { String propString = CollectionUtil.toPropString(datamap, retractTrue);
case k8s:
propString = CollectionUtil.toPropString(datamap, 4);
break;
case docker:
case host:
propString = CollectionUtil.toPropString(datamap, 0);
default:
break;
}
return propString; return propString;
} }
public String formateConfig(Map<String, Object> datamap) {
return formateConfig(datamap,-1);
}
private final String desc; private final String desc;
private final IConvertValue<String> statusConvert; private final IConvertValue<String> statusConvert;
private final int retract;//默认的缩进个数
private DeployType(String desc, IConvertValue<String> statusConvert) { private DeployType(String desc, IConvertValue<String> statusConvert,int retract) {
this.desc = desc; this.desc = desc;
this.statusConvert = statusConvert; this.statusConvert = statusConvert;
this.retract=retract;
} }
public String getStatus(String statusTrue) { public String getStatus(String statusTrue) {
......
...@@ -18,6 +18,7 @@ import net.wicp.tams.app.duckula.controller.config.constant.CommandType; ...@@ -18,6 +18,7 @@ import net.wicp.tams.app.duckula.controller.config.constant.CommandType;
import net.wicp.tams.app.duckula.controller.config.constant.DeployType; import net.wicp.tams.app.duckula.controller.config.constant.DeployType;
import net.wicp.tams.app.duckula.controller.dao.CommonDeployMapper; import net.wicp.tams.app.duckula.controller.dao.CommonDeployMapper;
import net.wicp.tams.app.duckula.controller.dao.CommonVersionMapper; import net.wicp.tams.app.duckula.controller.dao.CommonVersionMapper;
import net.wicp.tams.app.duckula.controller.service.deploy.DeployK8s;
import net.wicp.tams.app.duckula.controller.service.deploy.IDeploy; import net.wicp.tams.app.duckula.controller.service.deploy.IDeploy;
import net.wicp.tams.common.Result; import net.wicp.tams.common.Result;
import net.wicp.tams.common.apiext.IOUtil; import net.wicp.tams.common.apiext.IOUtil;
...@@ -125,6 +126,21 @@ public class DeployService { ...@@ -125,6 +126,21 @@ public class DeployService {
return null; return null;
} }
} }
public String viewConfK8s(CommandType commandType, Long taskId,int retract) {
DeployK8s deploy = (DeployK8s) SpringAssit.context.getBean("k8s");
try {
String viewConf = deploy.viewK8sConf(commandType, taskId,retract);
return viewConf;
} catch (Throwable e) {
log.error("查看日志错误", e);
return null;
}
}
public String viewConfK8s(CommandType commandType, Long taskId) {
return viewConfK8s(commandType,taskId,-1);
}
public String viewConfDeploy(CommandType commandType, Long taskId, Long deployId) { public String viewConfDeploy(CommandType commandType, Long taskId, Long deployId) {
CommonDeploy commonDeploy = commonDeployMapper.selectById(deployId); CommonDeploy commonDeploy = commonDeployMapper.selectById(deployId);
......
...@@ -228,7 +228,7 @@ public class K8sService { ...@@ -228,7 +228,7 @@ public class K8sService {
*/ */
public V1ConfigMap deployConfigmap(Long deployid, String configMapName, Map<String, Object> contextParams) { public V1ConfigMap deployConfigmap(Long deployid, String configMapName, Map<String, Object> contextParams) {
CommonDeploy commonDeploy = commonDeployMapper.selectById(deployid); CommonDeploy commonDeploy = commonDeployMapper.selectById(deployid);
String configmapStr = DeployType.formateConfig(DeployType.valueOf(commonDeploy.getDeploy()), contextParams); String configmapStr = DeployType.valueOf(commonDeploy.getDeploy()).formateConfig(contextParams);
Map<String, String> params = new HashMap<String, String>(); Map<String, String> params = new HashMap<String, String>();
params.put(ConfigItem.configmap_name, configMapName); params.put(ConfigItem.configmap_name, configMapName);
// 保证第一行为非空字符,为了避免yaml语法检查失败 // 保证第一行为非空字符,为了避免yaml语法检查失败
...@@ -256,10 +256,15 @@ public class K8sService { ...@@ -256,10 +256,15 @@ public class K8sService {
public String OriConfig(Long deployid, Map<String, Object> contextParams) { public String OriConfig(Long deployid, Map<String, Object> contextParams) {
CommonDeploy commonDeploy = commonDeployMapper.selectById(deployid); CommonDeploy commonDeploy = commonDeployMapper.selectById(deployid);
String configmapStr = DeployType.formateConfig(DeployType.valueOf(commonDeploy.getDeploy()), contextParams); String configmapStr = DeployType.valueOf(commonDeploy.getDeploy()).formateConfig( contextParams);
return configmapStr; return configmapStr;
} }
public String OriConfig(DeployType deployType, Map<String, Object> contextParams,int retract) {
String configmapStr = deployType.formateConfig(contextParams,retract);
return configmapStr;
}
public V1Status deleteConfigmap(Long deployid, String configMapName) { public V1Status deleteConfigmap(Long deployid, String configMapName) {
CommonDeploy commonDeploy = commonDeployMapper.selectById(deployid); CommonDeploy commonDeploy = commonDeployMapper.selectById(deployid);
ApiClient apiClient = getApiClient(commonDeploy); ApiClient apiClient = getApiClient(commonDeploy);
......
...@@ -121,6 +121,15 @@ public class DeployK8s implements IDeploy { ...@@ -121,6 +121,15 @@ public class DeployK8s implements IDeploy {
String oriConfig = k8sService.OriConfig(deployid, params); String oriConfig = k8sService.OriConfig(deployid, params);
return oriConfig; return oriConfig;
} }
public String viewK8sConf(CommandType commandType, Long taskId,int retract) {
Map<String, Object> params = new HashMap<String, Object>();
BusiTools.configContext(commonConsumerMapper, commonTaskMapper, commonCheckpointMapper, commonDumpMapper,
commonMiddlewareMapper, commonInstanceMapper, commandType, taskId, params);
String oriConfig = k8sService.OriConfig(DeployType.k8s, params,retract);
return oriConfig;
}
@Override @Override
public Result deleteConfig(Long deployid, CommandType commandType, Long taskId) { public Result deleteConfig(Long deployid, CommandType commandType, Long taskId) {
......
...@@ -30,6 +30,7 @@ import net.wicp.tams.app.duckula.controller.dao.CommonTaskMapper; ...@@ -30,6 +30,7 @@ import net.wicp.tams.app.duckula.controller.dao.CommonTaskMapper;
import net.wicp.tams.app.duckula.controller.dao.CommonVersionMapper; import net.wicp.tams.app.duckula.controller.dao.CommonVersionMapper;
import net.wicp.tams.app.duckula.controller.service.DeployService; import net.wicp.tams.app.duckula.controller.service.DeployService;
import net.wicp.tams.app.duckula.controller.service.PosService; import net.wicp.tams.app.duckula.controller.service.PosService;
import net.wicp.tams.app.duckula.controller.service.deploy.DeployK8s;
import net.wicp.tams.common.Result; import net.wicp.tams.common.Result;
import net.wicp.tams.common.apiext.CollectionUtil; import net.wicp.tams.common.apiext.CollectionUtil;
import net.wicp.tams.common.apiext.StringUtil; import net.wicp.tams.common.apiext.StringUtil;
...@@ -280,12 +281,20 @@ public class TaskManager { ...@@ -280,12 +281,20 @@ public class TaskManager {
final CommonTask commonTask = TapestryAssist.getBeanFromPage(CommonTask.class, requestGlobals); final CommonTask commonTask = TapestryAssist.getBeanFromPage(CommonTask.class, requestGlobals);
CommonCheckpoint commonCheckpoint = commonCheckpointMapper.selectById(commonTask.getCheckpointId()); CommonCheckpoint commonCheckpoint = commonCheckpointMapper.selectById(commonTask.getCheckpointId());
Result delResult = posService.delPositionByMysql(commonCheckpoint, Result delResult = posService.delPositionByMysql(commonCheckpoint,
commonTask.getClientId(),Long.MAX_VALUE); commonTask.getClientId(),Long.MAX_VALUE);
//更新gtid
CommonTask updateTask=new CommonTask();
updateTask.setId(commonTask.getId());
updateTask.setGtids("");
commonTaskMapper.updateByPrimaryKeySelective(updateTask);
return TapestryAssist.getTextStreamResponse(delResult); return TapestryAssist.getTextStreamResponse(delResult);
} }
//查询位点5分钟一次 //查询位点5分钟一次
public TextStreamResponse onQueryPos() { public TextStreamResponse onQueryPos() {
final CommonTask commonTask = TapestryAssist.getBeanFromPage(CommonTask.class, requestGlobals); final CommonTask commonTask = TapestryAssist.getBeanFromPage(CommonTask.class, requestGlobals);
if(commonTask==null||commonTask.getCheckpointId()==null) {
return TapestryAssist.getTextStreamResponse(EasyUiAssist.getJsonForGridEmpty());
}
CommonCheckpoint commonCheckpoint = commonCheckpointMapper.selectById(commonTask.getCheckpointId()); CommonCheckpoint commonCheckpoint = commonCheckpointMapper.selectById(commonTask.getCheckpointId());
List<PositionBean> result = posService.selectPositionIntervalByMysql(commonCheckpoint, commonTask.getClientId(), 300); List<PositionBean> result = posService.selectPositionIntervalByMysql(commonCheckpoint, commonTask.getClientId(), 300);
String retstr = EasyUiAssist.getJsonForGridAlias(result, result.size()); String retstr = EasyUiAssist.getJsonForGridAlias(result, result.size());
...@@ -301,6 +310,8 @@ public class TaskManager { ...@@ -301,6 +310,8 @@ public class TaskManager {
commonTaskMapper.updateByPrimaryKeySelective(updateTask); commonTaskMapper.updateByPrimaryKeySelective(updateTask);
return TapestryAssist.getTextStreamResponse(Result.getSuc()); return TapestryAssist.getTextStreamResponse(Result.getSuc());
} }
/// 停止任务,会等3分钟。 /// 停止任务,会等3分钟。
public TextStreamResponse onStopTask() { public TextStreamResponse onStopTask() {
......
package net.wicp.tams.duckula.ops.pages.tools;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.RequestGlobals;
import lombok.extern.slf4j.Slf4j;
import net.wicp.tams.app.duckula.controller.BusiTools;
import net.wicp.tams.app.duckula.controller.bean.models.CommonConsumer;
import net.wicp.tams.app.duckula.controller.bean.models.CommonDump;
import net.wicp.tams.app.duckula.controller.bean.models.CommonTask;
import net.wicp.tams.app.duckula.controller.bean.models.CommonVersion;
import net.wicp.tams.app.duckula.controller.config.ConfigItem;
import net.wicp.tams.app.duckula.controller.config.constant.CommandType;
import net.wicp.tams.app.duckula.controller.dao.CommonConsumerMapper;
import net.wicp.tams.app.duckula.controller.dao.CommonDumpMapper;
import net.wicp.tams.app.duckula.controller.dao.CommonTaskMapper;
import net.wicp.tams.app.duckula.controller.dao.CommonVersionMapper;
import net.wicp.tams.app.duckula.controller.service.DeployService;
import net.wicp.tams.common.apiext.FreemarkUtil;
import net.wicp.tams.common.apiext.IOUtil;
import net.wicp.tams.common.apiext.TarUtil;
import net.wicp.tams.common.apiext.UUIDGenerator;
import net.wicp.tams.component.response.FileStreamResponse;
import net.wicp.tams.component.services.IReq;
@Slf4j
public class DownLoadHelm3Charts {
@Inject
protected RequestGlobals requestGlobals;
@Inject
protected Request request;
@Inject
private IReq req;
@Property
private String wsUri;
@Property
private String params;
@Inject
private DeployService deployService;
@Inject
private CommonTaskMapper commonTaskMapper;
@Inject
private CommonVersionMapper commonVersionMapper;
@Inject
private CommonDumpMapper commonDumpMapper;
@Inject
private CommonConsumerMapper commonConsumerMapper;
/***
* 页面初始化
*
* @param type
* @param id
* @return
*/
public Object onActivate(String type, Long id) {
CommandType commandType = CommandType.valueOf(type);
// 得到当前的配置文件
String viewConf = deployService.viewConfK8s(commandType, id,6);
// 检查源文件
String baseDirPath = null;
String parentPath = null;
try {
parentPath =IOUtil.mergeFolderAndFilePath(System.getProperty("user.home"),
"/.tams/tempcharts/" + UUIDGenerator.getUniqueLong());
baseDirPath = IOUtil.mergeFolderAndFilePath(parentPath,"/duckula-task");
File baseDir = new File(baseDirPath);
if (!baseDir.exists()) {
baseDir.mkdir();
copyOriHelm3Charts(baseDirPath, "Chart.yaml");
copyOriHelm3Charts(baseDirPath, "README.en.md");
copyOriHelm3Charts(baseDirPath, "README.md");
// copyOriHelm3Charts(baseDirPath,"values.yaml");
copyOriHelm3Charts(baseDirPath, "/templates/_helpers.tpl");
copyOriHelm3Charts(baseDirPath, "/templates/configmap-root.yaml");
copyOriHelm3Charts(baseDirPath, "/templates/deployment.yaml");
copyOriHelm3Charts(baseDirPath, "/templates/NOTES.txt");
}
String context = IOUtil.slurp(
IOUtil.fileToInputStream(IOUtil.mergeFolderAndFilePath("/deploy/k8s/duckula-task", "values.yaml"),
DownLoadHelm3Charts.class));
Map<String, Object> params = new HashMap<String, Object>();
CommonVersion commonVersion=null;
switch (commandType) {
case task:
CommonTask commonTask = commonTaskMapper.selectById(id);
commonVersion = commonVersionMapper.selectById(commonTask.getVersionId());
break;
case consumer:
CommonConsumer commonConsumer = commonConsumerMapper.selectById(id);
commonVersion = commonVersionMapper.selectById(commonConsumer.getVersionId());
break;
case dump:
CommonDump commonDump = commonDumpMapper.selectById(id);
commonVersion = commonVersionMapper.selectById(commonDump.getVersionId());
break;
default:
break;
}
params.put(ConfigItem.task_version, BusiTools.packVersionImage(commonVersion, true));
params.put(ConfigItem.task_data_version, BusiTools.packVersionImage(commonVersion, false));
params.put(ConfigItem.task_image, BusiTools.getImageGroup(commonVersion.getImageGroup()));
//params.put(ConfigItem.configmap_name, commandType.formateConfigName(selectTask.getName()));
params.put(ConfigItem.task_cmd, commandType.getHostShellFile());
params.put(ConfigItem.configmap_filecontext, viewConf);
String result = FreemarkUtil.getInst().doProcessByTemp(context, params);
FileUtils.write(new File(IOUtil.mergeFolderAndFilePath(baseDirPath, "values.yaml")), result);
TarUtil.compress(baseDirPath, baseDirPath + ".tar");
// J2EEAssist.getFileOS(requestGlobals.getHTTPServletResponse(), baseDirPath +
// ".tar", true);
final String baseJarPath = baseDirPath + ".tar";
FileStreamResponse retobj = new FileStreamResponse(new File(baseJarPath));
return retobj;
} catch (Exception e) {
log.error("导出文件失败", e);
return null;
} finally {
try {
FileUtils.forceDelete(new File(parentPath));
} catch (IOException e) {
log.error("删除文件失败", e);
}
}
}
private void copyOriHelm3Charts(String baseDirPath, String path) throws IOException {
String oriPath = IOUtil.mergeFolderAndFilePath("/deploy/k8s/duckula-task", path);
InputStream inputStream = IOUtil.fileToInputStream(oriPath, DownLoadHelm3Charts.class);
File toFile = new File(IOUtil.mergeFolderAndFilePath(baseDirPath, path));
FileUtils.copyInputStreamToFile(inputStream, toFile);
}
}
package net.wicp.tams.duckula.ops.pages.tools; package net.wicp.tams.duckula.ops.pages.tools;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.apache.tapestry5.annotations.BeforeRenderTemplate; import org.apache.tapestry5.annotations.BeforeRenderTemplate;
import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.ioc.annotations.Inject;
...@@ -9,13 +16,20 @@ import org.apache.tapestry5.util.TextStreamResponse; ...@@ -9,13 +16,20 @@ import org.apache.tapestry5.util.TextStreamResponse;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import net.wicp.tams.app.duckula.controller.config.constant.CommandType; import net.wicp.tams.app.duckula.controller.config.constant.CommandType;
import net.wicp.tams.app.duckula.controller.service.DeployService; import net.wicp.tams.app.duckula.controller.service.DeployService;
import net.wicp.tams.app.duckula.controller.service.K8sService;
import net.wicp.tams.common.Conf; import net.wicp.tams.common.Conf;
import net.wicp.tams.common.apiext.FreemarkUtil;
import net.wicp.tams.common.apiext.IOUtil; import net.wicp.tams.common.apiext.IOUtil;
import net.wicp.tams.common.apiext.TarUtil;
import net.wicp.tams.common.apiext.UUIDGenerator;
import net.wicp.tams.common.web.J2EEAssist;
import net.wicp.tams.component.services.IReq; import net.wicp.tams.component.services.IReq;
import net.wicp.tams.component.tools.TapestryAssist; import net.wicp.tams.component.tools.TapestryAssist;
@Slf4j
public class ViewPodLog { public class ViewPodLog {
@Inject @Inject
...@@ -51,7 +65,7 @@ public class ViewPodLog { ...@@ -51,7 +65,7 @@ public class ViewPodLog {
public TextStreamResponse onOldConfig(String type, Long id, Long deployId) { public TextStreamResponse onOldConfig(String type, Long id, Long deployId) {
String viewConf = deployService.viewConfDeploy(CommandType.valueOf(type), id, deployId); String viewConf = deployService.viewConfDeploy(CommandType.valueOf(type), id, deployId);
//viewConf = viewConf.replaceAll("\\r\\n", "<br/><br/>"); // viewConf = viewConf.replaceAll("\\r\\n", "<br/><br/>");
viewConf = viewConf.replaceAll("\\n", "<br/>"); viewConf = viewConf.replaceAll("\\n", "<br/>");
return TapestryAssist.getTextStreamResponse(viewConf); return TapestryAssist.getTextStreamResponse(viewConf);
} }
...@@ -63,4 +77,55 @@ public class ViewPodLog { ...@@ -63,4 +77,55 @@ public class ViewPodLog {
return TapestryAssist.getTextStreamResponse(viewConf); return TapestryAssist.getTextStreamResponse(viewConf);
} }
// 下载可以独立布署的helm3 chart包
public void onTaskDown(String type, Long id) {
// 得到当前的配置文件
String viewConf = deployService.viewConfK8s(CommandType.valueOf(type), id);
viewConf = viewConf.replaceAll("\\r\\n", "<br/>");
// TODO 替换模板
// 压缩
// 检查源文件
String baseDirPath = null;
try {
baseDirPath = IOUtil.mergeFolderAndFilePath(System.getProperty("user.home"),
"/.tams/tempcharts/" + UUIDGenerator.getUniqueLong());
File baseDir = new File(baseDirPath);
if (!baseDir.exists()) {
baseDir.mkdir();
copyOriHelm3Charts(baseDirPath, "Chart.yaml");
copyOriHelm3Charts(baseDirPath, "README.en.md");
copyOriHelm3Charts(baseDirPath, "README.md");
// copyOriHelm3Charts(baseDirPath,"values.yaml");
copyOriHelm3Charts(baseDirPath, "/templates/_helpers.tpl");
copyOriHelm3Charts(baseDirPath, "/templates/configmap-root.yaml");
copyOriHelm3Charts(baseDirPath, "/templates/deployment.yaml");
copyOriHelm3Charts(baseDirPath, "/templates/NOTES.txt");
}
String context = IOUtil.slurp(IOUtil.fileToInputStream(
IOUtil.mergeFolderAndFilePath("/deploy/k8s/duckula-task", "values.yaml"), ViewPodLog.class));
Map<String, String> params = new HashMap<String, String>();
String result = FreemarkUtil.getInst().doProcessByTemp(context, params);
FileUtils.write(new File(IOUtil.mergeFolderAndFilePath(baseDirPath, "values.yaml")), result);
TarUtil.compress(baseDirPath, baseDirPath + ".tar");
J2EEAssist.getFileOS(requestGlobals.getHTTPServletResponse(), baseDirPath + ".tar", true);
} catch (Exception e) {
log.error("导出文件失败",e);
} finally {
try {
FileUtils.forceDelete(new File(baseDirPath));
FileUtils.forceDelete(new File(baseDirPath + ".tar"));
} catch (IOException e) {
log.error("删除文件失败", e);
}
}
}
private void copyOriHelm3Charts(String baseDirPath, String path) throws IOException {
String oriPath = IOUtil.mergeFolderAndFilePath("/deploy/k8s/duckula-task", path);
InputStream inputStream = IOUtil.fileToInputStream(oriPath, ViewPodLog.class);
File toFile = new File(IOUtil.mergeFolderAndFilePath(baseDirPath, path));
FileUtils.copyInputStreamToFile(inputStream, toFile);
}
} }
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>duckula3-char</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
apiVersion: v2
name: duckula-task
description: The chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: 3.0.0
# duckula3-char
#### Description
duckula最新版本的部署包
#### Software Architecture
Software architecture description
#### Installation
1. xxxx
2. xxxx
3. xxxx
#### Instructions
1. xxxx
2. xxxx
3. xxxx
#### Contribution
1. Fork the repository
2. Create Feat_xxx branch
3. Commit your code
4. Create Pull Request
#### Gitee Feature
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
4. The most valuable open source project [GVP](https://gitee.com/gvp)
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
# duckula3-char
#### 介绍
duckula最新版本的部署包
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 码云特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "duckula3-char.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "duckula3-char.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "duckula3-char.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "duckula3-char.labels" -}}
helm.sh/chart: {{ include "duckula3-char.chart" . }}
{{ include "duckula3-char.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "duckula3-char.selectorLabels" -}}
app.kubernetes.io/name: {{ include "duckula3-char.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "duckula3-char.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "duckula3-char.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
{{- if .Values.userconfig.root }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "duckula3-char.fullname" . }}-root
data:
{{- range $key, $val := .Values.userconfig.root }}
{{ $key }}: |-
{{ $val | indent 4}}
{{- end }}
{{- end -}}
\ No newline at end of file
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "duckula3-char.fullname" . }}
labels:
{{- include "duckula3-char.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "duckula3-char.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "duckula3-char.selectorLabels" . | nindent 8 }}
spec:
initContainers:
- name: pro-data
image: '{{ .Values.image }}:{{ .Values.imageDataTag }}'
imagePullPolicy: IfNotPresent
volumeMounts:
- name: data
mountPath: /data/duckula-data
{{- if .Values.userconfig.root }}
- name: userconfig-root
mountPath: /opt/userconfig
{{- end }}
{{- if .Values.userconfig.es }}
- name: userconfig-es
mountPath: /opt/userconfig/es
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: '{{ .Values.image }}:{{ .Values.imageOpsTag | default .Chart.AppVersion }}'
imagePullPolicy: IfNotPresent
args: [{{ .Values.cmd |quote }},"$(taskid)","2723"]
ports:
- name: jmx
containerPort: 2723
- name: jmxexporter
containerPort: 2780
- name: debug
containerPort: 2113
livenessProbe:
exec:
command:
- /bin/sh
- -c
- "/bin/echo 0"
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
readinessProbe:
exec:
command:
- /bin/sh
- -c
- "/bin/echo 0"
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 1
successThreshold: 1
failureThreshold: 3
volumeMounts:
- name: data
mountPath: /data/duckula-data
{{- if .Values.userconfig.root }}
- name: userconfig-root
mountPath: /opt/userconfig
{{- end }}
{{- if .Values.userconfig.es }}
- name: userconfig-es
mountPath: /opt/userconfig/es
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: data
emptyDir: {}
{{- if .Values.userconfig.root }}
- name: userconfig-root
configMap:
name: {{ template "duckula3-char.fullname" . }}-root
{{- end }}
{{- if .Values.userconfig.es }}
- name: userconfig-es
configMap:
name: {{ template "duckula3-char.fullname" . }}-es
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
# Default values for duckula3-char.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image: '${task_image}'
imageOpsTag: ${task_version}
imageDataTag: ${data_version}
cmd: ${cmd}
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}
#支持2层目录,暂只用一层就好了
userconfig:
root:
configmap.properties: |-
${filecontext}
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<body> <body>
<r:query id="q" qBlock="query" queryUrl="/runing/TaskManager:query" uBlock="save" saveUrl="/runing/TaskManager:save" deleteUrl="/runing/TaskManager:del" opFormatter="showopt" <r:query id="q" qBlock="query" queryUrl="/runing/TaskManager:query" uBlock="save" saveUrl="/runing/TaskManager:save" deleteUrl="/runing/TaskManager:del" opFormatter="showopt"
columns="[[{field:'name',width:200,title:'监听任务名'},{field:'version1',width:80,title:'版本'},{field:'deployId1',width:150,title:'布署环境'},{field:'middlewareId1',width:150,title:'目的中间件'},{field:'instanceId1',width:350,title:'监听实例'},{field:'checkpoint1',width:140,title:'检查点'},{field:'taskStatus',width:100,title:'运行状态'},{field:'pos',width:120,title:'运行位点'},{field:'op',width:280,title:'操作'}]]" columns="[[{field:'name',width:200,title:'监听任务名'},{field:'version1',width:80,title:'版本'},{field:'deployId1',width:150,title:'布署环境'},{field:'middlewareId1',width:150,title:'目的中间件'},{field:'instanceId1',width:350,title:'监听实例'},{field:'checkpoint1',width:140,title:'检查点'},{field:'taskStatus',width:100,title:'运行状态'},{field:'pos',width:120,title:'运行位点'},{field:'op',width:280,title:'操作'}]]"
dialogStyle="width:900px;height:560px;" initAddHandle="initAdd" initSaveHandle="initUpdate" queryButs="[{'id':'viewLogBut','iconCls':'icon-attach','text':'查看日志'},{'id':'viewConfigBut','iconCls':'icon-attach','text':'查看配置'},{'id':'editPosBut','text':'位点配置'}]" saveCheckHandle="saveCheck" pagination="true"/> dialogStyle="width:900px;height:560px;" initAddHandle="initAdd" initSaveHandle="initUpdate" queryButs="[{'id':'viewLogBut','iconCls':'icon-attach','text':'查看日志'},{'id':'viewConfigBut','iconCls':'icon-attach','text':'查看配置'},{'id':'editPosBut','text':'位点配置'},{'id':'taskdownBut','iconCls':'icon-attach','text':'任务离线下载'}]" saveCheckHandle="saveCheck" pagination="true"/>
<t:block id="query"> <t:block id="query">
<table class="frame_table_list_4"> <table class="frame_table_list_4">
<tr> <tr>
...@@ -181,8 +181,7 @@ ...@@ -181,8 +181,7 @@
</tr> </tr>
</thead> </thead>
</table> </table>
</r:dialog> </r:dialog>
<script> <script>
function showopt(value,row,index){ function showopt(value,row,index){
var reg = RegExp(/未布署/); var reg = RegExp(/未布署/);
...@@ -222,12 +221,11 @@ ...@@ -222,12 +221,11 @@
//把权限退到“保存”按钮,这样就可以查看任务了 //把权限退到“保存”按钮,这样就可以查看任务了
var reg = RegExp(/未布署/); var reg = RegExp(/未布署/);
var opt=!reg.test(row.taskStatus); var opt=!reg.test(row.taskStatus);
$('#q_saveDoBut').unbind('click');
if(opt){ if(opt){
$('#q_saveDoBut').linkbutton('disable').unbind('click'); $('#q_saveDoBut').linkbutton('disable');
}else{ }else{
$('#q_saveDoBut').linkbutton('enable').click(function(){ $('#q_saveDoBut').bind('click', _doSaveRecode);
_doSaveRecode();
});
} }
} }
...@@ -321,6 +319,34 @@ ...@@ -321,6 +319,34 @@
},'json'); },'json');
}); });
} }
function taskdown(){
var row = jQuery('#q_grid').datagrid('getSelected');
if(!row){
$.rjzjh.alert('需要选择任务');
return;
}
$.rjzjh.confirm('你确定要下载适用于署地化部署的helm3 chart包进行独立安装监听任务吗?',function(){
$.messager.progress({
title:window.msg.hintwaiting,
msg:window.msg.hinthandling
});
var urlpar= $.rjzjh.packurl('/tools/DownLoadHelm3Charts/task/'+row.id);
//借用q_updateform,就不用新建form了
jQuery('#q_updateform').form('submit',{
url :'/zh/tools/DownLoadHelm3Charts/task/1344921618608640002',
onSubmit: function(){
},
success: function(data){
//下载时不会触发,跳走了
}
});
jQuery.messager.progress('close');
//$.post($.rjzjh.packurl('/tools/DownLoadHelm3Charts/task/'+row.id),row,function(data){
// $.messager.progress('close');
// },'json');
});
}
function addConfig(){ function addConfig(){
...@@ -552,12 +578,14 @@ ...@@ -552,12 +578,14 @@
var reg = RegExp(/未布署/); var reg = RegExp(/未布署/);
var opt=!reg.test(row.taskStatus); var opt=!reg.test(row.taskStatus);
if(opt){ if(opt){
$('#viewLogBut').unbind('click');
$('#viewLogBut').linkbutton('enable').bind('click', viewLog); $('#viewLogBut').linkbutton('enable').bind('click', viewLog);
$('#editPosBut').menubutton('disable'); $('#editPosBut').menubutton('disable');
}else{ }else{
$('#viewLogBut').linkbutton('disable').unbind('click',viewLog,false); $('#viewLogBut').linkbutton('disable').unbind('click',viewLog,false);
$('#editPosBut').menubutton('enable'); $('#editPosBut').menubutton('enable');
} }
$('#viewConfigBut').unbind('click');
$('#viewConfigBut').linkbutton('enable').bind('click', viewConfig); $('#viewConfigBut').linkbutton('enable').bind('click', viewConfig);
} }
}); });
...@@ -567,6 +595,8 @@ ...@@ -567,6 +595,8 @@
$('#opsSelBut').bind('click', opsSel); $('#opsSelBut').bind('click', opsSel);
$('#opsDelBut').bind('click', opsDel); $('#opsDelBut').bind('click', opsDel);
$('#savePosBut').bind('click', savePos); $('#savePosBut').bind('click', savePos);
$('#taskdownBut').bind('click', taskdown);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册