Last active
October 31, 2022 20:13
-
-
Save lcarva/9c65671f16edffcd7e8929f0aba51ae7 to your computer and use it in GitHub Desktop.
Easily create a new temporary kubeconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create a new temporary kubeconfig file and display a command to | |
# configure the current shell to use the new kubeconfig file. | |
# This is helpful if you interact with multiple OpenShift clusters | |
# at the same time. | |
# | |
# Usage: | |
# $(kubectl-new-env) | |
set -euo pipefail | |
KUBECONFIG=$(mktemp -t kubeconfig.XXXXX) | |
chmod og-rwx ${KUBECONFIG} | |
echo "export KUBECONFIG=${KUBECONFIG}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have set this up on my system so a new KubeConfig is created whenever I open a new shell which works well for my use case.
chmod +x <path-to-script>
.bashrc
:$(<path-to-file-above)