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/09 10:14:35 UTC

[GitHub] [submarine] kevin85421 opened a new pull request #553: SUBMARINE-786. Use helm in k8s cluster

kevin85421 opened a new pull request #553:
URL: https://github.com/apache/submarine/pull/553


   ### What is this PR for?
   Because the helm chart of Submarine depends on many other charts, submarine-operator needs to be able to install these charts with helm.
   
   
   ### What type of PR is it?
   [Feature]
   
   ### Todos
   * Check if the release has already existed automatically
   
   ### What is the Jira issue?
   https://issues.apache.org/jira/projects/SUBMARINE/issues/SUBMARINE-786?filter=allopenissues
   
   ### How should this be tested?
   * Out-of-cluster
   
   https://user-images.githubusercontent.com/20109646/114165283-dc7bab80-995e-11eb-831d-e9e9d6574eba.mov
   
   * In-cluster
   
   https://user-images.githubusercontent.com/20109646/114165309-e2718c80-995e-11eb-95c3-c28c5d206d0b.mov
   
   
   ### Screenshots (if appropriate)
   
   ### Questions:
   * Does the licenses files need update? No
   * Is there breaking changes for older versions? No
   * Does this needs documentation? Yes
   


-- 
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



[GitHub] [submarine] kevin85421 merged pull request #553: SUBMARINE-786. Use helm in k8s cluster

Posted by GitBox <gi...@apache.org>.
kevin85421 merged pull request #553:
URL: https://github.com/apache/submarine/pull/553


   


-- 
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



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

Posted by GitBox <gi...@apache.org>.
kevin85421 commented on a change in pull request #553:
URL: https://github.com/apache/submarine/pull/553#discussion_r612121192



##########
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:
       This is used to observe the behavior of "helm install" and "helm uninstall".
   Without sleep, the helm chart will be uninstalled immediately after the helm chart installation, and thus we cannot observe the behavior of "helm install".




-- 
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



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

Posted by GitBox <gi...@apache.org>.
kevin85421 commented on a change in pull request #553:
URL: https://github.com/apache/submarine/pull/553#discussion_r612150812



##########
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:
       I tested the function `os.Setenv` with the following example:
   ```go
    package main
   
    import (
        "fmt"
        "os"
    )
   
    func main() {
        os.Setenv("FOO", "1")
        fmt.Println("FOO:", os.Getenv("FOO"))
        fmt.Println("BAR:", os.Getenv("BAR"))
        fmt.Println("PATH:", os.Getenv("PATH"))
        fmt.Println()
    }
   ```
   
   The result is shown in the following figure:
   <img width="1440" alt="ζˆͺεœ– 2021-04-13 δΈ‹εˆ1 54 56" src="https://user-images.githubusercontent.com/20109646/114503551-164ef980-9c60-11eb-928e-3f1cf292fee2.png">
   
   According to the experiment result, the function `os.Setenv` will not influence other processes.




-- 
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



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

Posted by GitBox <gi...@apache.org>.
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