Skip to content

Commit

Permalink
Support in-cluster configuration (#55)
Browse files Browse the repository at this point in the history
* Support in-cluster configuration

* bump version
  • Loading branch information
jkroepke authored Dec 26, 2023
1 parent bfa4119 commit b4c24ea
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions kubectl-node_shell
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

kubectl=kubectl
version=1.8.0
version=1.8.1
generator=""
node=""
nodefaultctx=0
Expand Down Expand Up @@ -85,9 +85,11 @@ if [ -z "$node" ]; then
exit 1
fi

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

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

0 comments on commit b4c24ea

Please sign in to comment.