Created
August 10, 2018 18:24
-
-
Save lilithmooncohen/01b180b897b0eac4f1c0f09088cb2da4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 -e | |
if [ "$#" -lt 4 ]; then | |
>&2 echo "Not all expected arguments set." | |
exit 1 | |
fi | |
PROJECT_ID=$1 | |
CREDENTIALS=$2 | |
LOCATION=$3 | |
CLUSTER_NAME=$4 | |
shift 4 | |
export CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=$CREDENTIALS | |
RANDOM_ID="${RANDOM}_${RANDOM}" | |
export TMPDIR="/tmp/kube_auth_wrapper_${CLUSTER_NAME}_${RANDOM_ID}" | |
function cleanup { | |
rm -rf ${TMPDIR} | |
echo "CLEANUP" | |
} | |
trap cleanup EXIT | |
mkdir ${TMPDIR} | |
export KUBECONFIG="${TMPDIR}/config" | |
gcloud --project="${PROJECT_ID}" container clusters --zone="${LOCATION}" get-credentials ${CLUSTER_NAME} | |
"$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment