Add _kubectl_config_merge for merging kube configs

This commit is contained in:
Rune Juhl Jacobsen 2024-07-03 09:05:45 +02:00
parent 112621e793
commit 76845745e3

18
_kubectl_config_merge Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
#
# Merge kube config file on stdin with the existing kube config file.
set -euo pipefail
tmp=$(mktemp)
new=$(mktemp)
cat > "${tmp}"
function _exit() {
rm -f "${tmp}" "${new}"
}
trap _exit EXIT
export KUBECONFIG="${tmp}:${HOME}/.kube/config"
kubectl config view --merge --flatten > "${new}"
mv "${new}" ~/.kube/config