-
-
Save spmason/77e0e4b4bda984248f0b61824c90c08f to your computer and use it in GitHub Desktop.
Command for working with k8s contexts without needing to use kubectx or similar
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 | |
set -ue -o pipefail | |
CLUSTER=$1 | |
shift | |
CLUSTER_KUBECONFIG="$HOME/.kube/config.${CLUSTER}" | |
if ! [ -f $CLUSTER_KUBECONFIG ]; then | |
echo "current-context: ${CLUSTER}" > $CLUSTER_KUBECONFIG | |
fi | |
export KUBECONFIG=${CLUSTER_KUBECONFIG}:$HOME/.kube/config | |
exec kubectl $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment