|
@@ -4,6 +4,7 @@ import api.common.pojo.constants.DictConstants;
|
|
|
import api.common.pojo.dto.ProjectMessageDTO;
|
|
|
import api.common.util.*;
|
|
|
import com.css.simulation.resource.scheduler.configuration.docker.DockerConfiguration;
|
|
|
+import com.css.simulation.resource.scheduler.configuration.kubernetes.KubernetesConfiguration;
|
|
|
import com.css.simulation.resource.scheduler.mapper.*;
|
|
|
import com.css.simulation.resource.scheduler.pojo.po.*;
|
|
|
import com.css.simulation.resource.scheduler.pojo.to.*;
|
|
@@ -13,7 +14,6 @@ import com.css.simulation.resource.scheduler.util.ProjectUtil;
|
|
|
import com.css.simulation.resource.scheduler.util.RedisUtil;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-import io.kubernetes.client.openapi.ApiClient;
|
|
|
import io.minio.MinioClient;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -36,7 +36,7 @@ import java.util.stream.Collectors;
|
|
|
public class ProjectService {
|
|
|
|
|
|
/*
|
|
|
- algorithm-platform:
|
|
|
+ algorithm-platform:
|
|
|
appid: 2af6f44d98104dc5adcbfb49809ff9d5
|
|
|
secret: db129a741fde1e9f474199dea24f3901
|
|
|
token-uri: https://open.zoogooy.com.cn/cgi-bin/token/token?grant_type=client_credential
|
|
@@ -68,8 +68,7 @@ public class ProjectService {
|
|
|
String username;
|
|
|
@Value("${scheduler.host.password}")
|
|
|
String password;
|
|
|
- @Value("${scheduler.kubernetes.namespace}")
|
|
|
- String kubernetesNamespace;
|
|
|
+
|
|
|
@Resource
|
|
|
StringRedisTemplate stringRedisTemplate;
|
|
|
@Resource
|
|
@@ -91,11 +90,11 @@ public class ProjectService {
|
|
|
@Resource
|
|
|
AlgorithmMapper algorithmMapper;
|
|
|
@Resource
|
|
|
- ApiClient apiClient;
|
|
|
- @Resource
|
|
|
ProjectUtil projectUtil;
|
|
|
@Resource
|
|
|
DockerConfiguration dockerConfiguration;
|
|
|
+ @Resource
|
|
|
+ KubernetesConfiguration kubernetesConfiguration;
|
|
|
|
|
|
|
|
|
// -------------------------------- Comment --------------------------------
|
|
@@ -421,9 +420,10 @@ public class ProjectService {
|
|
|
public void createPod(String projectId, Map<String, Integer> nodeMap, String algorithmDockerImage) {
|
|
|
String podString = FileUtil.read(new File(podTemplateYaml));
|
|
|
String replace0 = podString.replace("vtd-container", "vtd-" + projectId);
|
|
|
- String replace1 = replace0.replace("algorithm-container", "algorithm-" + projectId);
|
|
|
- String replace2 = replace1.replace("algorithm-image", algorithmDockerImage);
|
|
|
- String podTemplateStringOfProject = replace2.replace("kafkaTopic", projectId); // 消息主题名称为 projectId
|
|
|
+ String replace1 = replace0.replace("vtd-image", kubernetesConfiguration.getVtdImage());
|
|
|
+ String replace2 = replace1.replace("algorithm-container", "algorithm-" + projectId);
|
|
|
+ String replace3 = replace2.replace("algorithm-image", algorithmDockerImage);
|
|
|
+ String podTemplateStringOfProject = replace3.replace("kafkaTopic", projectId); // 消息主题名称为 projectId
|
|
|
String podTemplateFileNameOfProject = "project-" + projectId + ".yaml"; // 模板文件名称
|
|
|
FileUtil.writeStringToLocalFile(podTemplateStringOfProject, podYamlDirectory + podTemplateFileNameOfProject);
|
|
|
|
|
@@ -431,7 +431,7 @@ public class ProjectService {
|
|
|
for (int i = 0; i < parallelism; i++) {
|
|
|
String podName = projectUtil.getRandomPodName(projectId); // 生成 podName
|
|
|
String tempReplace4 = podTemplateStringOfProject.replace("pod-name", podName); // pod 名称包括 projectId 和 随机字符串
|
|
|
- String tempReplace5 = tempReplace4.replace("namespace-name", kubernetesNamespace); // pod 名称包括 projectId 和 随机字符串
|
|
|
+ String tempReplace5 = tempReplace4.replace("namespace-name", kubernetesConfiguration.getNamespace()); // pod 名称包括 projectId 和 随机字符串
|
|
|
String tempPodString = tempReplace5.replace("node-name", nodeName); // 指定 pod 运行节点
|
|
|
log.info("ProjectService--createPod 在节点 " + nodeName + " 开始执行 pod:" + tempPodString);
|
|
|
projectUtil.createPod(nodeName, podName, tempPodString);
|
|
@@ -442,7 +442,7 @@ public class ProjectService {
|
|
|
|
|
|
/**
|
|
|
* @param projectId 手动项目 id 或自动项目子id
|
|
|
- * @param projectType
|
|
|
+ * @param projectType 项目类型
|
|
|
*/
|
|
|
@SneakyThrows
|
|
|
public void stopProject(String projectId, String projectType) {
|