diff --git a/.bin/kube-merge b/.bin/kube-merge new file mode 100755 index 0000000..3dfb476 --- /dev/null +++ b/.bin/kube-merge @@ -0,0 +1,23 @@ +#!/bin/sh + +# Create backup of previous kubeconfig +cp ~/.kube/config ~/.kube/config.bak + +KUBECONFIG="" + +for config in ~/.kube/config-* +do + profile=$(echo $config | cut -d '-' -f 2) + + # De-duplicate profile names + sed 's/default/'$profile'/g' $config > $config.tmp + KUBECONFIG="$KUBECONFIG:$config.tmp" +done + +KUBECONFIG=$(echo $KUBECONFIG | cut -c2-) + +# Flatten configuration and write it to file +KUBECONFIG=$KUBECONFIG kubectl config view --flatten > ~/.kube/config + +# Remove building blocks +rm ~/.kube/config-*.tmp diff --git a/.zshrc b/.zshrc index 403e0da..3f685fa 100644 --- a/.zshrc +++ b/.zshrc @@ -111,11 +111,6 @@ alias gitcommiiiiiiiiiiiiiit='cz' alias clip='xclip -selection primary' -function kube-merge() { - cp ~/.kube/config ~/.kube/config.bak && - KUBECONFIG=~/.kube/config-nuuday:~/.kube/config-halia kubectl config view --flatten > ~/.kube/config -} - # alias wg-reload="f() {sudo bash -c 'cd /etc/wireguard && wg syncconf $1 <(wg-quick strip $1)'};f" function wg-reload() { sudo bash -c 'cd /etc/wireguard && wg syncconf $0 <(wg-quick strip $0)' $1