Browse Source

update helmstart node_selector, image_pull_secret

Zhang Li 1 year ago
parent
commit
e5e11999c1

+ 8 - 3
dag-jupyter/internal/api/helm-wrapper.go

@@ -31,13 +31,18 @@ func genParam(req *types.CreateJupyterInfo) map[string]interface{} {
 	settings = append(settings, fmt.Sprintf("ingress.jupyterlab.hosts[0].paths[0].pathType=%s", req.PathType))
 	logx.Info(req.IngressClass, "-------  len: ", len(req.IngressClass))
 	if len(req.IngressClass) > 0 {
-		// ingressClass, _ := json.Marshal(map[string]string{
-		// 	"kubernetes.io/ingress.class": req.IngressClass,
-		// })
+
 		settings = append(settings, fmt.Sprintf("ingress.jupyterlab.annotations.kubernetes\\.io/ingress\\.class=%s", req.IngressClass))
 		settings = append(settings, fmt.Sprintf("ingress.jupyterlab.annotations.nginx\\.ingress\\.kubernetes\\.io/proxy-body-size=%s", "8192m"))
 
 	}
+	if req.NodeSelector != "" {
+		settings = append(settings, fmt.Sprintf("jupyterlab.nodeSelector.kubernetes\\.io/hostname=%s", req.NodeSelector))
+	}
+
+	if req.ImagePullSecret != "" {
+		settings = append(settings, fmt.Sprintf("jupyterlab.imagePullSecrets[0].name=%s", req.ImagePullSecret))
+	}
 	settings = append(settings, fmt.Sprintf("jupyterlab.image.repository=%s", req.Image))
 	settings = append(settings, fmt.Sprintf("jupyterlab.image.tag=%s", req.Tag))
 	settings = append(settings, fmt.Sprintf("jupyterlab.config.baseUrl=%s", req.BaseUrl))

+ 1 - 0
dag-jupyter/internal/logic/startoplogic.go

@@ -43,6 +43,7 @@ func formatPassword(password string) string {
 
 func (l *StartOpLogic) StartOp(req *types.CreateJupyterInfo) (resp *types.Response, err error) {
 	req.Password = formatPassword(req.Password)
+	logx.Infof("req: %+v", req)
 	err = api.Install(req)
 	data := map[string]interface{}{
 		"namespace":    req.Namespace,

+ 14 - 12
dag-jupyter/internal/types/types.go

@@ -11,18 +11,20 @@ type PasswordRequest struct {
 }
 
 type CreateJupyterInfo struct {
-	Password     string `json:"password"`
-	Workspace    string `json:"workspace"`
-	Image        string `json:"image"`
-	Tag          string `json:"tag"`
-	BaseUrl      string `json:"base_url"`
-	Host         string `json:"host"`
-	Path         string `json:"path"`
-	PathType     string `json:"path_type"`
-	ReleaseName  string `json:"release_name"`
-	Namespace    string `json:"namespace"`
-	Chart        string `json:"chart"`
-	IngressClass string `json:"ingress_class" default:""`
+	Password        string `json:"password"`
+	Workspace       string `json:"workspace"`
+	Image           string `json:"image"`
+	Tag             string `json:"tag"`
+	BaseUrl         string `json:"base_url"`
+	Host            string `json:"host"`
+	Path            string `json:"path"`
+	PathType        string `json:"path_type"`
+	ReleaseName     string `json:"release_name"`
+	Namespace       string `json:"namespace"`
+	Chart           string `json:"chart"`
+	IngressClass    string `json:"ingress_class" default:""`
+	NodeSelector    string `json:"node_selector"`
+	ImagePullSecret string `json:"image_pull_secret"`
 }
 
 type DeleteJupyterInfo struct {

+ 14 - 12
jupyter.api

@@ -8,18 +8,20 @@ type (
 		Password string `json:"password"`
 	}
 	CreateJupyterInfo {
-		Password     string `json:"password"`
-		Workspace    string `json:"workspace"`
-		Image        string `json:"image"`
-		Tag          string `json:"tag"`
-		BaseUrl      string `json:"base_url"`
-		Host         string `json:"host"`
-		Path         string `json:"path"`
-		PathType     string `json:"path_type"`
-		ReleaseName  string `json:"release_name"`
-		Namespace    string `json:"namespace"`
-		Chart        string `json:"chart"`
-		IngressClass string `json:"ingress_class" default:""`
+		Password        string `json:"password"`
+		Workspace       string `json:"workspace"`
+		Image           string `json:"image"`
+		Tag             string `json:"tag"`
+		BaseUrl         string `json:"base_url"`
+		Host            string `json:"host"`
+		Path            string `json:"path"`
+		PathType        string `json:"path_type"`
+		ReleaseName     string `json:"release_name"`
+		Namespace       string `json:"namespace"`
+		Chart           string `json:"chart"`
+		IngressClass    string `json:"ingress_class" default:""`
+		NodeSelector    string `json:"node_selector"`
+		ImagePullSecret string `json:"image_pull_secret"`
 	}
 	DeleteJupyterInfo {
 		ReleaseName string `json:"release_name"`