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/05/14 05:46:15 UTC

[GitHub] [submarine] kevin85421 opened a new pull request #588: SUBMARINE-824. Execute port-forwarding automatically with Golang out-of-cluster

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


   ### What is this PR for?
   Execute the following command via Golang out-of-cluster
   ```
   kubectl port-forward --address 0.0.0.0 -n ${Your_Namespace} service/traefik 32080:80
   ```
   
   Reference: 
   (1) https://gianarb.it/blog/programmatically-kube-port-forward-in-go
   (2) https://github.com/minio/operator/blob/master/kubectl-minio/cmd/proxy.go
   
   ### What type of PR is it?
   [Feature]
   
   ### Todos
   * Execute port-forwarding automatically with Golang in-cluster
        *  The function `k8sutil.ServicePortForwardPort(context.TODO(), namespace, "traefik", 32080, 80, color.FgGreen)` does not work in-cluster.
        * (In submarine-operator pod) `curl 127.0.0.1:32080` --> Yes
        * (Local Chrome browser) 127.0.0.1:32080 --> 404
        * We need to forward the request from 127.0.0.1:32080 to the submarine-operator pod.
   
   
   
   ### What is the Jira issue?
   https://issues.apache.org/jira/browse/SUBMARINE-824
   
   ### How should this be tested?
   https://user-images.githubusercontent.com/20109646/118227081-86001080-b4ba-11eb-9274-6a053954f5f7.mov
   
   
   
   ### Screenshots (if appropriate)
   
   ### Questions:
   * Do the license files need updating? No
   * Are there breaking changes for older versions? No
   * Does this need new documentation? No
   


-- 
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 #588: SUBMARINE-824. Execute port-forwarding automatically with Golang out-of-cluster

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



##########
File path: submarine-cloud-v2/controller.go
##########
@@ -1134,6 +1136,17 @@ func (c *Controller) syncHandler(workqueueItem WorkQueueItem) error {
 		if err != nil {
 			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 !incluster {
+				k8sutil.ServicePortForwardPort(context.TODO(), newNamespace, "traefik", 32080, 80, color.FgGreen)
+			}
+		}
 	} else { // Case: DELETE

Review comment:
       I have fixed it.

##########
File path: submarine-cloud-v2/controller.go
##########
@@ -1134,6 +1136,17 @@ func (c *Controller) syncHandler(workqueueItem WorkQueueItem) error {
 		if err != nil {
 			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 !incluster {

Review comment:
       I have fixed it.




-- 
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] MortalHappiness commented on a change in pull request #588: SUBMARINE-824. Execute port-forwarding automatically with Golang out-of-cluster

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



##########
File path: submarine-cloud-v2/controller.go
##########
@@ -1134,6 +1136,17 @@ func (c *Controller) syncHandler(workqueueItem WorkQueueItem) error {
 		if err != nil {
 			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 !incluster {
+				k8sutil.ServicePortForwardPort(context.TODO(), newNamespace, "traefik", 32080, 80, color.FgGreen)
+			}
+		}
 	} else { // Case: DELETE

Review comment:
       You do not remove the port forward in delete event. So if the submarine custom resource is deleted and re-create again, some bug will happen.

##########
File path: submarine-cloud-v2/controller.go
##########
@@ -112,6 +115,7 @@ type WorkQueueItem struct {
 
 // NewController returns a new sample controller
 func NewController(
+	incluster bool,

Review comment:
       Here you pass `incluster` as parameter but not used.

##########
File path: submarine-cloud-v2/controller.go
##########
@@ -1134,6 +1136,17 @@ func (c *Controller) syncHandler(workqueueItem WorkQueueItem) error {
 		if err != nil {
 			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 !incluster {

Review comment:
       Here the `incluster` still works. But the `incluster` here is actually the global variable in `main.go`. I think what you want to do is to add this `incluster` as one attribute of `struct Controller` and use it.

##########
File path: submarine-cloud-v2/controller.go
##########
@@ -1134,6 +1136,17 @@ func (c *Controller) syncHandler(workqueueItem WorkQueueItem) error {
 		if err != nil {
 			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 !incluster {
+				k8sutil.ServicePortForwardPort(context.TODO(), newNamespace, "traefik", 32080, 80, color.FgGreen)
+			}
+		}
 	} else { // Case: DELETE

Review comment:
       You do not remove the port forward in delete event. So if the submarine custom resource is deleted and re-created again, some bugs will happen.




-- 
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 #588: SUBMARINE-824. Execute port-forwarding automatically with Golang out-of-cluster

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



##########
File path: submarine-cloud-v2/controller.go
##########
@@ -1134,6 +1136,17 @@ func (c *Controller) syncHandler(workqueueItem WorkQueueItem) error {
 		if err != nil {
 			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 !incluster {

Review comment:
       I have fixed it.




-- 
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 pull request #588: SUBMARINE-824. Execute port-forwarding automatically with Golang out-of-cluster

Posted by GitBox <gi...@apache.org>.
kevin85421 commented on pull request #588:
URL: https://github.com/apache/submarine/pull/588#issuecomment-842469857


   @MortalHappiness  Thank you for your recommendations. I have fixed the problems.


-- 
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] MortalHappiness commented on a change in pull request #588: SUBMARINE-824. Execute port-forwarding automatically with Golang out-of-cluster

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



##########
File path: submarine-cloud-v2/controller.go
##########
@@ -1134,6 +1136,17 @@ func (c *Controller) syncHandler(workqueueItem WorkQueueItem) error {
 		if err != nil {
 			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 !incluster {
+				k8sutil.ServicePortForwardPort(context.TODO(), newNamespace, "traefik", 32080, 80, color.FgGreen)
+			}
+		}
 	} else { // Case: DELETE

Review comment:
       You do not remove the port forward in delete event. So if the submarine custom resource is deleted and re-create again, some bug will happen.

##########
File path: submarine-cloud-v2/controller.go
##########
@@ -112,6 +115,7 @@ type WorkQueueItem struct {
 
 // NewController returns a new sample controller
 func NewController(
+	incluster bool,

Review comment:
       Here you pass `incluster` as parameter but not used.

##########
File path: submarine-cloud-v2/controller.go
##########
@@ -1134,6 +1136,17 @@ func (c *Controller) syncHandler(workqueueItem WorkQueueItem) error {
 		if err != nil {
 			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 !incluster {

Review comment:
       Here the `incluster` still works. But the `incluster` here is actually the global variable in `main.go`. I think what you want to do is to add this `incluster` as one attribute of `struct Controller` and use it.




-- 
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] asfgit closed pull request #588: SUBMARINE-824. Execute port-forwarding automatically with Golang out-of-cluster

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #588:
URL: https://github.com/apache/submarine/pull/588


   


-- 
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 pull request #588: SUBMARINE-824. Execute port-forwarding automatically with Golang out-of-cluster

Posted by GitBox <gi...@apache.org>.
kevin85421 commented on pull request #588:
URL: https://github.com/apache/submarine/pull/588#issuecomment-842469857


   @MortalHappiness  Thank you for your recommendations. I have fixed the problems.


-- 
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] MortalHappiness commented on a change in pull request #588: SUBMARINE-824. Execute port-forwarding automatically with Golang out-of-cluster

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



##########
File path: submarine-cloud-v2/controller.go
##########
@@ -1134,6 +1136,17 @@ func (c *Controller) syncHandler(workqueueItem WorkQueueItem) error {
 		if err != nil {
 			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 !incluster {
+				k8sutil.ServicePortForwardPort(context.TODO(), newNamespace, "traefik", 32080, 80, color.FgGreen)
+			}
+		}
 	} else { // Case: DELETE

Review comment:
       You do not remove the port forward in delete event. So if the submarine custom resource is deleted and re-created again, some bugs will happen.




-- 
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 pull request #588: SUBMARINE-824. Execute port-forwarding automatically with Golang out-of-cluster

Posted by GitBox <gi...@apache.org>.
kevin85421 commented on pull request #588:
URL: https://github.com/apache/submarine/pull/588#issuecomment-841586365


   @Kenchu123 @MortalHappiness can you help me review this PR? Thanks!


-- 
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 #588: SUBMARINE-824. Execute port-forwarding automatically with Golang out-of-cluster

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



##########
File path: submarine-cloud-v2/controller.go
##########
@@ -1134,6 +1136,17 @@ func (c *Controller) syncHandler(workqueueItem WorkQueueItem) error {
 		if err != nil {
 			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 !incluster {
+				k8sutil.ServicePortForwardPort(context.TODO(), newNamespace, "traefik", 32080, 80, color.FgGreen)
+			}
+		}
 	} else { // Case: DELETE

Review comment:
       I have fixed it.




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