Velero Search and Practice Post demo code
KIND k8s cluster
- Create KIND k8s cluster
kind create cluster --name rocketchat-migrate-demo --config kind-config.yaml
- setup metallb
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.6/manifests/namespace.yaml kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)" kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.6/manifests/metallb.yaml kubectl apply -f metallb-config.yaml
- setup
rocketchat-migrate-demo-control-plane
node volume mount- 連線至
rocketchat-migrate-demo-control-plane
nodedocker exec -it rocketchat-migrate-demo-control-plane bash
- 在
rocketchat-migrate-demo-control-plane
node 建立後緒所需的磁碟區for vol in pv1; do mkdir /mnt/disks/$vol; mount -t tmpfs $vol /mnt/disks/$vol; done
- 連線至
- create
local-storage
storageClasskubectl apply -f local-pv-storage.yaml
- creat
local-persistent-storage
local persistent volumekubectl apply -f local-pv.yaml
- create Minio Server
helm install minio --create-namespace --namespace minio -f minio-values.yaml bitnami/minio
- create rocketchat workload
helm install rocketchat --namespace rocketchat --create-namespace -f rocketchat.yaml stable/rocketchat
- setup velero and restic
helm install velero vmware-tanzu/velero --namespace velero --create-namespace -f velero-values.yaml
- annotate pod
kubectl annotate pod -n rocketchat --selector=release=rocketchat,app=mongodb backup.velero.io/backup-volumes=datadir --overwrite
- backup rocketchat
velero backup create rocketchat-backup --include-namespaces rocketchat
s3cmd download bacup
cat <<EOF > ~/.s3cfg
host_base = <kind-minio-server>:9000
host_bucket = <kind-minio-server>:9000
bucket_location = default
use_https = False
access_key = minio
secret_key = minio123
signature_v2 = False
EOF
mkdir backup
s3cmd -p sync s3://velero/ backup/
GKE cluster
- create GKE cluster
- setup Minio Server
helm install minio --create-namespace --namespace minio -f minio-values.yaml bitnami/minio
- upload local backup to Minio server
s3cmd -p sync backup/ s3://velero/
- setup Velero & Restic
MINIO_SVC=$(kubectl -n minio get svc minio -o=jsonpath="{.status.loadBalancer.ingress[0].ip}") PUBLIC_URL=http://$MINIO_SVC:9000 echo $PUBLIC_URL helm install velero vmware-tanzu/velero --namespace velero --create-namespace --set configuration.backupStorageLocation.config.publicUrl=$PUBLIC_URL -f velero-values.yaml
- setup
change-storage-class-config.yaml
for StorageClass mappingkubectl apply -f change-storage-class-config.yaml -n velero
- restore velero backup
velero restore create --from-backup rocketchat-backup