22set -e
33
44kubectl=kubectl
5- version=1.7 .0
5+ version=1.8 .0
66generator=" "
77node=" "
88nodefaultctx=0
99nodefaultns=0
1010container_cpu=" ${KUBECTL_NODE_SHELL_POD_CPU:- 100m} "
1111container_memory=" ${KUBECTL_NODE_SHELL_POD_MEMORY:- 256Mi} "
12+ volumes=" []"
13+ volume_mounts=" []"
14+ x_mode=0
1215labels=" ${KUBECTL_NODE_SHELL_LABELS} "
1316
1417if [ -t 0 ]; then
@@ -55,6 +58,12 @@ while [ $# -gt 0 ]; do
5558 kubectl=" $kubectl --namespace=${key##* =} "
5659 shift
5760 ;;
61+ -x)
62+ x_mode=1
63+ volumes=' [{"hostPath":{"path":"/","type":""},"name":"host-root"}]'
64+ volume_mounts=' [{"mountPath":"/host","name":"host-root"}]'
65+ shift
66+ ;;
5867 --)
5968 shift
6069 break
106115
107116# Build the container command
108117if [ $# -gt 0 ]; then
109- cmd=" [ $cmd_start $cmd_arg_prefix "
118+ if [ " $x_mode " -eq 1 ]; then
119+ cmd=' ['
120+ else
121+ cmd=" [ $cmd_start $cmd_arg_prefix ,"
122+ fi
123+ c=" "
110124 while [ $# -gt 0 ]; do
111- cmd=" $cmd , \" $( echo " $1 " | \
125+ cmd=" ${ cmd}${c} \" $( echo " $1 " | \
112126 awk ' {gsub(/["\\]/,"\\\\&");gsub(/\x1b/,"\\u001b");printf "%s",last;last=$0"\\n"} END{print $0}' \
113127 ) \" "
128+ c=,
114129 shift
115130 done
116131 cmd=" $cmd ]"
117132else
118- cmd=" [ $cmd_start $cmd_default ]"
133+ if [ " $x_mode " = 1 ]; then
134+ cmd=' null'
135+ else
136+ cmd=" [ $cmd_start $cmd_default ]"
137+ fi
119138fi
120139
121140overrides=" $(
@@ -137,13 +156,15 @@ cat <<EOT
137156 "resources": {
138157 "limits": { "cpu": "${container_cpu} ", "memory": "${container_memory} " },
139158 "requests": { "cpu": "${container_cpu} ", "memory": "${container_memory} " }
140- }
159+ },
160+ "volumeMounts": $volume_mounts
141161 }
142162 ],
143163 "tolerations": [
144164 { "key": "CriticalAddonsOnly", "operator": "Exists" },
145165 { "effect": "NoExecute", "operator": "Exists" }
146- ]
166+ ],
167+ "volumes": $volumes
147168 }
148169}
149170EOT
0 commit comments