Service type ClusterIP - Controller port forward through CLI (#431)
setting serviceType to ClusterIP as default for fission controller and corresponding changes in fission cli to be able to port-forward the controller pod.
This commit is contained in:
committed by
smruthi2187
parent
1428c64b4f
commit
b9a559af2f
+28
-2
@@ -21,6 +21,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -602,10 +603,35 @@ func fnPods(c *cli.Context) error {
|
||||
}
|
||||
|
||||
func fnTest(c *cli.Context) error {
|
||||
//we can port-forward the router specifically for this method
|
||||
fnName := c.String("name")
|
||||
if len(fnName) == 0 {
|
||||
fatal("Need function name to be specified with --name")
|
||||
}
|
||||
|
||||
routerURL := os.Getenv("FISSION_ROUTER")
|
||||
if len(routerURL) == 0 {
|
||||
fatal("Need FISSION_ROUTER set to your fission router.")
|
||||
localRouterPort, err := findFreePort()
|
||||
if err != nil {
|
||||
fatal(fmt.Sprintf("Error finding unused port for router :%s", err.Error()))
|
||||
}
|
||||
|
||||
fissionNamespace := os.Getenv("FISSION_NAMESPACE")
|
||||
go func() {
|
||||
err := runportForward("router", localRouterPort, fissionNamespace)
|
||||
if err != nil {
|
||||
fatal(err.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
for {
|
||||
conn, _ := net.DialTimeout("tcp", net.JoinHostPort("", localRouterPort), time.Second)
|
||||
if conn != nil {
|
||||
conn.Close()
|
||||
break
|
||||
}
|
||||
}
|
||||
routerURL = "127.0.0.1:" + localRouterPort
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("http://%s/fission-function/%s", routerURL, fnName)
|
||||
@@ -621,7 +647,7 @@ func fnTest(c *cli.Context) error {
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
checkErr(err, "read log response from pod")
|
||||
fmt.Printf("Error calling function %v: %v %v", fnName, resp.StatusCode, string(body))
|
||||
fmt.Printf("Error calling function %s: %d %s", fnName, resp.StatusCode, string(body))
|
||||
defer resp.Body.Close()
|
||||
err = printPodLogs(c)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user