Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add list option for "minikube node" command #7851

Merged
merged 5 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ var nodeCmd = &cobra.Command{
Short: "Node operations",
Long: "Operations on nodes",
Run: func(cmd *cobra.Command, args []string) {
exit.UsageT("Usage: minikube node [add|start|stop|delete]")
exit.UsageT("Usage: minikube node [add|start|stop|delete|list]")
},
}
58 changes: 58 additions & 0 deletions cmd/minikube/cmd/node_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright 2020 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package cmd

import (
"fmt"
"os"

"github.com/golang/glog"
"github.com/spf13/cobra"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/mustload"
)

var nodeListCmd = &cobra.Command{
Use: "list",
Short: "List nodes.",
Long: "List existing Minikube nodes.",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 0 {
exit.UsageT("Usage: minikube node list")
}

cname := ClusterFlagValue()
_, cc := mustload.Partial(cname)

if len(cc.Nodes) < 1 {
glog.Warningf("Did not found any Minikube node.")
} else {
glog.Infof("%v", cc.Nodes)
}

for _, n := range cc.Nodes {
machineName := driver.MachineName(*cc, n)
fmt.Printf("%s\t%s\n", machineName, n.IP)
}
os.Exit(0)
},
}

func init() {
nodeCmd.AddCommand(nodeListCmd)
}
32 changes: 32 additions & 0 deletions site/content/en/docs/commands/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,38 @@ minikube node help [command] [flags]
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging
```

## minikube node list

List nodes.

### Synopsis

List existing Minikube nodes.

```
minikube node list [flags]
```

### Options

```
-h, --help help for list
```

### Options inherited from parent commands

```
--alsologtostderr log to standard error as well as files
-b, --bootstrapper string The name of the cluster bootstrapper that will set up the kubernetes cluster. (default "kubeadm")
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory
--logtostderr log to standard error instead of files
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
-v, --v Level log level for V logs
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging
```

## minikube node start

Starts a node.
Expand Down