Skip to content
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

feat: Move node exec command to nodegizmo's root #32

Merged
merged 3 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ Nodepool related information
- Node list
- Topology info (Region & Zone)
- Instance type
- K8sVersion
- Nodepool provider (supported: EKS/AKS/GKE/Karpenter)
<p align="center"><img src="/assets/nodegizmo-nodepool.png" alt="Nodegizmo node "/></p>

##### nodegizmo node exec nodeName
##### nodegizmo exec nodeName

Exec into any node by spawning a `nsenter` pod automatically based on the node selection.
3 changes: 2 additions & 1 deletion docs/nodegizmo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 22 additions & 0 deletions docs/nodegizmo_exec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## nodegizmo exec

Spawns a nsenter pod to exec into the provided node

```
nodegizmo exec <node-name> [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
1 change: 0 additions & 1 deletion docs/nodegizmo_node.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 0 additions & 29 deletions docs/nodegizmo_node_exec.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/nodegizmo_nodepool.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## nodegizmo nodepool

Displays detailed information about Nodepool/Nodegroup
Displays detailed information about Nodepool

```
nodegizmo nodepool [flags]
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/nodes/exec.go → pkg/cmd/exec.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nodes
package cmd

import (
"context"
Expand Down Expand Up @@ -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 <node-name>",
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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/nodepool/nodepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/nodes/capacity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion pkg/cmd/nodes/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func NewCmdNodeInfo() *cobra.Command {

// additional sub-commands
cmd.AddCommand(NewCmdNodeCapacityInfo())
cmd.AddCommand(NewCmdNodeExec())

return cmd
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading