diff --git a/README.md b/README.md index caf6948..4930a97 100644 --- a/README.md +++ b/README.md @@ -123,93 +123,64 @@ To verify above installation run following commands root@my-vm:/work# kubectl -n velero get pods NAME READY STATUS RESTARTS AGE velero-86bb45cdfb-987ps 1/1 Running 0 23s -``` - +kubectl logs deployment/velero -n velero +``` -## Author -**Akshit Sadana ** - -- Github: [@Akshit8](https://github.com/Akshit8) -- LinkedIn: [@akshitsadana](https://www.linkedin.com/in/akshit-sadana-b051ab121/) - -## License -Licensed under the MIT License - +If installation and connection to our storage bucket is successful no error messages would be there inside deployment logs. -## starting a docker conatiner with terraform installed +## Backing-up the sample namespace +For adding sample namespace to velero backup pool ```bash -docker run -it --rm -v ${PWD}/storage:/storage -w /storage akshit8/terraform +velero backup create sample-namespace-backup --include-namespaces sample -chmod +x .terraform/providers/registry.terraform.io/hashicorp/google/3.54.0/linux_amd64/terraform-provider-google_v3.54.0_x5 +velero backup describe sample-namespace-backup ``` -## setting up a test cluster with kind -```bash -kind create cluster --name test-cluster --image kindest/node:v1.18.0 + -docker run -it --rm -v ${HOME}:/root/ -v ${PWD}:/work -w /work --net host debian:buster - -apt-get update && apt install curl vim -y +If some error occurs inspect the backup logs -curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl - -chmod +x ./kubectl - -mv ./kubectl /usr/local/bin/kubectl - -root@my-vm:/work# kubectl get nodes -NAME STATUS ROLES AGE VERSION -test-cluster-control-plane Ready master 5m15s v1.17.0 - -curl -L -o /tmp/velero.tar.gz https://github.com/vmware-tanzu/velero/releases/download/v1.5.1/velero-v1.5.1-linux-amd64.tar.gz - -tar -C /tmp -xvf /tmp/velero.tar.gz - -mv /tmp/velero-v1.5.1-linux-amd64/velero /usr/local/bin/velero +```bash +velero backup logs sample-namespace-backup +``` -chmod +x /usr/local/bin/velero +Listing backups -velero --help +```bash +root@my-vm:/work/velero# velero get backups +NAME STATUS ERRORS WARNINGS CREATED EXPIRES STORAGE LOCATION SELECTOR +sample-namespace-backup Completed 0 0 2021-02-24 07:44:11 +0000 UTC 29d default +``` -kubectl create ns sample +Verify on Google Cloud Console -kubectl -n sample apply -f ./k8s-objects + -export BUCKET=velero-akshit -export REGION=asia-east1 +Our bucket contain backup files of all kuberntes objects that were deployed inside sample namespace. -velero install \ - --provider gcp \ - --plugins velero/velero-plugin-for-gcp:v1.1.0 \ - --bucket $BUCKET \ - --secret-file ./gcpServiceAccount/credentials.json +## Deleting object inside sample namespace +```bash +kubectl -n sample delete -f ./k8s-objects +``` -root@my-vm:/work# kubectl -n velero get pods -NAME READY STATUS RESTARTS AGE -velero-86bb45cdfb-987ps 1/1 Running 0 23s +Let's now recover the deleted objects with Velero -kubectl logs deployment/velero -n velero +```bash +velero restore create sample-namespace-backup --from-backup sample-namespace-backup +``` -velero backup create sample-namespace-backup --include-namespaces sample + -velero backup describe sample-namespace-backup +In case of any refer the logs +```bash velero backup logs sample-namespace-backup +``` -root@my-vm:/work/velero# velero get backups -NAME STATUS ERRORS WARNINGS CREATED EXPIRES STORAGE LOCATION SELECTOR -sample-namespace-backup Completed 0 0 2021-02-24 07:44:11 +0000 UTC 29d default - -kubectl -n sample delete -f ./k8s-objects - -root@my-vm:/work/velero# kubectl get all -n sample -No resources found in sample namespace. - -velero restore create sample-namespace-backup --from-backup sample-namespace-backup - -velero restore describe sample-namespace-backup +Let's verify whether sample namespace has restored or not +```bash root@my-vm:/work/velero# kubectl get all -n sample NAME READY STATUS RESTARTS AGE pod/sample-app-6ffc75c46-g6bbg 1/1 Running 0 24s @@ -223,39 +194,67 @@ deployment.apps/sample-app 2/2 2 2 24s NAME DESIRED CURRENT READY AGE replicaset.apps/sample-app-6ffc75c46 2 2 2 24s +``` + +## Migrating cluster from version 1.18 to 1.19 +As before we'll use kind to spin another light weight cluster with version 1.19 +```bash kind create cluster --name test-cluster-2 --image kindest/node:v1.19.0 +``` -## repeat steps +Check if the cluster is ready and accessible +```bash root@my-vm:/work# kubectl get nodes NAME STATUS ROLES AGE VERSION test-cluster-2-control-plane Ready master 6m1s v1.19.0 +``` -kubectl logs deployment/velero -n velero -[NO errors] +### Installing velero inside new cluster +- repeat the above steps to install velero again +- make sure deployment logs displays no error +- verify all components inside namespace velero are running. + +## Migrating backup to new cluster +List the backups present inside storage bucket +```bash root@my-vm:/work/velero# velero get backup NAME STATUS ERRORS WARNINGS CREATED EXPIRES STORAGE LOCATION SELECTOR sample-namespace-backup Completed 0 0 2021-02-24 07:44:11 +0000 UTC 29d default +``` -root@my-vm:/work/velero# kubectl get ns -NAME STATUS AGE -default Active 11m -kube-node-lease Active 11m -kube-public Active 11m -kube-system Active 11m -local-path-storage Active 10m -velero Active 2m45s +Starting the restore +```bash velero restore create sample-namespace-backup --from-backup sample-namespace-backup +``` +Verifying the restore +```bash velero restore describe sample-namespace-backu Phase: Completed Started: 2021-02-24 09:52:47 +0000 UTC Completed: 2021-02-24 09:52:48 +0000 UTC +``` + +Checking if all the components has been recovered - kubectl get all -n sample +```bash +kubectl get all -n sample ``` + + + + +## Author +**Akshit Sadana ** + +- Github: [@Akshit8](https://github.com/Akshit8) +- LinkedIn: [@akshitsadana](https://www.linkedin.com/in/akshit-sadana-b051ab121/) + +## License +Licensed under the MIT License \ No newline at end of file diff --git a/assets/backupconsole.png b/assets/backupconsole.png new file mode 100644 index 0000000..f308167 Binary files /dev/null and b/assets/backupconsole.png differ diff --git a/assets/backupdescribe.png b/assets/backupdescribe.png new file mode 100644 index 0000000..710d0a7 Binary files /dev/null and b/assets/backupdescribe.png differ diff --git a/assets/backupresult.png b/assets/backupresult.png new file mode 100644 index 0000000..d2bd4c7 Binary files /dev/null and b/assets/backupresult.png differ