add docker-env and podman-env to minikube status

Signed-off-by: Tharun <rajendrantharun@live.com>
pull/10872/head
Tharun 2021-03-19 12:51:32 +05:30
parent f29366a596
commit 2779ec021b
3 changed files with 18 additions and 4 deletions

View File

@ -252,7 +252,8 @@ var dockerEnvCmd = &cobra.Command{
sh := shell.EnvConfig{
Shell: shl,
}
cname := ClusterFlagValue()
co := mustload.Running(cname)
if dockerUnset {
if err := dockerUnsetScript(DockerEnvConfig{EnvConfig: sh}, os.Stdout); err != nil {
exit.Error(reason.InternalEnvScript, "Error generating unset output", err)
@ -265,8 +266,6 @@ var dockerEnvCmd = &cobra.Command{
exit.SetShell(true)
}
cname := ClusterFlagValue()
co := mustload.Running(cname)
driverName := co.CP.Host.DriverName
if driverName == driver.None {

View File

@ -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

View File

@ -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")