Skip to content

Commit 5fabc2b

Browse files
authored
Replicate nsenter options to pod spec (#69)
Signed-off-by: Andrei Kvapil <[email protected]>
1 parent c6d37cf commit 5fabc2b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

kubectl-node_shell

+7-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ container_cpu="${KUBECTL_NODE_SHELL_POD_CPU:-100m}"
1111
container_memory="${KUBECTL_NODE_SHELL_POD_MEMORY:-256Mi}"
1212
volumes="[]"
1313
volume_mounts="[]"
14-
x_mode=0
14+
x_mode=false
1515
labels="${KUBECTL_NODE_SHELL_LABELS}"
1616
pod_running_timeout="${KUBECTL_NODE_SHELL_POD_RUNNING_TIMEOUT:-1m}"
1717
image_pull_secret_name="${KUBECTL_NODE_SHELL_IMAGE_PULL_SECRET_NAME}"
@@ -73,7 +73,7 @@ while [ $# -gt 0 ]; do
7373
shift
7474
;;
7575
-x)
76-
x_mode=1
76+
x_mode=true
7777
volumes=$(echo "$volumes" | jq '. += [{"hostPath": {"path": "/", "type": ""}, "name": "host-root"}]')
7878
volume_mounts=$(echo "$volume_mounts" | jq '. += [{"mountPath":"/host","name":"host-root"}]')
7979
shift
@@ -173,7 +173,7 @@ fi
173173

174174
# Build the container command
175175
if [ $# -gt 0 ]; then
176-
if [ "$x_mode" -eq 1 ]; then
176+
if [ "$x_mode" = true ]; then
177177
cmd='['
178178
else
179179
cmd="[ $cmd_start $cmd_arg_prefix,"
@@ -188,7 +188,7 @@ if [ $# -gt 0 ]; then
188188
done
189189
cmd="$cmd ]"
190190
else
191-
if [ "$x_mode" = 1 ]; then
191+
if [ "$x_mode" = true ]; then
192192
cmd='null'
193193
else
194194
cmd="[ $cmd_start $cmd_default ]"
@@ -213,8 +213,9 @@ cat <<EOT
213213
{
214214
"spec": {
215215
"nodeName": "$node",
216-
"hostPID": true,
217-
"hostNetwork": true,
216+
"hostPID": $use_pid,
217+
"hostIPC": $use_ipc,
218+
"hostNetwork": $use_net,
218219
"imagePullSecrets": $image_pull_secrets,
219220
"containers": [
220221
{

0 commit comments

Comments
 (0)