You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@submarine.apache.org by GitBox <gi...@apache.org> on 2021/04/13 01:57:11 UTC

[GitHub] [submarine] xunliu commented on a change in pull request #553: SUBMARINE-786. Use helm in k8s cluster

xunliu commented on a change in pull request #553:
URL: https://github.com/apache/submarine/pull/553#discussion_r612072149



##########
File path: submarine-cloud-v2/controller.go
##########
@@ -111,6 +112,34 @@ func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error {
 		return fmt.Errorf("failed to wait for caches to sync")
 	}
 
+	// Example: HelmInstall (can be removed in the future):
+	// This is equal to:
+	// 		helm repo add k8s-as-helm https://ameijer.github.io/k8s-as-helm/
+	// .	helm repo update
+	//  	helm install helm-install-example-release k8s-as-helm/svc --set ports[0].protocol=TCP,ports[0].port=80,ports[0].targetPort=9376
+	// Useful Links: 
+	//   (1) https://github.com/PrasadG193/helm-clientgo-example
+	// . (2) https://github.com/ameijer/k8s-as-helm/tree/master/charts/svc
+	klog.Info("[Helm example] Install")
+	helmActionConfig := helm.HelmInstall(
+		"https://ameijer.github.io/k8s-as-helm/",
+		"k8s-as-helm",
+		"svc",
+		"helm-install-example-release",
+		"default",
+		map[string]string {
+			"set": "ports[0].protocol=TCP,ports[0].port=80,ports[0].targetPort=9376",
+		},	
+	)
+
+	klog.Info("[Helm example] Sleep 60 seconds")
+	time.Sleep(time.Duration(60) * time.Second)

Review comment:
       Why does this need to sleep?

##########
File path: submarine-cloud-v2/pkg/helm/helm.go
##########
@@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Reference: https://github.com/PrasadG193/helm-clientgo-example
+
+package helm
+
+import (
+	"context"
+	"fmt"
+	"gopkg.in/yaml.v2"
+	"io/ioutil"
+	"log"
+	"os"
+	"path/filepath"
+	"strings"
+	"sync"
+	"time"
+
+	"github.com/gofrs/flock"
+	"github.com/pkg/errors"
+	"helm.sh/helm/v3/pkg/action"
+	"helm.sh/helm/v3/pkg/chart"
+	"helm.sh/helm/v3/pkg/chart/loader"
+	"helm.sh/helm/v3/pkg/cli"
+	"helm.sh/helm/v3/pkg/cli/values"
+	"helm.sh/helm/v3/pkg/downloader"
+	"helm.sh/helm/v3/pkg/getter"
+	"helm.sh/helm/v3/pkg/repo"
+	"helm.sh/helm/v3/pkg/strvals"
+)
+
+func HelmInstall(url string, repoName string, chartName string, releaseName string, namespace string, args map[string]string) (*action.Configuration){
+	var settings *cli.EnvSettings
+	os.Setenv("HELM_NAMESPACE", namespace)

Review comment:
       What is the scope of this enviroment variable `HELM_NAMESPACE`?
   Will it affect other places?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org