From 061e8eeb7b34e31e1100de0eded98fc8789bf891 Mon Sep 17 00:00:00 2001 From: Kavinraja-Ganesan <62742678+Kavinraja-G@users.noreply.github.com> Date: Sun, 18 Feb 2024 17:43:18 +0530 Subject: [PATCH 1/3] feat: Move node exec command to nodegizmo's root --- pkg/cmd/{nodes => }/exec.go | 6 +++--- pkg/cmd/nodepool/nodepool.go | 2 +- pkg/cmd/nodes/capacity.go | 4 ++-- pkg/cmd/nodes/nodes.go | 1 - pkg/cmd/root.go | 3 ++- 5 files changed, 8 insertions(+), 8 deletions(-) rename pkg/cmd/{nodes => }/exec.go (98%) diff --git a/pkg/cmd/nodes/exec.go b/pkg/cmd/exec.go similarity index 98% rename from pkg/cmd/nodes/exec.go rename to pkg/cmd/exec.go index 90714fe..00d6a2f 100644 --- a/pkg/cmd/nodes/exec.go +++ b/pkg/cmd/exec.go @@ -1,4 +1,4 @@ -package nodes +package cmd import ( "context" @@ -31,8 +31,8 @@ var ( // NewCmdNodeExec initialises the 'exec' command func NewCmdNodeExec() *cobra.Command { cmd := &cobra.Command{ - Use: "exec nodeName", - Short: "Spawns a 'nsenter' pod to exec into the provided node", + Use: "exec ", + Short: "Spawns a nsenter pod to exec into the provided node", Aliases: []string{"ex"}, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { diff --git a/pkg/cmd/nodepool/nodepool.go b/pkg/cmd/nodepool/nodepool.go index e6a725c..d9c40ef 100644 --- a/pkg/cmd/nodepool/nodepool.go +++ b/pkg/cmd/nodepool/nodepool.go @@ -16,7 +16,7 @@ var sortByHeader string func NewCmdNodepoolInfo() *cobra.Command { cmd := &cobra.Command{ Use: "nodepool", - Short: "Displays detailed information about Nodepool/Nodegroup", + Short: "Displays detailed information about Nodepool", Aliases: []string{"np", "ng"}, RunE: func(cmd *cobra.Command, args []string) error { return showNodePoolInfo(cmd, args) diff --git a/pkg/cmd/nodes/capacity.go b/pkg/cmd/nodes/capacity.go index 59293bc..1cd2e9c 100644 --- a/pkg/cmd/nodes/capacity.go +++ b/pkg/cmd/nodes/capacity.go @@ -15,7 +15,7 @@ func NewCmdNodeCapacityInfo() *cobra.Command { cmd := &cobra.Command{ Use: "capacity", Short: "Displays Node capacity related information", - Aliases: []string{"capacities", "cp"}, + Aliases: []string{"capacities", "cap"}, RunE: func(cmd *cobra.Command, args []string) error { return showNodeCapacities(cmd, args) }, @@ -28,7 +28,7 @@ func NewCmdNodeCapacityInfo() *cobra.Command { func showNodeCapacities(cmd *cobra.Command, args []string) error { var nodeCapacityInfo []pkg.NodeCapacities labels, _ = cmd.Flags().GetString("labels") - + nodes, err := utils.Cfg.Clientset.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{LabelSelector: labels}) if err != nil { return err diff --git a/pkg/cmd/nodes/nodes.go b/pkg/cmd/nodes/nodes.go index 9dec6cb..233af61 100644 --- a/pkg/cmd/nodes/nodes.go +++ b/pkg/cmd/nodes/nodes.go @@ -44,7 +44,6 @@ func NewCmdNodeInfo() *cobra.Command { // additional sub-commands cmd.AddCommand(NewCmdNodeCapacityInfo()) - cmd.AddCommand(NewCmdNodeExec()) return cmd } diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index 02de2a7..6e87c41 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -21,9 +21,10 @@ func NewCmdRoot() *cobra.Command { } // child commands + cmd.AddCommand(NewCmdDocs(cmd)) + cmd.AddCommand(NewCmdNodeExec()) cmd.AddCommand(nodes.NewCmdNodeInfo()) cmd.AddCommand(nodepool.NewCmdNodepoolInfo()) - cmd.AddCommand(NewCmdDocs(cmd)) return cmd } From ff9d7f4259b5258763471e54e7e96153500208b7 Mon Sep 17 00:00:00 2001 From: Kavinraja-Ganesan <62742678+Kavinraja-G@users.noreply.github.com> Date: Sun, 18 Feb 2024 17:46:05 +0530 Subject: [PATCH 2/3] chore: go docs & readme update --- README.md | 3 ++- docs/nodegizmo.md | 3 ++- docs/nodegizmo_exec.md | 22 ++++++++++++++++++++++ docs/nodegizmo_node.md | 1 - docs/nodegizmo_nodepool.md | 2 +- 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 docs/nodegizmo_exec.md diff --git a/README.md b/README.md index ccd7854..3f5aedc 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,10 @@ Nodepool related information - Node list - Topology info (Region & Zone) - Instance type + - K8sVersion - Nodepool provider (supported: EKS/AKS/GKE/Karpenter)

Nodegizmo node

-##### nodegizmo node exec nodeName +##### nodegizmo exec nodeName Exec into any node by spawning a `nsenter` pod automatically based on the node selection. \ No newline at end of file diff --git a/docs/nodegizmo.md b/docs/nodegizmo.md index 1ca7349..7fbfada 100644 --- a/docs/nodegizmo.md +++ b/docs/nodegizmo.md @@ -16,7 +16,8 @@ nodegizmo [flags] * [nodegizmo completion](nodegizmo_completion.md) - Generate the autocompletion script for the specified shell * [nodegizmo docs](nodegizmo_docs.md) - Generates Markdown docs for nodegizmo in the current working directory +* [nodegizmo exec](nodegizmo_exec.md) - Spawns a nsenter pod to exec into the provided node * [nodegizmo node](nodegizmo_node.md) - Displays generic node related information in the cluster -* [nodegizmo nodepool](nodegizmo_nodepool.md) - Displays detailed information about Nodepool/Nodegroup +* [nodegizmo nodepool](nodegizmo_nodepool.md) - Displays detailed information about Nodepool ###### Auto generated by spf13/cobra on 18-Feb-2024 diff --git a/docs/nodegizmo_exec.md b/docs/nodegizmo_exec.md new file mode 100644 index 0000000..4f72ddf --- /dev/null +++ b/docs/nodegizmo_exec.md @@ -0,0 +1,22 @@ +## nodegizmo exec + +Spawns a nsenter pod to exec into the provided node + +``` +nodegizmo exec [flags] +``` + +### Options + +``` + -h, --help help for exec + -i, --image string Image used by nsenter pod (default "docker.io/alpine:3.18") + -n, --namespace string Namespace where nsenter pod to be created (default "kube-system") + -t, --ttl string Time to live (seconds) for the exec container. Defaults to 3600s (default "3600") +``` + +### SEE ALSO + +* [nodegizmo](nodegizmo.md) - Nodegizmo - A CLI utility for your Kubernetes nodes + +###### Auto generated by spf13/cobra on 18-Feb-2024 diff --git a/docs/nodegizmo_node.md b/docs/nodegizmo_node.md index edcf1b6..fdb3963 100644 --- a/docs/nodegizmo_node.md +++ b/docs/nodegizmo_node.md @@ -21,6 +21,5 @@ nodegizmo node [flags] * [nodegizmo](nodegizmo.md) - Nodegizmo - A CLI utility for your Kubernetes nodes * [nodegizmo node capacity](nodegizmo_node_capacity.md) - Displays Node capacity related information -* [nodegizmo node exec](nodegizmo_node_exec.md) - Spawns a 'nsenter' pod to exec into the provided node ###### Auto generated by spf13/cobra on 18-Feb-2024 diff --git a/docs/nodegizmo_nodepool.md b/docs/nodegizmo_nodepool.md index 848cd2b..944af46 100644 --- a/docs/nodegizmo_nodepool.md +++ b/docs/nodegizmo_nodepool.md @@ -1,6 +1,6 @@ ## nodegizmo nodepool -Displays detailed information about Nodepool/Nodegroup +Displays detailed information about Nodepool ``` nodegizmo nodepool [flags] From 61539630f81d7b89ed1e886ec90b6cca1148a243 Mon Sep 17 00:00:00 2001 From: Kavinraja-Ganesan <62742678+Kavinraja-G@users.noreply.github.com> Date: Sun, 18 Feb 2024 17:47:51 +0530 Subject: [PATCH 3/3] remove nodegizmo node exec readme --- docs/nodegizmo_node_exec.md | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 docs/nodegizmo_node_exec.md diff --git a/docs/nodegizmo_node_exec.md b/docs/nodegizmo_node_exec.md deleted file mode 100644 index 4c7b3db..0000000 --- a/docs/nodegizmo_node_exec.md +++ /dev/null @@ -1,29 +0,0 @@ -## nodegizmo node exec - -Spawns a 'nsenter' pod to exec into the provided node - -``` -nodegizmo node exec nodeName [flags] -``` - -### Options - -``` - -h, --help help for exec - -i, --image string Image used by nsenter pod (default "docker.io/alpine:3.18") - -n, --namespace string Namespace where nsenter pod to be created (default "kube-system") - -t, --ttl string Time to live (seconds) for the exec container. Defaults to 3600s (default "3600") -``` - -### Options inherited from parent commands - -``` - -l, --labels string Filter based on node labels - --sort-by string Sorts output using a valid Column name. Defaults to 'name' if the column name is not valid (default "name") -``` - -### SEE ALSO - -* [nodegizmo node](nodegizmo_node.md) - Displays generic node related information in the cluster - -###### Auto generated by spf13/cobra on 18-Feb-2024