Skip to content

Commit b4c24ea

Browse files
authored
Support in-cluster configuration (#55)
* Support in-cluster configuration * bump version
1 parent bfa4119 commit b4c24ea

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

kubectl-node_shell

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
kubectl=kubectl
5-
version=1.8.0
5+
version=1.8.1
66
generator=""
77
node=""
88
nodefaultctx=0
@@ -85,9 +85,11 @@ if [ -z "$node" ]; then
8585
exit 1
8686
fi
8787

88-
# Set the default context and namespace to avoid situations where the user switch them during the build process
89-
[ "$nodefaultctx" = 1 ] || kubectl="$kubectl --context=$(${kubectl} config current-context)"
90-
[ "$nodefaultns" = 1 ] || kubectl="$kubectl --namespace=$(${kubectl} config view --minify --output 'jsonpath={.contexts..namespace}')"
88+
if [ -z "$KUBERNETES_PORT" ]; then
89+
# Set the default context and namespace to avoid situations where the user switch them during the build process
90+
[ "$nodefaultctx" = 1 ] || kubectl="$kubectl --context=$(${kubectl} config current-context)"
91+
[ "$nodefaultns" = 1 ] || kubectl="$kubectl --namespace=$(${kubectl} config view --minify --output 'jsonpath={.contexts..namespace}')"
92+
fi
9193

9294
# Check the node and retrieve the node OS label
9395
os="$($kubectl get node $node -o jsonpath="{.metadata.labels.kubernetes\.io/os}" || exit 1)"

0 commit comments

Comments
 (0)