Last active
August 10, 2021 20:24
-
-
Save f9n/69793910e2256fbaa997c58f0bf2d0ad to your computer and use it in GitHub Desktop.
Kube Cluster Merger
This file contains hidden or 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
#!/usr/bin/env bash | |
DIRPATH=$1 | |
OUTFILE=$2 | |
if [ -z "$1" ]; then | |
DIRPATH="$HOME/.kube/clusters" | |
fi | |
if [ -z "$2" ]; then | |
OUTFILE="$HOME/.kube/config" | |
fi | |
echo $DIRPATH | |
echo $OUTFILE | |
_KUBECONFIG="" | |
for file_cluster in $(ls $DIRPATH); do | |
if [ -z "$_KUBECONFIG" ]; then | |
_KUBECONFIG=$DIRPATH/$file_cluster | |
else | |
_KUBECONFIG=$_KUBECONFIG:$DIRPATH/$file_cluster | |
fi | |
done | |
export KUBECONFIG=$_KUBECONFIG | |
echo $KUBECONFIG | |
kubectl config view --merge --flatten > $OUTFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment