You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@submarine.apache.org by li...@apache.org on 2021/06/10 15:11:01 UTC

[submarine] branch master updated: SUBMARINE-835. Exposing method modified

This is an automated email from the ASF dual-hosted git repository.

liuxun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git


The following commit(s) were added to refs/heads/master by this push:
     new ddee828  SUBMARINE-835. Exposing method modified
ddee828 is described below

commit ddee8287a3339714a03e83c2ffce769fb24d0919
Author: noidname01 <ti...@gmail.com>
AuthorDate: Mon Jun 7 14:16:31 2021 +0800

    SUBMARINE-835. Exposing method modified
    
    ### What is this PR for?
    Modify the way to access Submarine in a cluster in documentation.
    
    ### What type of PR is it?
    [Improvement|Documentation]
    
    ### Todos
    
    ### What is the Jira issue?
    https://issues.apache.org/jira/projects/SUBMARINE/issues/SUBMARINE-835
    
    ### How should this be tested?
    
    ### Screenshots (if appropriate)
    
    https://user-images.githubusercontent.com/55401762/120828366-07fdc980-c58f-11eb-8112-c9e83eee2857.mp4
    
    ### Questions:
    * Do the license files need updating? No
    * Are there breaking changes for older versions? No
    * Does this need new documentation? No
    
    Author: noidname01 <ti...@gmail.com>
    
    Signed-off-by: Liu Xun <li...@apache.org>
    
    Closes #600 from noidname01/SUBMARINE-835 and squashes the following commits:
    
    0806be4 [noidname01] SUBMARINE-835. Fix Some Bug
    468475c [noidname01] SUBMARINE-835. Exposing method modified
---
 submarine-cloud-v2/README.md                   | 78 +++++++++++++++++---------
 submarine-cloud-v2/controller.go               | 25 ---------
 website/docs/gettingStarted/localDeployment.md | 33 +++++++++--
 3 files changed, 79 insertions(+), 57 deletions(-)

diff --git a/submarine-cloud-v2/README.md b/submarine-cloud-v2/README.md
index cb87817..1d5e7b0 100644
--- a/submarine-cloud-v2/README.md
+++ b/submarine-cloud-v2/README.md
@@ -1,5 +1,6 @@
 # Why submarine-cloud-v2?
-* Because `submarine-cloud` is outdated, `submarine-cloud-v2` is the refactored version of `submarine-cloud`. In addition, after `submarine-cloud-v2` finishes, we will replace `submarine-cloud` with `submarine-cloud-v2`.
+
+- Because `submarine-cloud` is outdated, `submarine-cloud-v2` is the refactored version of `submarine-cloud`. In addition, after `submarine-cloud-v2` finishes, we will replace `submarine-cloud` with `submarine-cloud-v2`.
 
 # Formatting the code
 
@@ -8,6 +9,7 @@ For `go` files, please use [gofmt](https://golang.org/pkg/cmd/gofmt/) to format
 For `yaml` files, please use [prettier](https://prettier.io/) to format the code.
 
 # Initialization
+
 ```bash
 minikube start --vm-driver=docker  --kubernetes-version v1.15.11
 go mod vendor
@@ -15,7 +17,9 @@ chmod -R 777 vendor
 ```
 
 # Generate API
-* It makes use of the generators in [k8s.io/code-generator](https://github.com/kubernetes/code-generator) to generate a typed client, informers, listers and deep-copy functions. You can do this yourself using the ./update-codegen.sh script. (Note: Before you run update-codegen.sh and verify-codegen.sh, you need to move to hack/ directory at first.)
+
+- It makes use of the generators in [k8s.io/code-generator](https://github.com/kubernetes/code-generator) to generate a typed client, informers, listers and deep-copy functions. You can do this yourself using the ./update-codegen.sh script. (Note: Before you run update-codegen.sh and verify-codegen.sh, you need to move to hack/ directory at first.)
+
 ```bash
 # Step1: Modify doc.go & types.go
 # Step2: Generate API to pkg/generated
@@ -27,6 +31,7 @@ cd hack
 ```
 
 # Add new dependencies
+
 ```bash
 # Step1: Add the dependency to go.mod
 go get ${new_dependency} # Example: go get k8s.io/code-generator
@@ -36,6 +41,7 @@ go mod vendor
 ```
 
 # Run Unit Test
+
 ```bash
 # Step1: Register Custom Resource Definition
 kubectl apply -f artifacts/examples/crd.yaml
@@ -48,6 +54,7 @@ make test-unit
 ```
 
 # Run submarine-operator out-of-cluster
+
 ```bash
 # Step1: Build & Run "submarine-operator"
 go build -o submarine-operator
@@ -57,21 +64,29 @@ go build -o submarine-operator
 kubectl create ns submarine-admin
 kubectl apply -n submarine-admin -f artifacts/examples/example-submarine.yaml
 
-# Step3: "submarine-operator" will perform port-forwarding automatically.
+# Step3: Exposing Service
+# Method1 -- using minikube ip + NodePort
+$ minikube ip  # you'll get the IP address of minikube, ex: 192.168.49.2
+
+# Method2 -- using port-forwarding
+$ kubectl port-forward --address 0.0.0.0 -n submarine-user-test service/traefik 32080:80
 
-# Step4: View workbench (127.0.0.1:32080) with your web browser
+# Step4: View workbench
+# http://{minikube ip}:32080(from Method1), ex: http://192.168.49.2:32080
+# or http://127.0.0.1:32080 (from Method 2).
 
-# Step5: Delete: 
+# Step5: Delete:
 #   (1) Remove all relevant Helm chart releases
 #   (2) Remove all resources in the namespace "submariner-user-test"
-#   (3) Remove all non-namespaced resources (Ex: PersistentVolume) created by client-go API 
+#   (3) Remove all non-namespaced resources (Ex: PersistentVolume) created by client-go API
 #   (4) **Note:** The namespace "submarine-admin" will not be deleted
-kubectl delete submarine example-submarine -n submarine-admin 
+kubectl delete submarine example-submarine -n submarine-admin
 ```
 
 # Run operator in-cluster
+
 ```bash
-# Step1: Build image "submarine-operator" to minikube's Docker 
+# Step1: Build image "submarine-operator" to minikube's Docker
 eval $(minikube docker-env)
 make image
 
@@ -85,38 +100,46 @@ kubectl apply -f artifacts/examples/submarine-operator.yaml
 kubectl create ns submarine-admin
 kubectl apply -n submarine-admin -f artifacts/examples/example-submarine.yaml
 
-# Step5: Inspect submarine-operator POD logs 
+# Step5: Inspect submarine-operator POD logs
 kubectl logs -f ${submarine-operator POD}
 
 # Step6: The operator will create a new namespace "submarine-user-test"
-kubectl get all -n submarine-user-test 
+kubectl get all -n submarine-user-test
+
+# Step7: Exposing Service
+# Method1 -- using minikube ip + NodePort
+$ minikube ip  # you'll get the IP address of minikube, ex: 192.168.49.2
 
-# Step7: port-forwarding
-kubectl port-forward --address 0.0.0.0 -n submarine-user-test service/traefik 32080:80
+# Method2 -- using port-forwarding
+$ kubectl port-forward --address 0.0.0.0 -n submarine-user-test service/traefik 32080:80
 
-# Step8: View workbench (127.0.0.1:32080) with your web browser
+# Step8: View workbench
+# http://{minikube ip}:32080(from Method1), ex: http://192.168.49.2:32080
+# or http://127.0.0.1:32080 (from Method 2).
 
-# Step9: Delete: 
+# Step9: Delete:
 #   (1) Remove all relevant Helm chart releases
 #   (2) Remove all resources in the namespace "submariner-user-test"
-#   (3) Remove all non-namespaced resources (Ex: PersistentVolume) created by client-go API 
+#   (3) Remove all non-namespaced resources (Ex: PersistentVolume) created by client-go API
 #   (4) **Note:** The namespace "submarine-admin" will not be deleted
-kubectl delete submarine example-submarine -n submarine-admin 
+kubectl delete submarine example-submarine -n submarine-admin
 
 # Step10: Delete "submarine-operator"
 kubectl delete deployment submarine-operator-demo
 ```
 
 # Helm Golang API
-* Function `HelmInstall` is defined in pkg/helm/helm.go.
-* Example: (You can see this example in controller.go:123.)
+
+- Function `HelmInstall` is defined in pkg/helm/helm.go.
+- Example: (You can see this example in controller.go:123.)
+
 ```go
 // Example: HelmInstall
 // 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: 
+// Useful Links:
 //   (1) https://github.com/PrasadG193/helm-clientgo-example
 // . (2) https://github.com/ameijer/k8s-as-helm/tree/master/charts/svc
 helmActionConfig := helm.HelmInstall(
@@ -127,19 +150,21 @@ helmActionConfig := helm.HelmInstall(
     "default",
     map[string]string {
         "set": "ports[0].protocol=TCP,ports[0].port=80,ports[0].targetPort=9376",
-    },	
+    },
 )
 // Example: HelmUninstall
 // This is equal to:
-//    helm uninstall helm-install-example-release 
+//    helm uninstall helm-install-example-release
 helm.HelmUninstall("helm-install-example-release", helmActionConfig)
 
 ```
-* Troubleshooting: 
-  * If the release name exists, Helm will report the error "cannot re-use a name that is still in use".
+
+- Troubleshooting:
+  - If the release name exists, Helm will report the error "cannot re-use a name that is still in use".
+
 ```
 helm ls
-helm uninstall helm-install-example-release 
+helm uninstall helm-install-example-release
 ```
 
 # Build custom images when development
@@ -165,10 +190,11 @@ Use the following helper script to run frontend E2E tests.
 # Prerequisite: Make sure Workbench is running on $URL:$WORKBENCH_PORT.
 ./hack/run_frontend_e2e.sh [testcase]
 ```
-* [testcase]: Check the directory [integration](../submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/).
+
+- [testcase]: Check the directory [integration](../submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/).
 
 Examples:
 
 ```
 ./hack/run_frontend_e2e.sh loginIT
-```
\ No newline at end of file
+```
diff --git a/submarine-cloud-v2/controller.go b/submarine-cloud-v2/controller.go
index 676b0db..294c0e7 100644
--- a/submarine-cloud-v2/controller.go
+++ b/submarine-cloud-v2/controller.go
@@ -27,7 +27,6 @@ import (
 	informers "submarine-cloud-v2/pkg/generated/informers/externalversions/submarine/v1alpha1"
 	listers "submarine-cloud-v2/pkg/generated/listers/submarine/v1alpha1"
 	"submarine-cloud-v2/pkg/helm"
-	"submarine-cloud-v2/pkg/k8sutil"
 	v1alpha1 "submarine-cloud-v2/pkg/submarine/v1alpha1"
 	"time"
 
@@ -61,9 +60,6 @@ import (
 	traefikinformers "github.com/traefik/traefik/v2/pkg/provider/kubernetes/crd/generated/informers/externalversions/traefik/v1alpha1"
 	traefiklisters "github.com/traefik/traefik/v2/pkg/provider/kubernetes/crd/generated/listers/traefik/v1alpha1"
 	traefikv1alpha1 "github.com/traefik/traefik/v2/pkg/provider/kubernetes/crd/traefik/v1alpha1"
-
-	"github.com/fatih/color"
-	"os/exec"
 )
 
 const controllerAgentName = "submarine-controller"
@@ -117,7 +113,6 @@ type Controller struct {
 	// TODO: Need to be modified to implement multi-tenant
 	// Store charts
 	charts     []helm.HelmUninstallInfo
-	portfwdCmd *exec.Cmd
 	incluster  bool
 }
 
@@ -178,7 +173,6 @@ func NewController(
 		clusterrolebindingLister:    clusterrolebindingInformer.Lister(),
 		workqueue:                   workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "Submarines"),
 		recorder:                    recorder,
-		portfwdCmd:                  nil,
 		incluster:                   incluster,
 	}
 
@@ -1415,18 +1409,6 @@ func (c *Controller) syncHandler(workqueueItem WorkQueueItem) error {
 			return err
 		}
 
-		// Port-forwarding
-		// TODO:
-		//   (1) multi-tenant port-forwarding
-		//   (2) Basic operations: on/off/modify (change port)
-		//   (3) in-cluster
-		if action == ADD {
-			if !c.incluster {
-				c.portfwdCmd = k8sutil.ServicePortForwardPort(context.TODO(), newNamespace, "traefik", 8080, 80, color.FgGreen)
-			}
-		}
-
-		c.recorder.Event(submarine, corev1.EventTypeNormal, SuccessSynced, MessageResourceSynced)
 	} else { // Case: DELETE
 		// Uninstall Helm charts
 		for _, chart := range c.charts {
@@ -1434,13 +1416,6 @@ func (c *Controller) syncHandler(workqueueItem WorkQueueItem) error {
 		}
 		c.charts = nil
 
-		// Kill port-forward process:
-		if !c.incluster {
-			err = c.portfwdCmd.Process.Kill()
-			if err != nil {
-				return err
-			}
-		}
 	}
 
 	return nil
diff --git a/website/docs/gettingStarted/localDeployment.md b/website/docs/gettingStarted/localDeployment.md
index 6b61510..338f2f2 100644
--- a/website/docs/gettingStarted/localDeployment.md
+++ b/website/docs/gettingStarted/localDeployment.md
@@ -23,21 +23,25 @@ under the License.
 -->
 
 ## Prerequisite
-- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) 
+
+- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
 - [helm](https://helm.sh/docs/intro/install/) (Helm v3 is minimum requirement.)
 - [minikube](https://minikube.sigs.k8s.io/docs/start/).
 
 ## Deploy Kubernetes Cluster
+
 ```
 $ minikube start --vm-driver=docker --cpus 8 --memory 4096 --disk-size=20G --kubernetes-version v1.15.11
 ```
 
 ## Install Submarine on Kubernetes
+
 ```
 $ git clone https://github.com/apache/submarine.git
 $ cd submarine
 $ helm install submarine ./helm-charts/submarine
 ```
+
 ```
 NAME: submarine
 LAST DEPLOYED: Fri Jan 29 05:35:36 2021
@@ -48,7 +52,9 @@ TEST SUITE: None
 ```
 
 ## Verify installation
+
 Once you got it installed, check with below commands and you should see similar outputs:
+
 ```bash
 $ kubectl get pods
 ```
@@ -66,26 +72,41 @@ tf-job-operator-7844656dd-lfgmd                   1/1     Running   0          5
 :::warning
 Note that if you encounter below issue when installation:
 :::
+
 ```bash
 Error: rendered manifests contain a resource that already exists.
 Unable to continue with install: existing resource conflict: namespace: , name: podgroups.scheduling.incubator.k8s.io, existing_kind: apiextensions.k8s.io/v1beta1, Kind=CustomResourceDefinition, new_kind: apiextensions.k8s.io/v1beta1, Kind=CustomResourceDefinition
 ```
+
 It might be caused by the previous installed submarine charts. Fix it by running:
+
 ```bash
 $ kubectl delete crd/tfjobs.kubeflow.org && kubectl delete crd/podgroups.scheduling.incubator.k8s.io && kubectl delete crd/pytorchjobs.kubeflow.org
 ```
 
-## Use Port Forwarding to Access Submarine in a Cluster
-```bash=
-# # Listen on port 32080 on all addresses, forwarding to 80 in the pod
+## Access Submarine in a Cluster
+
+```bash
+# #Listen on port 32080 on all addresses, forwarding to 80 in the pod
+# Method1 -- using minikube ip + NodePort
+$ minikube ip  # you'll get the IP address of minikube, ex: 192.168.49.2
+
+# Method2 -- using port-forwarding
 $ kubectl port-forward --address 0.0.0.0 service/submarine-traefik 32080:80
 ```
+
 ## Open Workbench in the browser.
-Open http://127.0.0.1:32080. The default username and password is `admin` and `admin`
+
+Open http://{minikube ip}:32080(from Method1), ex: http://192.168.49.2:32080
+
+or http://127.0.0.1:32080 (from Method 2).
+
+The default username and password is `admin` and `admin`
 
 ![](https://i.imgur.com/DkZhyEG.png)
 
 ## Uninstall Submarine
+
 ```bash
 $ helm delete submarine
-```
\ No newline at end of file
+```

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@submarine.apache.org
For additional commands, e-mail: dev-help@submarine.apache.org