Add _kubectl_config_merge for merging kube configs
This commit is contained in:
parent
112621e793
commit
76845745e3
1 changed files with 18 additions and 0 deletions
18
_kubectl_config_merge
Executable file
18
_kubectl_config_merge
Executable 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue