Skip to content

Commit 257d77a

Browse files
committed
manage current context with check-k8s
1 parent c8d08a5 commit 257d77a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/scripts/check-k8s.sh

+6
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ checkClusterResources() {
6060
#--- Check k8s cluster status
6161
#===================================================================================
6262
unset https_proxy http_proxy no_proxy
63+
current_context="$(kubectx -c 2> /dev/null)"
6364
export KUBECONFIG="${HOME}/.kube/config"
6465
contexts="$(kubectl config view -o json | jq -r ".contexts[].name")"
6566
display_contexts="$(echo "${contexts}" | sort | pr -3t -W 130)"
@@ -83,3 +84,8 @@ if [ "${context}" = "" ] ; then
8384
else
8485
checkClusterResources "${context}"
8586
fi
87+
88+
#--- Set inital context
89+
if [ "${current_context}" != "" ] ; then
90+
kubectx ${current_context} > /dev/null 2>&1
91+
fi

0 commit comments

Comments
 (0)