Skip to content

Commit

Permalink
fix(dashboard): Add helm-dashboard bind address for docker mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JacieChao authored and orangedeng committed Aug 29, 2023
1 parent 57b793d commit 0cc97b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ RUN curl -sLf https://github.com/komodorio/helm-dashboard/releases/download/v${H
ENV AUTOK3S_CONFIG /root/.autok3s
ENV DOCKER_HOST unix:///var/run/docker.sock
ENV HOME /root
ENV AUTOK3S_HELM_DASHBOARD_ADDRESS=0.0.0.0

WORKDIR /home/shell
VOLUME /root/.autok3s
Expand Down
9 changes: 7 additions & 2 deletions pkg/common/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

const HelmDashboardCommand = "helm-dashboard"

var dashboardBindAddress = "127.0.0.1"

func SwitchDashboard(ctx context.Context, enabled string) error {
if enabled == "true" {
// check if cluster list is empty
Expand Down Expand Up @@ -67,13 +69,16 @@ func InitDashboard(ctx context.Context) {

func StartHelmDashboard(ctx context.Context, port string) error {
_ = os.Setenv(clientcmd.RecommendedConfigPathEnvVar, filepath.Join(CfgPath, KubeCfgFile))
dashboard := exec.CommandContext(ctx, HelmDashboardCommand, "-b", fmt.Sprintf("--port=%s", port))
if os.Getenv("AUTOK3S_HELM_DASHBOARD_ADDRESS") != "" {
dashboardBindAddress = os.Getenv("AUTOK3S_HELM_DASHBOARD_ADDRESS")
}
dashboard := exec.CommandContext(ctx, HelmDashboardCommand, fmt.Sprintf("--bind=%s", dashboardBindAddress), "-b", fmt.Sprintf("--port=%s", port))
dashboard.Stdout = os.Stdout
dashboard.Stderr = os.Stderr
if err := dashboard.Start(); err != nil {
logrus.Errorf("fail to start helm-dashboard: %v", err)
}
logrus.Infof("helm-dashboard will listen on 127.0.0.1:%s ...", port)
logrus.Infof("helm-dashboard will listen on %s:%s ...", dashboardBindAddress, port)
return dashboard.Wait()
}

Expand Down

0 comments on commit 0cc97b3

Please sign in to comment.