Verification:
Confirm the bucket was created by listing its contents (it will be empty initially):
aws s3 ls s3://kubeblocks-backup-repo
Step 2: Create a Kubernetes Secret for AWS Credentials
Store your AWS credentials securely in a Kubernetes Secret. Replace <ACCESS_KEY> and <SECRET_KEY> with your actual AWS credentials:
# Create a secret to save the access key
kubectl create secret generic s3-credential-for-backuprepo \
--from-literal=accessKeyId=<ACCESS KEY> \
--from-literal=secretAccessKey=<SECRET KEY> \
-n kb-system
Step 3: Configure Backup Repository
A BackupRepo is a custom resource that defines a storage repository for backups. In this step, you'll integrate your S3 bucket with KubeBlocks by creating a BackupRepo resource.
Apply the following YAML to create the BackupRepo. Replace fields(e.g., bucket name, region) with your specific settings.
kubectlapply-f-<<EOFapiVersion:dataprotection.kubeblocks.io/v1alpha1kind:BackupRepometadata:name:s3-repoannotations:dataprotection.kubeblocks.io/is-default-repo:'true'spec:# Currently, KubeBlocks supports configuring various object storage services as backup repositories# - s3 (Amazon Simple Storage Service)# - oss (Alibaba Cloud Object Storage Service)# - cos (Tencent Cloud Object Storage)# - gcs (Google Cloud Storage)# - obs (Huawei Cloud Object Storage)# - minio, and other S3-compatible services.storageProviderRef:s3# Specifies the access method of the backup repository.# - Tool# - MountaccessMethod:Tool# Specifies reclaim policy of the PV created by this backup repository.pvReclaimPolicy:Retain# Specifies the capacity of the PVC created by this backup repository.volumeCapacity:100Gi# Stores the non-secret configuration parameters for the StorageProvider.config:bucket:kubeblocks-backup-repoendpoint:''mountOptions:--memory-limit1000--dir-mode0777--file-mode0666region:us-west-1# References to the secret that holds the credentials for the StorageProvider.credential:# name is unique within a namespace to reference a secret resource.name:s3-credential-for-backuprepo# namespace defines the space within which the secret name must be unique.namespace:kb-systemEOF
Step 4: Verify Backup Repository Status
Check the status of the BackupRepo to ensure it is correctly initialized:
kubectl get backuprepo s3-repo -w
Expected Status Flow:
NAME STATUS STORAGEPROVIDER ACCESSMETHOD DEFAULT AGE
s3-repo PreChecking s3 Tool true 5s
s3-repo Ready s3 Tool true 35s
Troubleshooting:
If status becomes Failed:
Verify bucket name and region match your S3 configuration.
Confirm AWS credentials in the Secret are correct.
Check network connectivity between KubeBlocks and AWS S3.