Browse Source

feat: cpu and memory

Zhang Li 1 năm trước cách đây
mục cha
commit
c00dd2be5a

+ 0 - 3
aihub-dag-jupyter/values.yaml

@@ -13,9 +13,6 @@ jupyterlab:
   fullnameOverride: ""
   podAnnotations: {}
   resources:
-    limits:
-      cpu: 2000m
-      memory: 10240Mi
     requests:
       cpu: 100m
       memory: 128Mi

+ 6 - 1
dag-jupyter/internal/api/helm-wrapper.go

@@ -38,7 +38,7 @@ func genParam(req *types.CreateJupyterInfo) map[string]interface{} {
 
 	}
 	if req.NodeSelector != "" {
-		if strings.TrimSpace(req.NodeSelector) == "aihub-dag" {
+		if strings.HasPrefix(strings.TrimSpace(req.NodeSelector), "aihub-dag") {
 			settings = append(settings, fmt.Sprintf("jupyterlab.nodeSelector.aihub-dag=%s", req.NodeSelector))
 
 		} else {
@@ -55,6 +55,11 @@ func genParam(req *types.CreateJupyterInfo) map[string]interface{} {
 	settings = append(settings, fmt.Sprintf("jupyterlab.config.workspace=%s", req.Workspace))
 	settings = append(settings, fmt.Sprintf("jupyterlab.config.password=%s", req.Password))
 
+	if req.Cpu != "" && req.Memory != "" {
+		settings = append(settings, fmt.Sprintf("jupyterlab.resources.limits.cpu=%s", req.Cpu))
+		settings = append(settings, fmt.Sprintf("jupyterlab.resources.limits.memory=%s", req.Memory))
+	}
+
 	m := map[string]interface{}{
 		"dry_run":          false,
 		"create_namespace": false,

+ 2 - 0
dag-jupyter/internal/types/types.go

@@ -25,6 +25,8 @@ type CreateJupyterInfo struct {
 	IngressClass    string `json:"ingress_class" default:""`
 	NodeSelector    string `json:"node_selector"`
 	ImagePullSecret string `json:"image_pull_secret"`
+	Memory          string `json:"memory" default:""`
+	Cpu             string `json:"cpu" default:""`
 }
 
 type DeleteJupyterInfo struct {

+ 2 - 0
jupyter.api

@@ -22,6 +22,8 @@ type (
 		IngressClass    string `json:"ingress_class" default:""`
 		NodeSelector    string `json:"node_selector"`
 		ImagePullSecret string `json:"image_pull_secret"`
+		Memory          string `json:"memory" default:""`
+		Cpu             string `json:"cpu" default:""`
 	}
 	DeleteJupyterInfo {
 		ReleaseName string `json:"release_name"`