Skip to content

Commit

Permalink
updated .envrc-gcp
Browse files Browse the repository at this point in the history
  • Loading branch information
HariSekhon committed Jul 27, 2021
1 parent c863433 commit f50ae11
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions .envrc-gcp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,28 @@ export CLOUDSDK_RUN_PLATFORM=managed
#export CLOUDSDK_RUN_CLUSTER=mycluster

export CLOUDSDK_GCLOUDIGNORE_ENABLED=True
#export CLOUDSDK_BUILDS_USE_KANIKO=True

# XXX: Edit
# XXX: Edit, or remove if only have 1 cluster in project, will auto-determine below
export CLOUDSDK_CONTAINER_CLUSTER=mycluster # GKE cluster name
#export CLOUDSDK_BUILDS_USE_KANIKO=True

export GKE_CONTEXT="gke_${CLOUDSDK_CORE_PROJECT}_${CLOUDSDK_COMPUTE_REGION}_${CLOUDSDK_CONTAINER_CLUSTER}"
# If CLOUDSDK_CONTAINNER_CLUSTER isn't set and there is only one EKS cluster in this account and region, then use it - smart, but slower, prefer setting it explicitly for speed
if [ -z "${CLOUDSDK_CONTAINER_CLUSTER:-}" ]; then
gke_clusters=()
while IFS='' read -r line; do
gke_clusters+=("$line")
done < <(gcloud container clusters list --format='get(name)')
if [ "${#gke_clusters[@]}" -eq 1 ]; then
export CLOUDSDK_CONTAINER_CLUSTER="${gke_clusters[*]}"
fi
fi

if [ -n "${CLOUDSDK_CONTAINER_CLUSTER:-}" ]; then
# kubectl context is easily created by running adjacent aws_kube_creds.sh script first

export GKE_CONTEXT="gke_${CLOUDSDK_CORE_PROJECT}_${CLOUDSDK_COMPUTE_REGION}_${CLOUDSDK_CONTAINER_CLUSTER}"

# XXX: safer to inline .envrc-kubernetes if you're worried about changes to it bypassing 'direnv allow' authorization
# shellcheck disable=SC1090
. "$srcdir/.envrc-kubernetes" "$GKE_CONTEXT"
# XXX: safer to inline .envrc-kubernetes if you're worried about changes to it bypassing 'direnv allow' authorization
# shellcheck disable=SC1090
. "$srcdir/.envrc-kubernetes" "$GKE_CONTEXT"
fi

0 comments on commit f50ae11

Please sign in to comment.