-
Notifications
You must be signed in to change notification settings - Fork 159
Remove old policy bindings so that setup-project is reentrant #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
title: "GCP Compute Persistent Disk CSI Driver Custom Roles" | ||
description: Custom roles required for functions of the gcp-compute-persistent-disk-csi-driver | ||
stage: ALPHA | ||
includedPermissions: | ||
- compute.instances.get | ||
- compute.instances.attachDisk |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,17 +3,40 @@ | |
set -o nounset | ||
set -o errexit | ||
|
||
readonly PKGDIR="${GOPATH}/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver" | ||
readonly KUBEDEPLOY="${PKGDIR}/deploy/kubernetes" | ||
|
||
BIND_ROLES="roles/compute.storageAdmin roles/iam.serviceAccountUser projects/${PROJECT}/roles/gcp_compute_persistent_disk_csi_driver_custom_role" | ||
IAM_NAME="${GCEPD_SA_NAME}@${PROJECT}.iam.gserviceaccount.com" | ||
|
||
# Cleanup old Service Account and Key | ||
# Create or Update Custom Role | ||
if gcloud iam roles describe gcp_compute_persistent_disk_csi_driver_custom_role --project "${PROJECT}"; | ||
then | ||
yes | gcloud iam roles update gcp_compute_persistent_disk_csi_driver_custom_role \ | ||
--project "${PROJECT}" \ | ||
--file "${PKGDIR}/deploy/gcp-compute-persistent-disk-csi-driver-custom-role.yaml" | ||
else | ||
gcloud iam roles create gcp_compute_persistent_disk_csi_driver_custom_role \ | ||
--project "${PROJECT}" \ | ||
--file "${PKGDIR}/deploy/gcp-compute-persistent-disk-csi-driver-custom-role.yaml" | ||
fi | ||
|
||
# Delete Service Account Key | ||
if [ -f $SA_FILE ]; then | ||
rm "$SA_FILE" | ||
fi | ||
# Delete Bindings | ||
for role in ${BIND_ROLES} | ||
do | ||
gcloud projects remove-iam-policy-binding "${PROJECT}" --member serviceAccount:"${IAM_NAME}" --role $role --quiet || true | ||
done | ||
# Delete Service Account | ||
gcloud iam service-accounts delete "$IAM_NAME" --quiet || true | ||
# TODO: Delete ALL policy bindings | ||
|
||
# Create new Service Account and Keys | ||
gcloud iam service-accounts create "${GCEPD_SA_NAME}" | ||
gcloud iam service-accounts keys create "${SA_FILE}" --iam-account "${IAM_NAME}" | ||
gcloud projects add-iam-policy-binding "${PROJECT}" --member serviceAccount:"${IAM_NAME}" --role roles/compute.admin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. your role-binding teardown logic will not be backwards compatible anymore. maybe it needs to somehow iterate through all the rolebindings the SA has, and delete them There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. resolved |
||
gcloud projects add-iam-policy-binding "${PROJECT}" --member serviceAccount:"${IAM_NAME}" --role roles/iam.serviceAccountUser | ||
for role in ${BIND_ROLES} | ||
do | ||
gcloud projects add-iam-policy-binding "${PROJECT}" --member serviceAccount:"${IAM_NAME}" --role ${role} | ||
done | ||
gcloud iam service-accounts keys create "${SA_FILE}" --iam-account "${IAM_NAME}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the -q option not work for suppressing interactive mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brainfarted