Update fetchRunner.go, tapRunner.go, and 2 more files...

This commit is contained in:
RamiBerm 2021-07-11 14:06:08 +03:00
parent 3db6d5a5ea
commit 7de3338752
4 changed files with 8 additions and 8 deletions

View File

@ -16,7 +16,7 @@ import (
) )
func RunMizuFetch(fetch *MizuFetchOptions) { func RunMizuFetch(fetch *MizuFetchOptions) {
mizuProxiedUrl := kubernetes.GetMizuCollectorProxiesHostAndPath(uint16(fetch.MizuPort), mizu.ResourcesNamespace, mizu.AggregatorPodName) mizuProxiedUrl := kubernetes.GetMizuCollectorProxiedHostAndPath(uint16(fetch.MizuPort), mizu.ResourcesNamespace, mizu.AggregatorPodName)
resp, err := http.Get(fmt.Sprintf("http://%s/api/har?from=%v&to=%v", mizuProxiedUrl, fetch.FromTimestamp, fetch.ToTimestamp)) resp, err := http.Get(fmt.Sprintf("http://%s/api/har?from=%v&to=%v", mizuProxiedUrl, fetch.FromTimestamp, fetch.ToTimestamp))
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)

View File

@ -248,7 +248,7 @@ func portForwardApiPod(ctx context.Context, kubernetesProvider *kubernetes.Provi
cancel() cancel()
} }
}() }()
mizuProxiedUrl := kubernetes.GetMizuCollectorProxiesHostAndPath(tappingOptions.GuiPort, mizu.ResourcesNamespace, mizu.AggregatorPodName) mizuProxiedUrl := kubernetes.GetMizuCollectorProxiedHostAndPath(tappingOptions.GuiPort, mizu.ResourcesNamespace, mizu.AggregatorPodName)
fmt.Printf("Mizu is available at http://%s\n", mizuProxiedUrl) fmt.Printf("Mizu is available at http://%s\n", mizuProxiedUrl)
time.Sleep(time.Second * 5) // Waiting to be sure the proxy is ready time.Sleep(time.Second * 5) // Waiting to be sure the proxy is ready
@ -321,7 +321,7 @@ func waitForFinish(ctx context.Context, cancel context.CancelFunc) {
} }
func syncApiStatus(ctx context.Context, cancel context.CancelFunc, tappingOptions *MizuTapOptions) { func syncApiStatus(ctx context.Context, cancel context.CancelFunc, tappingOptions *MizuTapOptions) {
controlSocket, err := mizu.CreateControlSocket(fmt.Sprintf("ws://%s/ws", kubernetes.GetMizuCollectorProxiesHostAndPath(tappingOptions.GuiPort, mizu.ResourcesNamespace, mizu.AggregatorPodName))) controlSocket, err := mizu.CreateControlSocket(fmt.Sprintf("ws://%s/ws", kubernetes.GetMizuCollectorProxiedHostAndPath(tappingOptions.GuiPort, mizu.ResourcesNamespace, mizu.AggregatorPodName)))
if err != nil { if err != nil {
fmt.Printf("error establishing control socket connection %s\n", err) fmt.Printf("error establishing control socket connection %s\n", err)
cancel() cancel()

View File

@ -23,7 +23,7 @@ func runMizuView(mizuViewOptions *MizuViewOptions) {
return return
} }
mizuProxiedUrl := kubernetes.GetMizuCollectorProxiesHostAndPath(mizuViewOptions.GuiPort, mizu.ResourcesNamespace, mizu.AggregatorPodName) mizuProxiedUrl := kubernetes.GetMizuCollectorProxiedHostAndPath(mizuViewOptions.GuiPort, mizu.ResourcesNamespace, mizu.AggregatorPodName)
_, err = http.Get(fmt.Sprintf("http://%s/", mizuProxiedUrl)) _, err = http.Get(fmt.Sprintf("http://%s/", mizuProxiedUrl))
if err == nil { if err == nil {
fmt.Printf("Found a running service %s and open port %d\n", mizu.AggregatorPodName, mizuViewOptions.GuiPort) fmt.Printf("Found a running service %s and open port %d\n", mizu.AggregatorPodName, mizuViewOptions.GuiPort)
@ -31,7 +31,7 @@ func runMizuView(mizuViewOptions *MizuViewOptions) {
} }
fmt.Printf("Found service %s, creating k8s proxy\n", mizu.AggregatorPodName) fmt.Printf("Found service %s, creating k8s proxy\n", mizu.AggregatorPodName)
fmt.Printf("Mizu is available at http://%s\n", kubernetes.GetMizuCollectorProxiesHostAndPath(mizuViewOptions.GuiPort, mizu.ResourcesNamespace, mizu.AggregatorPodName)) fmt.Printf("Mizu is available at http://%s\n", kubernetes.GetMizuCollectorProxiedHostAndPath(mizuViewOptions.GuiPort, mizu.ResourcesNamespace, mizu.AggregatorPodName))
err = kubernetes.StartProxy(kubernetesProvider, mizuViewOptions.GuiPort, mizu.ResourcesNamespace, mizu.AggregatorPodName) err = kubernetes.StartProxy(kubernetesProvider, mizuViewOptions.GuiPort, mizu.ResourcesNamespace, mizu.AggregatorPodName)
if err != nil { if err != nil {
fmt.Printf("Error occured while running k8s proxy %v\n", err) fmt.Printf("Error occured while running k8s proxy %v\n", err)

View File

@ -19,7 +19,7 @@ func StartProxy(kubernetesProvider *Provider, mizuPort uint16, mizuNamespace str
RejectMethods: proxy.MakeRegexpArrayOrDie(proxy.DefaultMethodRejectRE), RejectMethods: proxy.MakeRegexpArrayOrDie(proxy.DefaultMethodRejectRE),
} }
mizuProxiedUrl := GetMizuCollectorProxiesHostAndPath(mizuPort, mizuNamespace, mizuServiceName) mizuProxiedUrl := GetMizuCollectorProxiedHostAndPath(mizuPort, mizuNamespace, mizuServiceName)
proxyHandler, err := proxy.NewProxyHandler(k8sProxyApiPrefix, filter, &kubernetesProvider.clientConfig, time.Second * 2) proxyHandler, err := proxy.NewProxyHandler(k8sProxyApiPrefix, filter, &kubernetesProvider.clientConfig, time.Second * 2)
if err != nil { if err != nil {
return err return err
@ -40,7 +40,7 @@ func StartProxy(kubernetesProvider *Provider, mizuPort uint16, mizuNamespace str
return server.Serve(l) return server.Serve(l)
} }
func GetMizuCollectorProxiesHostAndPath(mizuPort uint16, mizuNamespace string, mizuServiceName string) string { func GetMizuCollectorProxiedHostAndPath(mizuPort uint16, mizuNamespace string, mizuServiceName string) string {
return fmt.Sprintf("localhost:%d/api/v1/namespaces/%s/services/%s:80/proxy", mizuPort, mizuNamespace, mizuServiceName) return fmt.Sprintf("localhost:%d/api/v1/namespaces/%s/services/%s:80/proxy", mizuPort, mizuNamespace, mizuServiceName)
} }