diff --git a/cmd/minikube/cmd/ip.go b/cmd/minikube/cmd/ip.go index 6a2ca32055a1..3a34fad294d0 100644 --- a/cmd/minikube/cmd/ip.go +++ b/cmd/minikube/cmd/ip.go @@ -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.") +} diff --git a/cmd/minikube/cmd/ssh-key.go b/cmd/minikube/cmd/ssh-key.go index b7a0ddf0de5c..99db155c5e09 100644 --- a/cmd/minikube/cmd/ssh-key.go +++ b/cmd/minikube/cmd/ssh-key.go @@ -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.") +} diff --git a/site/content/en/docs/commands/ip.md b/site/content/en/docs/commands/ip.md index 044e4435d7ac..a460649225eb 100644 --- a/site/content/en/docs/commands/ip.md +++ b/site/content/en/docs/commands/ip.md @@ -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 ``` diff --git a/site/content/en/docs/commands/ssh-key.md b/site/content/en/docs/commands/ssh-key.md index 5abba114ad0d..76687f73770a 100644 --- a/site/content/en/docs/commands/ssh-key.md +++ b/site/content/en/docs/commands/ssh-key.md @@ -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 ```