Skip to content

Commit

Permalink
Acquire cluster admin role for only GKE (#1339)
Browse files Browse the repository at this point in the history
* acquire cluster admin role for only GKE

* add comment

* address comments

* move command outside the if
  • Loading branch information
chizhg authored and knative-prow-robot committed Sep 10, 2019
1 parent 92991cb commit 118deba
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions scripts/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,9 @@ function setup_test_cluster() {
abort "kubeconfig context set to ${k8s_cluster}, which is forbidden"

# If cluster admin role isn't set, this is a brand new cluster
# Setup the admin role and also KO_DOCKER_REPO
if [[ -z "$(kubectl get clusterrolebinding cluster-admin-binding 2> /dev/null)" ]]; then
# Setup the admin role and also KO_DOCKER_REPO if it is a GKE cluster
if [[ -z "$(kubectl get clusterrolebinding cluster-admin-binding 2> /dev/null)" && "${k8s_cluster}" =~ ^gke_.* ]]; then
acquire_cluster_admin_role ${k8s_user} ${E2E_CLUSTER_NAME} ${E2E_CLUSTER_REGION} ${E2E_CLUSTER_ZONE}
kubectl config set-context ${k8s_cluster} --namespace=default
# Incorporate an element of randomness to ensure that each run properly publishes images.
export KO_DOCKER_REPO=gcr.io/${E2E_PROJECT_ID}/${E2E_BASE_NAME}-e2e-img/${RANDOM}
fi
Expand All @@ -335,9 +334,12 @@ function setup_test_cluster() {
is_protected_gcr ${KO_DOCKER_REPO} && \
abort "\$KO_DOCKER_REPO set to ${KO_DOCKER_REPO}, which is forbidden"

echo "- Project is ${E2E_PROJECT_ID}"
# Use default namespace for all subsequent kubectl commands in this context
kubectl config set-context ${k8s_cluster} --namespace=default

echo "- gcloud project is ${E2E_PROJECT_ID}"
echo "- gcloud user is ${k8s_user}"
echo "- Cluster is ${k8s_cluster}"
echo "- User is ${k8s_user}"
echo "- Docker is ${KO_DOCKER_REPO}"

export KO_DATA_PATH="${REPO_ROOT_DIR}/.git"
Expand Down

0 comments on commit 118deba

Please sign in to comment.