(bin) Update kube-merge command

This commit is contained in:
Tanguy Herbron 2023-01-05 22:12:56 +01:00
parent 2465365f17
commit 001f99a0ac
2 changed files with 23 additions and 5 deletions

23
.bin/kube-merge Executable file
View File

@ -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

5
.zshrc
View File

@ -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