Created
July 3, 2020 09:21
-
-
Save velotiotech/fb6e48a089d44274ca6e0f7a2773a825 to your computer and use it in GitHub Desktop.
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
# Create a Service Account | |
gcloud iam service-accounts create velero --display-name "Velero service account" | |
SERVICE_ACCOUNT_EMAIL=$(gcloud iam service-accounts list --filter="displayName:Velero service account" --format 'value(email)') | |
#Define Permissions for the Service Account | |
ROLE_PERMISSIONS=( | |
compute.disks.get | |
compute.disks.create | |
compute.disks.createSnapshot | |
compute.snapshots.get | |
compute.snapshots.create | |
compute.snapshots.useReadOnly | |
compute.snapshots.delete | |
compute.zones.get | |
) | |
# Create a Role for Velero | |
PROJECT_ID=$(gcloud config get-value project) | |
gcloud iam roles create velero.server \ | |
--project $PROJECT_ID \ | |
--title "Velero Server" \ | |
--permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")" | |
# Create a Role Binding for Velero | |
gcloud projects add-iam-policy-binding $PROJECT_ID \ | |
--member serviceAccount:$SERVICE_ACCOUNT_EMAIL \ | |
--role projects/$PROJECT_ID/roles/velero.server | |
gsutil iam ch serviceAccount:$SERVICE_ACCOUNT_EMAIL:objectAdmin | |
# Generate Service Key file for Velero and save it for later | |
gcloud iam service-accounts keys create credentials-velero \ | |
--iam-account $SERVICE_ACCOUNT_EMAIL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment