瀏覽代碼

增加 pod cpu 限制

martin 2 年之前
父節點
當前提交
0ce899bc81

+ 1 - 1
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/consumer/ProjectConsumer.java

@@ -230,7 +230,7 @@ public class ProjectConsumer {
         /*
             {
                 "projectId": "sadfasdfs",	// 项目 id
-                "type": "1",	// 项目 id
+                "type": "1",	// 项目类型
             }
          */
 

+ 6 - 0
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/service/ProjectService.java

@@ -392,8 +392,14 @@ public class ProjectService {
     }
 
 
+    /**
+     *
+     * @param projectId 手动项目 id 或自动项目子id
+     * @param projectType
+     */
     @SneakyThrows
     public void stopProject(String projectId, String projectType) {
+
         //2 根据 pod 前缀删除所有 pod
         String podPrefix = "project-" + projectId;
         Set<String> nodeOfPodKeySet = RedisUtil.getKeySetByPrefix(stringRedisTemplate, "pod:" + podPrefix);

+ 11 - 1
simulation-resource-scheduler/src/main/resources/kubernetes/template/pod/pod-template.yaml

@@ -15,7 +15,7 @@ spec:
     - name: vtd-container
       image: vtd.run.perception:latest
       imagePullPolicy: Never
-      command: [ "/Controller/VTDController", "/Controller/config/docker_cloud.ini", "kafkaTopic"]
+      command: [ "/Controller/VTDController", "/Controller/config/docker_cloud.ini", "kafkaTopic" ]
       env:
         - name: PodName
           valueFrom:
@@ -30,10 +30,20 @@ spec:
           mountPath: /dev/nvidiactl
       securityContext:
         privileged: true
+      resources:
+        limits:
+          cpu: "1.5"
+        requests:
+          cpu: "0.5"
     - name: algorithm-container
       image: algorithm-image
       imagePullPolicy: Never
       command: [ "/bin/sh", "-c", "/run.sh; touch /tmp/hello.txt;while true;do /bin/echo $(date +%T) >> /tmp/hello.txt; sleep 5; done;" ]
+      resources:
+        limits:
+          cpu: "2.5"
+        requests:
+          cpu: "1.5"
   restartPolicy: Never
   volumes:
     - name: nvidia0