diff --git a/cmd/minikube/cmd/docker-env.go b/cmd/minikube/cmd/docker-env.go index 9be9583bde11..83858724b600 100644 --- a/cmd/minikube/cmd/docker-env.go +++ b/cmd/minikube/cmd/docker-env.go @@ -267,6 +267,7 @@ var dockerEnvCmd = &cobra.Command{ cname := ClusterFlagValue() co := mustload.Running(cname) + driverName := co.CP.Host.DriverName if driverName == driver.None { diff --git a/cmd/minikube/cmd/status.go b/cmd/minikube/cmd/status.go index 617876173f3a..710990297ba0 100644 --- a/cmd/minikube/cmd/status.go +++ b/cmd/minikube/cmd/status.go @@ -37,6 +37,7 @@ import ( "k8s.io/minikube/pkg/minikube/bootstrapper/bsutil/kverify" "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/minikube/config" + "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/driver" "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/kubeconfig" @@ -136,6 +137,8 @@ type Status struct { Kubeconfig string Worker bool TimeToStop string + DockerEnv string `json:",omitempty"` + PodManEnv string `json:",omitempty"` } // ClusterState holds a cluster state representation @@ -183,6 +186,12 @@ kubelet: {{.Kubelet}} apiserver: {{.APIServer}} kubeconfig: {{.Kubeconfig}} timeToStop: {{.TimeToStop}} +{{- if .DockerEnv }} +docker-env: {{.DockerEnv}} +{{- end }} +{{- if .PodManEnv }} +podman-env: {{.PodManEnv}} +{{- end }} ` workerStatusFormat = `{{.Name}} @@ -374,6 +383,12 @@ func nodeStatus(api libmachine.API, cc config.ClusterConfig, n config.Node) (*St initiationTime := time.Unix(cc.ScheduledStop.InitiationTime, 0) st.TimeToStop = time.Until(initiationTime.Add(cc.ScheduledStop.Duration)).String() } + if os.Getenv(constants.MinikubeActiveDockerdEnv) != "" { + st.DockerEnv = "in-use" + } + if os.Getenv(constants.MinikubeActivePodmanEnv) != "" { + st.PodManEnv = "in-use" + } // Early exit for worker nodes if !controlPlane { return st, nil diff --git a/go.sum b/go.sum index a5c8313f3538..ae446773c437 100644 --- a/go.sum +++ b/go.sum @@ -740,6 +740,7 @@ github.com/opencontainers/selinux v1.3.1-0.20190929122143-5215b1806f52/go.mod h1 github.com/otiai10/copy v1.5.0 h1:SoXDGnlTUZoqB/wSuj/Y5L6T5i6iN4YRAcMCd+JnLNU= github.com/otiai10/copy v1.5.0/go.mod h1:XWfuS3CrI0R6IE0FbgHsEazaXO8G0LpMp9o8tos0x4E= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= +github.com/otiai10/curr v1.0.0 h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= github.com/otiai10/mint v1.3.2 h1:VYWnrP5fXmz1MXvjuUvcBrXSjGE6xjON+axB/UrpO3E= diff --git a/site/content/en/docs/commands/status.md b/site/content/en/docs/commands/status.md index e964c2529dd9..992691f07469 100644 --- a/site/content/en/docs/commands/status.md +++ b/site/content/en/docs/commands/status.md @@ -23,7 +23,7 @@ minikube status [flags] ``` -f, --format string Go template format string for the status output. The format for Go templates can be found here: https://golang.org/pkg/text/template/ - For the list accessible variables for the template, see the struct values here: https://godoc.org/k8s.io/minikube/cmd/minikube/cmd#Status (default "{{.Name}}\ntype: Control Plane\nhost: {{.Host}}\nkubelet: {{.Kubelet}}\napiserver: {{.APIServer}}\nkubeconfig: {{.Kubeconfig}}\ntimeToStop: {{.TimeToStop}}\n\n") + For the list accessible variables for the template, see the struct values here: https://godoc.org/k8s.io/minikube/cmd/minikube/cmd#Status (default "{{.Name}}\ntype: Control Plane\nhost: {{.Host}}\nkubelet: {{.Kubelet}}\napiserver: {{.APIServer}}\nkubeconfig: {{.Kubeconfig}}\ntimeToStop: {{.TimeToStop}}\n{{- if .DockerEnv }}\ndocker-env: {{.DockerEnv}}\n{{- end }}\n{{- if .PodManEnv }}\npodman-env: {{.PodManEnv}}\n{{- end }}\n\n") -l, --layout string output layout (EXPERIMENTAL, JSON only): 'nodes' or 'cluster' (default "nodes") -n, --node string The node to check status for. Defaults to control plane. Leave blank with default format for status on all nodes. -o, --output string minikube status --output OUTPUT. json, text (default "text") diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 7a54b317635c..f4d8a7924706 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -271,6 +271,9 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { if !strings.Contains(rr.Output(), "Running") { t.Fatalf("expected status output to include 'Running' after eval docker-env but got: *%s*", rr.Output()) } + if !strings.Contains(rr.Output(), "in-use") { + t.Fatalf("expected status output to include `in-use` after eval docker-env but got *%s*", rr.Output()) + } mctx, cancel = context.WithTimeout(ctx, Seconds(60)) defer cancel()