Allow to set the dashboard proxyfied port
parent
27d738657c
commit
f76b0795d8
|
@ -24,6 +24,7 @@ import (
|
|||
"os/exec"
|
||||
"os/user"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
@ -44,7 +45,8 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
dashboardURLMode bool
|
||||
dashboardURLMode bool
|
||||
dashboardExposedPort int
|
||||
// Matches: 127.0.0.1:8001
|
||||
// TODO(tstromberg): Get kubectl to implement a stable supported output format.
|
||||
hostPortRe = regexp.MustCompile(`127.0.0.1:\d{4,}`)
|
||||
|
@ -92,7 +94,7 @@ var dashboardCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
out.ErrT(style.Launch, "Launching proxy ...")
|
||||
p, hostPort, err := kubectlProxy(kubectlVersion, cname)
|
||||
p, hostPort, err := kubectlProxy(kubectlVersion, cname, dashboardExposedPort)
|
||||
if err != nil {
|
||||
exit.Error(reason.HostKubectlProxy, "kubectl proxy", err)
|
||||
}
|
||||
|
@ -126,10 +128,10 @@ var dashboardCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
// kubectlProxy runs "kubectl proxy", returning host:port
|
||||
func kubectlProxy(kubectlVersion string, contextName string) (*exec.Cmd, string, error) {
|
||||
func kubectlProxy(kubectlVersion string, contextName string, port int) (*exec.Cmd, string, error) {
|
||||
// port=0 picks a random system port
|
||||
|
||||
kubectlArgs := []string{"--context", contextName, "proxy", "--port=0"}
|
||||
kubectlArgs := []string{"--context", contextName, "proxy", "--port", strconv.Itoa(port)}
|
||||
|
||||
var cmd *exec.Cmd
|
||||
if kubectl, err := exec.LookPath("kubectl"); err == nil {
|
||||
|
@ -217,4 +219,5 @@ func checkURL(url string) error {
|
|||
|
||||
func init() {
|
||||
dashboardCmd.Flags().BoolVar(&dashboardURLMode, "url", false, "Display dashboard URL instead of opening a browser")
|
||||
dashboardCmd.Flags().IntVar(&dashboardExposedPort, "port", 0, "Exposed port of the proxyfied dashboard. Set to 0 to pick a random port.")
|
||||
}
|
||||
|
|
|
@ -20,7 +20,8 @@ minikube dashboard [flags]
|
|||
### Options
|
||||
|
||||
```
|
||||
--url Display dashboard URL instead of opening a browser
|
||||
--port int Exposed port of the proxyfied dashboard. Set to 0 to pick a random port.
|
||||
--url Display dashboard URL instead of opening a browser
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
|
|
@ -215,6 +215,7 @@
|
|||
"Existing disk is missing new features ({{.error}}). To upgrade, run 'minikube delete'": "",
|
||||
"Exiting": "Wird beendet",
|
||||
"Exiting due to {{.fatal_code}}: {{.fatal_msg}}": "",
|
||||
"Exposed port of the proxyfied dashboard. Set to 0 to pick a random port.": "",
|
||||
"External Adapter on which external switch will be created if no external switch is found. (hyperv driver only)": "",
|
||||
"Fail check if container paused": "",
|
||||
"Failed runtime": "",
|
||||
|
|
|
@ -220,6 +220,7 @@
|
|||
"Existing disk is missing new features ({{.error}}). To upgrade, run 'minikube delete'": "",
|
||||
"Exiting": "Saliendo",
|
||||
"Exiting due to {{.fatal_code}}: {{.fatal_msg}}": "",
|
||||
"Exposed port of the proxyfied dashboard. Set to 0 to pick a random port.": "",
|
||||
"External Adapter on which external switch will be created if no external switch is found. (hyperv driver only)": "",
|
||||
"Fail check if container paused": "",
|
||||
"Failed runtime": "",
|
||||
|
|
|
@ -218,6 +218,7 @@
|
|||
"Existing disk is missing new features ({{.error}}). To upgrade, run 'minikube delete'": "Il manque de nouvelles fonctionnalités sur le disque existant ({{.error}}). Pour mettre à niveau, exécutez 'minikube delete'",
|
||||
"Exiting": "Fermeture…",
|
||||
"Exiting due to {{.fatal_code}}: {{.fatal_msg}}": "Fermeture en raison de {{.fatal_code}} : {{.fatal_msg}}",
|
||||
"Exposed port of the proxyfied dashboard. Set to 0 to pick a random port.": "",
|
||||
"External Adapter on which external switch will be created if no external switch is found. (hyperv driver only)": "L'adaptateur externe sur lequel un commutateur externe sera créé si aucun commutateur externe n'est trouvé. (pilote hyperv uniquement)",
|
||||
"Fail check if container paused": "Échec de la vérification si le conteneur est en pause",
|
||||
"Failed runtime": "Échec de l'exécution",
|
||||
|
|
|
@ -208,6 +208,7 @@
|
|||
"Exiting": "終了しています",
|
||||
"Exiting due to {{.fatal_code}}: {{.fatal_msg}}": "",
|
||||
"Exiting.": "終了しています",
|
||||
"Exposed port of the proxyfied dashboard. Set to 0 to pick a random port.": "",
|
||||
"External Adapter on which external switch will be created if no external switch is found. (hyperv driver only)": "",
|
||||
"Fail check if container paused": "",
|
||||
"Failed runtime": "",
|
||||
|
|
|
@ -232,6 +232,7 @@
|
|||
"Executing \"{{.command}}\" took an unusually long time: {{.duration}}": "",
|
||||
"Existing disk is missing new features ({{.error}}). To upgrade, run 'minikube delete'": "",
|
||||
"Exiting due to {{.fatal_code}}: {{.fatal_msg}}": "",
|
||||
"Exposed port of the proxyfied dashboard. Set to 0 to pick a random port.": "",
|
||||
"External Adapter on which external switch will be created if no external switch is found. (hyperv driver only)": "",
|
||||
"Fail check if container paused": "",
|
||||
"Failed runtime": "런타임이 실패하였습니다",
|
||||
|
|
|
@ -223,6 +223,7 @@
|
|||
"Executing \"{{.command}}\" took an unusually long time: {{.duration}}": "",
|
||||
"Existing disk is missing new features ({{.error}}). To upgrade, run 'minikube delete'": "",
|
||||
"Exiting due to {{.fatal_code}}: {{.fatal_msg}}": "",
|
||||
"Exposed port of the proxyfied dashboard. Set to 0 to pick a random port.": "",
|
||||
"External Adapter on which external switch will be created if no external switch is found. (hyperv driver only)": "",
|
||||
"Fail check if container paused": "",
|
||||
"Failed runtime": "",
|
||||
|
|
|
@ -201,6 +201,7 @@
|
|||
"Executing \"{{.command}}\" took an unusually long time: {{.duration}}": "",
|
||||
"Existing disk is missing new features ({{.error}}). To upgrade, run 'minikube delete'": "",
|
||||
"Exiting due to {{.fatal_code}}: {{.fatal_msg}}": "",
|
||||
"Exposed port of the proxyfied dashboard. Set to 0 to pick a random port.": "",
|
||||
"External Adapter on which external switch will be created if no external switch is found. (hyperv driver only)": "",
|
||||
"Fail check if container paused": "",
|
||||
"Failed runtime": "",
|
||||
|
|
|
@ -280,6 +280,7 @@
|
|||
"Exiting due to driver incompatibility": "由于驱动程序不兼容而退出",
|
||||
"Exiting due to {{.fatal_code}}: {{.fatal_msg}}": "",
|
||||
"Exiting.": "正在退出。",
|
||||
"Exposed port of the proxyfied dashboard. Set to 0 to pick a random port.": "",
|
||||
"External Adapter on which external switch will be created if no external switch is found. (hyperv driver only)": "",
|
||||
"Fail check if container paused": "",
|
||||
"Failed runtime": "",
|
||||
|
|
Loading…
Reference in New Issue