Backup and restore k3s kubernetes cluster with velero

   · ☕ 1 min read · 🤖 Alexander Chernov

Recently for my home, I’ve migrated from docker to k3s cluster. However, in the beginning, it was a standalone master with an agent connected to it. Later on I wanted to migrate to HA, however for now it’s not possible to do so natively with k3s.

And here comes in play Velero .

With Velero, you can back up and restore your cluster on s3 compatible storage (I am using scaleway) which permits you to replicate or migrate your kubernetes provider without any major issues.

Download and install velero executable on your machine

1
2
3
4
wget https://github.com/vmware-tanzu/velero/releases/download/v1.4.0/velero-v1.4.0-linux-amd64.tar.gz
tar xzvf velero-v1.4.0-linux-amd64.tar.gz
cd velero-v1.4.0-linux-amd64/
mv velero /usr/local/bin/

Create your s3 bucket and credentials, once that’s done, create configuration file

1
2
3
echo "[default]
aws_access_key_id = SCWXXXXXXXXXX
aws_secret_access_key = 7970c83b-xxx-xxxx-xxx-xxxxx" > credentials-velero

Install Velero on your cluster

1
2
3
4
5
6
7
velero install \
    --provider aws \
    --bucket k3s-akc-backup \
    --secret-file ./credentials-velero \
    --use-volume-snapshots=false \
    --plugins=velero/velero-plugin-for-aws \
    --backup-location-config region=fr-par,s3ForcePathStyle="true",s3Url=https://s3.fr-par.scw.cloud

Once that’s done, you can make a backup of your cluster with

1
velero backup create full -snapshot-volumes=false 

Alexander Chernov
WRITTEN BY
Alexander Chernov