Velero to the Rescue: Seamlessly Back Up On-Prem K8s Clusters to AWS S3


As Kubernetes continues to dominate the container orchestration landscape, ensuring robust backup and disaster recovery strategies for your workloads has never been more critical. Whether you're running Kubernetes on-premises for data sovereignty, compliance, or cost reasons, having a cloud-based backup strategy can significantly reduce risk and recovery time. Enter Velero — a powerful, open-source tool that simplifies the backup and restore process for Kubernetes clusters. And when combined with Amazon S3, Velero becomes a powerhouse for hybrid cloud backup.

Why Choose Velero for On-Prem Kubernetes?

Velero (formerly Heptio Ark) provides:

  • Backup of entire Kubernetes clusters, including persistent volumes.

  • Disaster recovery allows cluster restoration in different environments.

  • Migration enables the movement of workloads across clusters or platforms.

  • Scheduling lets you automate backups at regular intervals.

Its native support for various cloud storage providers, including AWS S3, makes it the ideal tool for integrating on-prem Kubernetes with AWS cloud storage.


Prerequisites

Before diving in, ensure you have:

  • An on-premises Kubernetes cluster (any K8s distro like k3s, kubeadm, OpenShift, etc.).

  • Access to an AWS account with an S3 bucket created.

  • Installed AWS CLI and configured credentials with access to S3.

  • Installed Velero CLI on your machine.


Step-by-Step: Backing Up On-Prem K8s to AWS S3 Using Velero

Step 1: Create an S3 Bucket on AWS

Go to the AWS Console or CLI and create a bucket:


aws s3api create-bucket --bucket your-velero-backup-bucket --region us-east-1


Enable versioning for better backup management:


aws s3api put-bucket-versioning --bucket your-velero-backup-bucket --versioning-configuration Status=Enabled



Step 2: Create an IAM User and Policy

Create an IAM policy with S3 access for Velero:


{

  "Version": "2012-10-17",

  "Statement": [

    {

      "Effect": "Allow",

      "Action": [

        "s3:PutObject",

        "s3:GetObject",

        "s3:DeleteObject",

        "s3:ListBucket"

      ],

      "Resource": [

        "arn:aws:s3:::your-velero-backup-bucket/*",

        "arn:aws:s3:::your-velero-backup-bucket"

      ]

    }

  ]

}


Attach the policy to a new IAM user and generate access keys.


Step 3: Install Velero on the On-Prem Cluster


velero install \

  --provider aws \

  --plugins velero/velero-plugin-for-aws:v1.8.0 \

  --bucket your-velero-backup-bucket \

  --backup-location-config region=us-east-1 \

  --secret-file ./credentials-velero \

  --use-volume-snapshots=false \

  --use-restic


Note: --use-volume-snapshots=false is used because on-prem clusters don’t typically support cloud-based snapshots. Velero’s Restic integration handles volume backups.


Step 4: Backup and Restore Workloads

To back up a namespace:


velero backup create my-backup --include-namespaces=my-namespace


To restore it:


velero restore create --from-backup my-backup


You can also schedule backups:


velero schedule create daily-backup --schedule="@every 24h" --include-namespaces=my-namespace



Benefits of Using AWS S3 with Velero

  • Durability: S3 provides 99.999999999% (11 9’s) durability.

  • Scalability: Easily scales with your backup data size.

  • Security: Integrated with IAM, encryption, and access logging.

  • Cost-Effective: Pay-as-you-go with lifecycle policies for archival to Glacier.


Considerations

  • Network Bandwidth: Backups will travel over the internet (or Direct Connect), so consider data egress speeds.

  • Security: Use secure access keys, IAM best practices, and encryption.

  • Restic Performance: For large PVs, performance may vary — test and tune accordingly.


Final Thoughts

Combining Velero with AWS S3 creates a resilient, cloud-integrated backup strategy for your on-prem Kubernetes clusters. Whether preparing for disaster recovery, planning a migration, or ensuring compliance, this setup has you covered with minimal overhead.


Comments

Popular posts from this blog

HTTP Basic vs API Key Auth: Best Practices for Secure API Development

ECS Deployment Best Practices: Blue/Green with CodePipeline and CodeDeploy

AWS Console Not Loading? Here’s How to Fix It Fast

YouTube Channel