Skip to content

Instantly share code, notes, and snippets.

@f9n
Last active August 10, 2021 20:24
Show Gist options
  • Save f9n/69793910e2256fbaa997c58f0bf2d0ad to your computer and use it in GitHub Desktop.
Save f9n/69793910e2256fbaa997c58f0bf2d0ad to your computer and use it in GitHub Desktop.
Kube Cluster Merger
#!/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