Skip to content

Commit

Permalink
conclusion left
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshit8 committed Feb 24, 2021
1 parent 7711451 commit a804549
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 76 deletions.
151 changes: 75 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <akshitsadana@gmail.com>**

- 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
<img src="assets/backupdescribe.png">

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 <none>
```

kubectl create ns sample
Verify on Google Cloud Console

kubectl -n sample apply -f ./k8s-objects
<img src="assets/backupconsole.png">

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
<img src="assets/backupresult.png">

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 <none>

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
Expand All @@ -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 <none>
```

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
```

<img src="assets/samplens.png">


## Author
**Akshit Sadana <akshitsadana@gmail.com>**

- Github: [@Akshit8](https://github.com/Akshit8)
- LinkedIn: [@akshitsadana](https://www.linkedin.com/in/akshit-sadana-b051ab121/)

## License
Licensed under the MIT License
Binary file added assets/backupconsole.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/backupdescribe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/backupresult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a804549

Please sign in to comment.