Skip to content

Commit

Permalink
feat: Image and namespace flags nsenter exec pods (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kavinraja-G authored Sep 23, 2023
1 parent c54584f commit f986175
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ Nodepool related information
<p align="center"><img src="/assets/nodegizmo-nodepool.png" alt="Nodegizmo node "/></p>

##### nodegizmo node exec nodeName
> Note: This feature is still in beta

Exec into any node by spawning a `nsenter` pod automatically based on the node selection.
10 changes: 8 additions & 2 deletions pkg/cmd/nodes/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (
)

var (
nodeshellPodNamespace = "default"
nodeshellPodNamespace string
nodeshellPodImage string
nodeshellPodNamePrefix = "nodeshell-"
podSCPrivileged = true
podTerminationGracePeriodSeconds = int64(0)
Expand Down Expand Up @@ -55,6 +56,11 @@ func NewCmdNodeExec() *cobra.Command {
return cleanUpNodeshellPods(cmd, args[0])
},
}

// additional local flags
cmd.Flags().StringVarP(&nodeshellPodNamespace, "namespace", "n", "kube-system", "Namespace where nsenter pod to be created")
cmd.Flags().StringVarP(&nodeshellPodImage, "image", "i", "docker.io/alpine:3.18", "Image used by nsenter pod")

return cmd
}

Expand Down Expand Up @@ -92,7 +98,7 @@ func createExecPodInTargetedNode(nodeName string) error {
Containers: []corev1.Container{
{
Name: "nodeshell",
Image: "docker.io/alpine:3.18",
Image: nodeshellPodImage,
Command: []string{"nsenter"},
Args: []string{"-t", "1", "-m", "-u", "-i", "-n", "sleep", "14000"},
SecurityContext: &corev1.SecurityContext{
Expand Down

0 comments on commit f986175

Please sign in to comment.