Set up a backup bucket incl. access in the google cloud
Setting up with Terraform
An example of setting up a Google Cloud bucket with Terraform can be found at here
Setting up with Google Cloud user interface
Prerequisites
- A service account must be available
Prerequisites for encrypting the bucket:
- The Cloud Key Management API must be activated in the project
- The service account must have the role "cloudkms.cryptoKeyEncrypterDecrypter"
- Key for encryption
- encryption is optional
Activate Cloud Key Management Service API
- Call up the KMS area of the project
- Activate Cloud Key Management Service API
Create service account
- Call up the IAM area of the project
- Create service account / service account
- Create name
- Set description
- Create
- Assign role "cloudkms.cryptoKeyEncrypterDecrypter" (optional, required for encryption)
Create key for encryption (optional)
- Switch to Security -> Key management -> Key rings
- Create a new key ring if necessary
- Region: europe-west3
- Create key
- Assign name
- Generated Key
- Symmetric encrypt/decrypt
- Key rotation: Never (or establish a better procedure)
- Labels
- purpose: (what this key is to be used for)
- key-name: $NAME (as above)
- team: $TEAM (e.g. ces)
Creating the bucket
- Call up buckets in the cloud storage area of the project
- Click "Create bucket"
- Assign a name
- Assign labels
- team: $TEAM (e.g. ces)
- purpose: $PURPOSE (what this bucket is to be used for)
- bucket_name: $NAME (as above)
- Location type: Region europe-west3
- Storage class: Standard
- Or nearline/coldline if there is infrequent access
- Prevent public access: Fine-grained
- Data protection: No soft-delete!
- Data encryption: Cloud KMS key
- Select the key created above
Serviceaccount auf den Bucket berechtigen
These steps need to be performed by a google cloud aministrator.
- get the serviceaccounts email
SERVICE_ACCOUNT_EMAIL=$(gcloud iam service-accounts list --project $PROJECT_ID --filter="displayName:Velero service account" --format 'value(email)')-
or use the serviceaccount page in google cloud
-
add permissions to the serviceaccount
ROLE_PERMISSIONS=(
compute.disks.get
compute.disks.create
compute.disks.createSnapshot
compute.projects.get
compute.snapshots.get
compute.snapshots.create
compute.snapshots.useReadOnly
compute.snapshots.delete
compute.zones.get
storage.objects.create
storage.objects.delete
storage.objects.get
storage.objects.list
iam.serviceAccounts.signBlob
)- the role "velero.server.2" already has all permissions
- otherwise: create the role
gcloud iam roles create velero.server --project $PROJECT_ID --title "Velero Server" --permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")"```- Add the role to the serviceaccount
gcloud projects add-iam-policy-binding $PROJECT_ID --member serviceAccount:$SERVICE_ACCOUNT_EMAIL --role projects/$PROJECT_ID/roles/velero.server- connect the serviceaccount to the bucket
gsutil iam ch serviceAccount:$SERVICE_ACCOUNT_EMAIL:objectAdmin gs://${BUCKET_NAME}Configure access from another project (optional)
- Open the created bucket
- Open "Authorisation"
- Click on "Grant access rights"
- Insert the email of the service account from the other project in the "New main accounts" input field
- Select the "Storage Object User" role in the "Select role" field
Configure bucket in velero
apiVersion: k8s.cloudogu.com/v1
kind: Component
metadata:
name: k8s-velero
labels:
app: ces
app.kubernetes.io/name: k8s-velero
spec:
name: k8s-velero
namespace: k8s
version: 10.0.1-5
valuesYamlOverwrite: |
volumesnapshotclass:
driver: "pd.csi.storage.gke.io"
parameters:
type: ""
velero:
credentials:
useSecret: true
existingSecret: velero-backup-target
initContainers:
- name: "velero-plugin-for-gcp"
image: "velero/velero-plugin-for-gcp:v1.12.1"
volumeMounts:
- "mountPath": "/target"
"name": "plugins"
configuration:
backupStorageLocation:
- name: default
provider: "velero.io/gcp"
bucket: "<my-bucket-name>"
config:
serviceAccount: "<my-service-account>"
volumeSnapshotLocation:
- name: default
provider: velero.io/gcp
config:
snapshotLocation: europe-west3Last updated on 1/21/2026