@@ -15,6 +15,11 @@ x_mode=0
1515labels=" ${KUBECTL_NODE_SHELL_LABELS} "
1616pod_running_timeout=" ${KUBECTL_NODE_SHELL_POD_RUNNING_TIMEOUT:- 1m} "
1717custom_image=" "
18+ use_ipc=true
19+ use_mount=true
20+ use_pid=true
21+ use_net=true
22+ use_uts=true
1823
1924if [ -t 0 ]; then
2025 tty=true
@@ -71,6 +76,26 @@ while [ $# -gt 0 ]; do
7176 shift
7277 shift
7378 ;;
79+ --no-ipc)
80+ use_ipc=false
81+ shift
82+ ;;
83+ --no-mount)
84+ use_mount=false
85+ shift
86+ ;;
87+ --no-pid)
88+ use_pid=false
89+ shift
90+ ;;
91+ --no-net)
92+ use_net=false
93+ shift
94+ ;;
95+ --no-uts)
96+ use_uts=false
97+ shift
98+ ;;
7499 --)
75100 shift
76101 break
@@ -116,7 +141,24 @@ else # If the OS isn't windows, assume linux
116141 image=" ${custom_image:- ${KUBECTL_NODE_SHELL_IMAGE:- $default_image } } "
117142 name=" nsenter"
118143 pod=" ${name} -$( env LC_ALL=C tr -dc a-z0-9 < /dev/urandom | head -c 6) "
119- cmd_start=' "nsenter", "--target", "1", "--mount", "--uts", "--ipc", "--net", "--pid"'
144+ cmd_start=' "nsenter", "--target", "1"'
145+ # , "--mount", "--uts", "--ipc", "--net", "--pid"
146+ if [ " $use_mount " = true ]; then
147+ cmd_start=" ${cmd_start} , \" --mount\" "
148+ fi
149+ if [ " $use_uts " = true ]; then
150+ cmd_start=" ${cmd_start} , \" --uts\" "
151+ fi
152+ if [ " $use_ipc " = true ]; then
153+ cmd_start=" ${cmd_start} , \" --ipc\" "
154+ fi
155+ if [ " $use_net " = true ]; then
156+ cmd_start=" ${cmd_start} , \" --net\" "
157+ fi
158+ if [ " $use_pid " = true ]; then
159+ cmd_start=" ${cmd_start} , \" --pid\" "
160+ fi
161+
120162 cmd_arg_prefix=' , "--"'
121163 cmd_default=' , "bash", "-l"'
122164 security_context=' {"privileged":true}'
0 commit comments