Last active
June 2, 2022 11:41
-
-
Save mesuutt/b3a293decb85416cd770fbea27a6fc17 to your computer and use it in GitHub Desktop.
rename kubeconfig files with cluster name
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
#!/bin/bash | |
# alias kctx="source ~/.bin/kctx.sh" | |
CONF_DIR=~/.kube/config.d | |
file=$(ls -1 $CONF_DIR | fzf) | |
echo "$file" | |
if [[ ! "$file" == "null" ]]; then | |
export KUBECONFIG="$CONF_DIR/$file" | |
fi |
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
#!/bin/bash | |
CONF_DIR=~/.kube/config.d | |
for f in $CONF_DIR/*.yml; do | |
name=$(cat $f | yq -r '.clusters[0].name') | |
if [[ ! "$name" == "null" ]]; then | |
echo "$f === $name" | |
mv $f "$CONF_DIR/$name.yml" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment