mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-04-04 09:49:23 +00:00
* Update config.go, tapConfig.go, and models.go * WIP * Update go.sum * Update tapRunner.go * Update tap.go * WIP * WIP * Update Dockerfile, main.go, and 2 more files... * WIP * Update utils.go, tapClusterResourceManagement.go, and utils.go * Merge branch 'develop' * Update metadata_controller.go, utils.go, and 2 more files... * Update main.go, utils.go, and tapRunner.go * Update tapRunner.go * Update config.go, config.go, and models.go * Update main.go, main.go, and stats_provider_test.go * Update provider.go * bug fixes * Update main.go, metadata_controller.go, and 13 more files... * Update metadata_controller.go, status_controller.go, and 4 more files... * Update main.go, config.go, and 3 more files... * Update tapRunner.go * Update config.go, stats_provider_test.go, and consts.go
74 lines
2.0 KiB
Go
74 lines
2.0 KiB
Go
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/up9inc/mizu/cli/apiserver"
|
|
"github.com/up9inc/mizu/cli/config"
|
|
"github.com/up9inc/mizu/cli/mizu/fsUtils"
|
|
"github.com/up9inc/mizu/cli/mizu/version"
|
|
"github.com/up9inc/mizu/cli/uiUtils"
|
|
"github.com/up9inc/mizu/shared/kubernetes"
|
|
"github.com/up9inc/mizu/shared/logger"
|
|
)
|
|
|
|
func runMizuView() {
|
|
kubernetesProvider, err := getKubernetesProviderForCli()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
|
|
url := config.Config.View.Url
|
|
|
|
if url == "" {
|
|
exists, err := kubernetesProvider.DoesServicesExist(ctx, config.Config.MizuResourcesNamespace, kubernetes.ApiServerPodName)
|
|
if err != nil {
|
|
logger.Log.Errorf("Failed to found mizu service %v", err)
|
|
cancel()
|
|
return
|
|
}
|
|
if !exists {
|
|
logger.Log.Infof("%s service not found, you should run `mizu tap` command first", kubernetes.ApiServerPodName)
|
|
cancel()
|
|
return
|
|
}
|
|
|
|
url = GetApiServerUrl()
|
|
|
|
response, err := http.Get(fmt.Sprintf("%s/", url))
|
|
if err == nil && response.StatusCode == 200 {
|
|
logger.Log.Infof("Found a running service %s and open port %d", kubernetes.ApiServerPodName, config.Config.View.GuiPort)
|
|
return
|
|
}
|
|
logger.Log.Infof("Establishing connection to k8s cluster...")
|
|
go startProxyReportErrorIfAny(kubernetesProvider, cancel)
|
|
|
|
}
|
|
|
|
apiServerProvider := apiserver.NewProvider(url, apiserver.DefaultRetries, apiserver.DefaultTimeout)
|
|
if err := apiServerProvider.TestConnection(); err != nil {
|
|
logger.Log.Errorf(uiUtils.Error, fmt.Sprintf("Couldn't connect to API server, for more info check logs at %s", fsUtils.GetLogFilePath()))
|
|
return
|
|
}
|
|
|
|
logger.Log.Infof("Mizu is available at %s\n", url)
|
|
|
|
uiUtils.OpenBrowser(url)
|
|
|
|
if isCompatible, err := version.CheckVersionCompatibility(apiServerProvider); err != nil {
|
|
logger.Log.Errorf("Failed to check versions compatibility %v", err)
|
|
cancel()
|
|
return
|
|
} else if !isCompatible {
|
|
cancel()
|
|
return
|
|
}
|
|
|
|
waitForFinish(ctx, cancel)
|
|
}
|