From 054fd86fa6fb3c4a2f8ec88ce1a9fced6cd95a60 Mon Sep 17 00:00:00 2001 From: Hari Sekhon Date: Thu, 5 Nov 2020 11:26:21 +0000 Subject: [PATCH] updated kubernetes_info.sh --- kubernetes_info.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kubernetes_info.sh b/kubernetes_info.sh index 5038e0b9..0593e289 100755 --- a/kubernetes_info.sh +++ b/kubernetes_info.sh @@ -49,6 +49,12 @@ usage_args="[]" help_usage "$@" +# XXX: set the kubectl context for the lifetime of this script to avoid a concurrency race condition changing the cluster we're speaking to half way through - this way the context reported at the beginning is the one we're using all the way through for consistent results +kubeconfig="/tmp/.kube/config.${EUID:-$UID}.$$" +mkdir -pv "$(dirname "$kubeconfig")" +cp -f "${KUBECONFIG:-$HOME/.kube/config}" "$kubeconfig" +export KUBECONFIG="$kubeconfig" + current_context="$(kubectl config current-context)" if [ $# -gt 0 ]; then @@ -62,6 +68,8 @@ if [ $# -gt 0 ]; then echo fi +echo "kubectl context: $(kubectl config current-context)" +echo kubectl cluster-info echo kubectl get componentstatuses