node add works

parent a539efc4
...@@ -24,6 +24,7 @@ import ( ...@@ -24,6 +24,7 @@ import (
"k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/node" "k8s.io/minikube/pkg/minikube/node"
"k8s.io/minikube/pkg/minikube/out"
) )
var nodeAddCmd = &cobra.Command{ var nodeAddCmd = &cobra.Command{
...@@ -40,8 +41,10 @@ var nodeAddCmd = &cobra.Command{ ...@@ -40,8 +41,10 @@ var nodeAddCmd = &cobra.Command{
if name == "" { if name == "" {
name = profile + strconv.Itoa(len(mc.Nodes)+1) name = profile + strconv.Itoa(len(mc.Nodes)+1)
} }
out.T(out.SuccessType, "Adding node {{.name}} to cluster {{.profile}}", out.V{"name": name, "profile": profile})
cp := viper.GetBool("control-plane") cp := viper.GetBool("control-plane")
err = node.Add(mc, name, cp, "", profile) worker := viper.GetBool("worker")
err = node.Add(mc, name, cp, worker, "", profile)
if err != nil { if err != nil {
exit.WithError("Error adding node to cluster", err) exit.WithError("Error adding node to cluster", err)
} }
...@@ -51,5 +54,6 @@ var nodeAddCmd = &cobra.Command{ ...@@ -51,5 +54,6 @@ var nodeAddCmd = &cobra.Command{
func init() { func init() {
nodeAddCmd.Flags().String("name", "", "The name of the node to add.") nodeAddCmd.Flags().String("name", "", "The name of the node to add.")
nodeAddCmd.Flags().Bool("control-plane", false, "If true, the node added will also be a control plane in addition to a worker.") nodeAddCmd.Flags().Bool("control-plane", false, "If true, the node added will also be a control plane in addition to a worker.")
nodeAddCmd.Flags().Bool("worker", true, "If true, the added node will be marked for work. Defaults to true.")
NodeCmd.AddCommand(nodeAddCmd) NodeCmd.AddCommand(nodeAddCmd)
} }
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/exit"
) )
// NodeCmd represents the set of node subcommands
var NodeCmd = &cobra.Command{ var NodeCmd = &cobra.Command{
Use: "node", Use: "node",
Short: "Node operations", Short: "Node operations",
......
...@@ -31,6 +31,7 @@ import ( ...@@ -31,6 +31,7 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
"k8s.io/kubectl/pkg/util/templates" "k8s.io/kubectl/pkg/util/templates"
configCmd "k8s.io/minikube/cmd/minikube/cmd/config" configCmd "k8s.io/minikube/cmd/minikube/cmd/config"
"k8s.io/minikube/cmd/minikube/cmd/node"
"k8s.io/minikube/pkg/minikube/bootstrapper" "k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm" "k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm"
"k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/config"
...@@ -205,6 +206,7 @@ func init() { ...@@ -205,6 +206,7 @@ func init() {
mountCmd, mountCmd,
sshCmd, sshCmd,
kubectlCmd, kubectlCmd,
node.NodeCmd,
}, },
}, },
{ {
......
...@@ -25,7 +25,7 @@ import ( ...@@ -25,7 +25,7 @@ import (
) )
// Add adds a new node config to an existing cluster. // Add adds a new node config to an existing cluster.
func Add(cc *config.MachineConfig, name string, controlPlane bool, k8sVersion string, profileName string) error { func Add(cc *config.MachineConfig, name string, controlPlane bool, worker bool, k8sVersion string, profileName string) error {
n := config.Node{ n := config.Node{
Name: name, Name: name,
Worker: true, Worker: true,
...@@ -35,8 +35,14 @@ func Add(cc *config.MachineConfig, name string, controlPlane bool, k8sVersion st ...@@ -35,8 +35,14 @@ func Add(cc *config.MachineConfig, name string, controlPlane bool, k8sVersion st
n.ControlPlane = true n.ControlPlane = true
} }
if worker {
n.Worker = true
}
if k8sVersion != "" { if k8sVersion != "" {
n.KubernetesVersion = k8sVersion n.KubernetesVersion = k8sVersion
} else {
n.KubernetesVersion = cc.KubernetesConfig.KubernetesVersion
} }
cc.Nodes = append(cc.Nodes, n) cc.Nodes = append(cc.Nodes, n)
...@@ -78,5 +84,6 @@ func Stop(cc *config.MachineConfig, name string) error { ...@@ -78,5 +84,6 @@ func Stop(cc *config.MachineConfig, name string) error {
// Start spins up a guest and starts the kubernetes node. // Start spins up a guest and starts the kubernetes node.
func Start(cc *config.MachineConfig, name string) error { func Start(cc *config.MachineConfig, name string) error {
// Throw all the slop from cmd.start in here // Throw all the slop from cmd.start in here
// Add the node if it doesn't already exist
return nil return nil
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment