From f986175a635599b95fc355928f6749dc02c5faa5 Mon Sep 17 00:00:00 2001 From: Kavinraja Ganesan <62742678+Kavinraja-G@users.noreply.github.com> Date: Sat, 23 Sep 2023 20:48:07 +0530 Subject: [PATCH] feat: Image and namespace flags nsenter exec pods (#17) --- README.md | 1 - pkg/cmd/nodes/exec.go | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e056a24..225fc2c 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,5 @@ Nodepool related information
##### 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. \ No newline at end of file diff --git a/pkg/cmd/nodes/exec.go b/pkg/cmd/nodes/exec.go index 5a3a785..dc641b5 100644 --- a/pkg/cmd/nodes/exec.go +++ b/pkg/cmd/nodes/exec.go @@ -21,7 +21,8 @@ import ( ) var ( - nodeshellPodNamespace = "default" + nodeshellPodNamespace string + nodeshellPodImage string nodeshellPodNamePrefix = "nodeshell-" podSCPrivileged = true podTerminationGracePeriodSeconds = int64(0) @@ -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 } @@ -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{