-
-
Notifications
You must be signed in to change notification settings - Fork 473
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-label flag for node create command (#584, @developer-guy, @ejose, @dentrax) #584
Conversation
… command as a --node-label flag Signed-off-by: Batuhan Apaydın <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor comment regarding the naming of the new field... apart from that LGTM! :)
Thank you for your efforts here! :) |
@ejose19 @iwilltry42, we updated the variable and flag name, FYI. |
diff --git a/cmd/node/nodeCreate.go b/cmd/node/nodeCreate.go
index b334b479..f817d211 100644
--- a/cmd/node/nodeCreate.go
+++ b/cmd/node/nodeCreate.go
@@ -74,7 +74,7 @@ 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\", \"foo=bar:NoExecute\"")
+ cmd.Flags().StringSliceP("k3s-node-label", "", []string{}, "Specify k3s node labels in format \"foo=bar\", \"foo=bar:NoExecute\"")
// done
return cmd
@@ -127,17 +127,17 @@ func parseCreateNodeCmd(cmd *cobra.Command, args []string) ([]*k3d.Node, *k3d.Cl
log.Errorf("Provided memory limit value is invalid")
}
- labels, err := cmd.Flags().GetStringSlice("node-label")
+ k3sNodeLabelsFlags, err := cmd.Flags().GetStringSlice("k3s-node-label")
if err != nil {
- log.Errorln("No node-label specified")
+ log.Errorln("No k3s-node-label specified")
log.Fatalln(err)
}
- k3sNodeLabels := make(map[string]string, len(labels))
- for _, label := range labels {
+ k3sNodeLabels := make(map[string]string, len(k3sNodeLabelsFlags))
+ for _, label := range k3sNodeLabelsFlags {
labelSplitted := strings.Split(label, "=")
if len(labelSplitted) != 2 {
- log.Fatalf("unknown label format format: %s, use format \"foo=bar\"", label)
+ log.Fatalf("unknown k3s-node-label format format: %s, use format \"foo=bar\"", label)
}
k3sNodeLabels[labelSplitted[0]] = labelSplitted[1]
}
@@ -153,8 +153,8 @@ func parseCreateNodeCmd(cmd *cobra.Command, args []string) ([]*k3d.Node, *k3d.Cl
k3d.LabelRole: roleStr,
},
K3sNodeLabels: k3sNodeLabels,
- Restart: true,
- Memory: memory,
+ Restart: true,
+ Memory: memory,
}
nodes = append(nodes, node)
}
diff --git a/pkg/types/types.go b/pkg/types/types.go
index 642038b3..e916a804 100644
--- a/pkg/types/types.go
+++ b/pkg/types/types.go
@@ -330,26 +330,26 @@ 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
+ 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
+ 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 Here's a diff with some format & naming adjusts, feel free to add it to your PR. |
Signed-off-by: Dentrax <[email protected]> Signed-off-by: Batuhan Apaydın <[email protected]>
thank you 👍 |
Looks good to me so far, thank you! |
Author: Batuhan Apaydın <[email protected]> Date: Mon May 10 17:58:01 2021 +0300 add --node-label flag for node create command (#584, @developer-guy, @EJose, @Dentrax)
Author: iwilltry42 <[email protected]> Date: Fri May 14 13:53:47 2021 +0200 Revert "add --node-label flag for node create command (#584, @developer-guy, @EJose, @Dentrax)" This reverts commit 5fe8a3c.
…developer-guy, @EJose, @Dentrax)"' This reverts commit 7087264.
…developer-guy, @EJose, @Dentrax)"' This reverts commit 7087264.
…developer-guy, @EJose, @Dentrax)"' This reverts commit 7087264.
…developer-guy, @EJose, @Dentrax)"' This reverts commit 7087264.
…developer-guy, @EJose, @Dentrax)"' This reverts commit 7087264.
Signed-off-by: Batuhan Apaydın [email protected]
This PR should fix #578.
What
This PR is going to provide users to be able to add labels to the Kubernetes nodes.
Why
The k3s tool has a flag called "--node-label", we can use this flag in order to add labels to nodes, k3d has no support for that, so, we can add it.
Implications