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 --node option for command ip and ssh-key #9873

Merged
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
18 changes: 15 additions & 3 deletions cmd/minikube/cmd/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,29 @@ package cmd

import (
"github.com/spf13/cobra"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/mustload"
"k8s.io/minikube/pkg/minikube/node"
"k8s.io/minikube/pkg/minikube/out"
"k8s.io/minikube/pkg/minikube/reason"
)

// ipCmd represents the ip command
var ipCmd = &cobra.Command{
Use: "ip",
Short: "Retrieves the IP address of the running cluster",
Long: `Retrieves the IP address of the running cluster, and writes it to STDOUT.`,
Short: "Retrieves the IP address of the specified node",
Long: `Retrieves the IP address of the specified node, and writes it to STDOUT.`,
Run: func(cmd *cobra.Command, args []string) {
co := mustload.Running(ClusterFlagValue())
out.Ln(co.CP.IP.String())
n, _, err := node.Retrieve(*co.Config, nodeName)
if err != nil {
exit.Error(reason.GuestNodeRetrieve, "retrieving node", err)
}

out.Ln(n.IP)
},
}

func init() {
ipCmd.Flags().StringVarP(&nodeName, "node", "n", "", "The node to get IP. Defaults to the primary control plane.")
}
19 changes: 16 additions & 3 deletions cmd/minikube/cmd/ssh-key.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,31 @@ import (
"path/filepath"

"github.com/spf13/cobra"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/minikube/mustload"
"k8s.io/minikube/pkg/minikube/node"
"k8s.io/minikube/pkg/minikube/out"
"k8s.io/minikube/pkg/minikube/reason"
)

// sshKeyCmd represents the sshKey command
var sshKeyCmd = &cobra.Command{
Use: "ssh-key",
Short: "Retrieve the ssh identity key path of the specified cluster",
Long: "Retrieve the ssh identity key path of the specified cluster.",
Short: "Retrieve the ssh identity key path of the specified node",
Long: "Retrieve the ssh identity key path of the specified node, and writes it to STDOUT.",
Run: func(cmd *cobra.Command, args []string) {
_, cc := mustload.Partial(ClusterFlagValue())
out.Ln(filepath.Join(localpath.MiniPath(), "machines", cc.Name, "id_rsa"))
n, _, err := node.Retrieve(*cc, nodeName)
if err != nil {
exit.Error(reason.GuestNodeRetrieve, "retrieving node", err)
}

out.Ln(filepath.Join(localpath.MiniPath(), "machines", driver.MachineName(*cc, *n), "id_rsa"))
},
}

func init() {
sshKeyCmd.Flags().StringVarP(&nodeName, "node", "n", "", "The node to get ssh-key path. Defaults to the primary control plane.")
}
12 changes: 9 additions & 3 deletions site/content/en/docs/commands/ip.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
---
title: "ip"
description: >
Retrieves the IP address of the running cluster
Retrieves the IP address of the specified node
---


## minikube ip

Retrieves the IP address of the running cluster
Retrieves the IP address of the specified node

### Synopsis

Retrieves the IP address of the running cluster, and writes it to STDOUT.
Retrieves the IP address of the specified node, and writes it to STDOUT.

```shell
minikube ip [flags]
```

### Options

```
-n, --node string The node to get IP. Defaults to the primary control plane.
```

### Options inherited from parent commands

```
Expand Down
12 changes: 9 additions & 3 deletions site/content/en/docs/commands/ssh-key.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
---
title: "ssh-key"
description: >
Retrieve the ssh identity key path of the specified cluster
Retrieve the ssh identity key path of the specified node
---


## minikube ssh-key

Retrieve the ssh identity key path of the specified cluster
Retrieve the ssh identity key path of the specified node

### Synopsis

Retrieve the ssh identity key path of the specified cluster.
Retrieve the ssh identity key path of the specified node, and writes it to STDOUT.

```shell
minikube ssh-key [flags]
```

### Options

```
-n, --node string The node to get ssh-key path. Defaults to the primary control plane.
```

### Options inherited from parent commands

```
Expand Down