From 70872648b345af93380653a357cc5c215614fb7c Mon Sep 17 00:00:00 2001 From: iwilltry42 Date: Fri, 14 May 2021 13:53:47 +0200 Subject: [PATCH] Revert "add --node-label flag for node create command (#584, @developer-guy, @ejose, @dentrax)" This reverts commit 5fe8a3c6c741f1720796c11b09efec26107cb72d. --- cmd/node/nodeCreate.go | 23 ++--------------------- pkg/client/node.go | 5 ----- pkg/types/types.go | 39 +++++++++++++++++++-------------------- 3 files changed, 21 insertions(+), 46 deletions(-) diff --git a/cmd/node/nodeCreate.go b/cmd/node/nodeCreate.go index e30aac78..c2d86281 100644 --- a/cmd/node/nodeCreate.go +++ b/cmd/node/nodeCreate.go @@ -23,7 +23,6 @@ package node import ( "fmt" - "strings" "time" "github.com/spf13/cobra" @@ -74,8 +73,6 @@ func NewCmdNodeCreate() *cobra.Command { cmd.Flags().BoolVar(&createNodeOpts.Wait, "wait", false, "Wait for the node(s) to be ready before returning.") cmd.Flags().DurationVar(&createNodeOpts.Timeout, "timeout", 0*time.Second, "Maximum waiting time for '--wait' before canceling/returning.") - cmd.Flags().StringSliceP("k3s-node-label", "", []string{}, "Specify k3s node labels in format \"foo=bar\"") - // done return cmd } @@ -127,21 +124,6 @@ func parseCreateNodeCmd(cmd *cobra.Command, args []string) ([]*k3d.Node, *k3d.Cl log.Errorf("Provided memory limit value is invalid") } - k3sNodeLabelsFlag, err := cmd.Flags().GetStringSlice("k3s-node-label") - if err != nil { - log.Errorln("No node-label specified") - log.Fatalln(err) - } - - k3sNodeLabels := make(map[string]string, len(k3sNodeLabelsFlag)) - for _, label := range k3sNodeLabelsFlag { - labelSplitted := strings.Split(label, "=") - if len(labelSplitted) != 2 { - log.Fatalf("unknown label format format: %s, use format \"foo=bar\"", label) - } - k3sNodeLabels[labelSplitted[0]] = labelSplitted[1] - } - // generate list of nodes nodes := []*k3d.Node{} for i := 0; i < replicas; i++ { @@ -152,9 +134,8 @@ func parseCreateNodeCmd(cmd *cobra.Command, args []string) ([]*k3d.Node, *k3d.Cl Labels: map[string]string{ k3d.LabelRole: roleStr, }, - K3sNodeLabels: k3sNodeLabels, - Restart: true, - Memory: memory, + Restart: true, + Memory: memory, } nodes = append(nodes, node) } diff --git a/pkg/client/node.go b/pkg/client/node.go index 94a800b7..3c00ddcc 100644 --- a/pkg/client/node.go +++ b/pkg/client/node.go @@ -481,11 +481,6 @@ func patchAgentSpec(node *k3d.Node) error { if node.Cmd == nil { node.Cmd = []string{"agent"} } - - for k, v := range node.K3sNodeLabels { - node.Args = append(node.Args, "--node-label", fmt.Sprintf("%s=%s", k, v)) - } - return nil } diff --git a/pkg/types/types.go b/pkg/types/types.go index e916a804..5745ce1c 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -330,26 +330,25 @@ type NodeIP struct { // Node describes a k3d node type Node struct { - Name string `yaml:"name" json:"name,omitempty"` - Role Role `yaml:"role" json:"role,omitempty"` - Image string `yaml:"image" json:"image,omitempty"` - Volumes []string `yaml:"volumes" json:"volumes,omitempty"` - Env []string `yaml:"env" json:"env,omitempty"` - Cmd []string // filled automatically based on role - Args []string `yaml:"extraArgs" json:"extraArgs,omitempty"` - Ports nat.PortMap `yaml:"portMappings" json:"portMappings,omitempty"` - Restart bool `yaml:"restart" json:"restart,omitempty"` - Created string `yaml:"created" json:"created,omitempty"` - Labels map[string]string // filled automatically - K3sNodeLabels map[string]string `yaml:"k3sNodeLabels" json:"k3sNodeLabels,omitempty"` - Networks []string // filled automatically - ExtraHosts []string // filled automatically - ServerOpts ServerOpts `yaml:"serverOpts" json:"serverOpts,omitempty"` - AgentOpts AgentOpts `yaml:"agentOpts" json:"agentOpts,omitempty"` - GPURequest string // filled automatically - Memory string // filled automatically - State NodeState // filled automatically - IP NodeIP // filled automatically + Name string `yaml:"name" json:"name,omitempty"` + Role Role `yaml:"role" json:"role,omitempty"` + Image string `yaml:"image" json:"image,omitempty"` + Volumes []string `yaml:"volumes" json:"volumes,omitempty"` + Env []string `yaml:"env" json:"env,omitempty"` + Cmd []string // filled automatically based on role + Args []string `yaml:"extraArgs" json:"extraArgs,omitempty"` + Ports nat.PortMap `yaml:"portMappings" json:"portMappings,omitempty"` + Restart bool `yaml:"restart" json:"restart,omitempty"` + Created string `yaml:"created" json:"created,omitempty"` + Labels map[string]string // filled automatically + Networks []string // filled automatically + ExtraHosts []string // filled automatically + ServerOpts ServerOpts `yaml:"serverOpts" json:"serverOpts,omitempty"` + AgentOpts AgentOpts `yaml:"agentOpts" json:"agentOpts,omitempty"` + GPURequest string // filled automatically + Memory string // filled automatically + State NodeState // filled automatically + IP NodeIP // filled automatically } // ServerOpts describes some additional server role specific opts