playground/_kubectl_config_merge

18 lines
344 B
Bash
Executable file

#!/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