Created
March 8, 2023 07:29
-
-
Save quangnhut123/ce9a7eaea16644fd495fe9d2ec63489e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubecontext=$(kubectl config view -o jsonpath='{.contexts[*].name}') | |
oldIFS=$IFS | |
IFS=$' ' | |
choices=( $kubecontext ) | |
IFS=$oldIFS | |
PS3="Please select your kube context: " | |
select answer in "${choices[@]}"; do | |
for item in "${choices[@]}"; do | |
if [[ $item == $answer ]]; then | |
break 2 | |
fi | |
done | |
done | |
kubectl config use-context $answer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment