Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshit8 committed Feb 24, 2021
1 parent 21be7e4 commit 738e7f3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
# velero
Backing-up, restoring and migrating kubernetes cluster with velero📦 .
Backing-up, restoring and migrating Kubernetes cluster with Velero📦 .

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

Velero is a light weight tool to safely backup, restore, handle cluster-failovers, and migrate Kubernetes cluster resources and persistent volumes.
**Velero** is a light weight tool to safely *backup*, *restore*, handle cluster-failovers, and migrate Kubernetes cluster resources and persistent volumes.

## Kubernetes cluster with Kind
[Kind](https://kind.sigs.k8s.io/) is a light weight utility to create single-node Kubernetes cluster on a docker container for testing purposes. Using kind will allow us to create two test cluster of different versions quickly, thus allowing us to simulate cluster-migrations.<br>
[**Kind**](https://kind.sigs.k8s.io/) is a light weight utility to create single-node Kubernetes cluster on a Docker container for testing purposes. Using Kind will allow us to create two test cluster of different versions quickly, thus allowing us to simulate cluster-migrations.<br>
For installing kind:
- checkout [kind-quickstart](https://kind.sigs.k8s.io/docs/user/quick-start/)
- Or watch [this](https://www.youtube.com/watch?v=m-IlbCgSzkc) video

**CAUTION** 🛑 🛑 :
- Make sure Docker is installed on your machine/
- If you are using kubernetes(v 1.17), do check your coredns is working. For verifying status of coredns click [here](https://stackoverflow.com/questions/53075796/coredns-pods-have-crashloopbackoff-or-error-state).
- Make sure Docker is installed on your machine.
- If you are using Kubernetes(version 1.17), do check if **coredns** is working. For verifying status of coredns click [here](https://stackoverflow.com/questions/53075796/coredns-pods-have-crashloopbackoff-or-error-state).

## Service account for terraform and velero
Instructions for creating a service account with necessary permission [here](../gcpServiceAccount/README.md).

## Setting up storage plugin for velero
Velero requires a storage site for pushing back-up files and retrieving them back in case of restoration. We'll be using Google cloud storage bucket for this tutorial, but you can explore wide variety of storage plugin offered by velero [here](https://velero.io/plugins/).
Velero requires a storage site for pushing back-up files and retrieving them back in case of restoration. We'll be using **Google cloud storage bucket** for this tutorial, but you can explore wide variety of storage plugin offered by velero [here](https://velero.io/plugins/).

### Creating a storage bucket with terraform
You can grap terraform CLI from [here](https://www.terraform.io/downloads.html) or else use docker container that comes pre-installed with terraform. The infrastructure files for terraform are placed inside [storage](./storage) folder. Make sure your `credentials.json` is present inside `gcpServiceAccount` folder
You can grab **Terraform** CLI from [here](https://www.terraform.io/downloads.html) or else use a Docker container that comes pre-installed with terraform. The infrastructure files for terraform are placed inside [storage](./storage) folder. Make sure your `credentials.json` is present inside `gcpServiceAccount` folder

```bash
docker run -it --rm -v ${PWD}/storage:/storage -w /storage akshit8/terraform
```

Once the container has been created run the following commands to create a storage bucket on GCP
Once the container has been created, run the following commands to create a storage bucket on GCP.

```bash
# to download gcp provider and any dependency
Expand All @@ -38,12 +38,12 @@ terraform init
terraform apply
```

If no error is thrown you'll be able to see newly created bucket in your cloud console.
If no error is thrown, you'll be able to see a newly created bucket in your cloud console.

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

## Test cluster(v 1.18)
With storage bucket in place, let us create a test cluster with kubernetes version 1.18
With storage bucket in place, let us create a `test-cluster` with Kubernetes version **1.18**

```bash
kind create cluster --name test-cluster --image kindest/node:v1.18.0
Expand All @@ -52,12 +52,12 @@ kind create cluster --name test-cluster --image kindest/node:v1.18.0
<img src="assets/kindcreate.png">

## Installing Kubectl and Velero CLI
To install both CLI's i'll use a debian docker container
To install both CLI's we can use a **Debian** Docker container.

```bash
docker run -it --rm -v ${HOME}:/root/ -v ${PWD}:/work -w /work --net host debian:buster
```
mounting $HOME directory provides access to KUBE_CONFIG generated by kind.
mounting **$HOME** directory provides access to **KUBE_CONFIG** generated by Kind cli.

- Installing Kubectl
```bash
Expand All @@ -68,7 +68,7 @@ chmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl
```

To verify kubectl and our test cluster run
To verify kubectl and our `test-cluster` run

```bash
root@my-vm:/work# kubectl get nodes
Expand All @@ -89,7 +89,7 @@ chmod +x /usr/local/bin/velero
```

## Deploying Kubernetes objects in a sample namespace
Kubernetes object that I use for this tutorial is located in [k8s-objects](./k8s-objects) folder.
Kubernetes objects used for this tutorial is located in [k8s-objects](./k8s-objects) folder.

```bash
kubectl create ns sample
Expand All @@ -103,7 +103,7 @@ kubectl -n sample apply -f ./k8s-objects

## Configuring Velero for backing-up sample namespace

- Using Velero CLI that we installed previously, we need to deploy some components(that velero use) inside our cluster and configure them, so that velero can access our cloud storage bucket
- Using Velero CLI installed previously, we need to deploy some components(that velero use) inside our cluster and configure them, so that Velero can access our *cloud storage bucket*.

```bash
# setting the bucket name
Expand All @@ -119,7 +119,7 @@ velero install \

**Note**: it will create a new namespace velero to hold all components.

To verify above installation run following commands
To verify above installation, run following commands

```bash
root@my-vm:/work# kubectl -n velero get pods
Expand All @@ -129,10 +129,10 @@ velero-86bb45cdfb-987ps 1/1 Running 0 23s
kubectl logs deployment/velero -n velero
```

If installation and connection to our storage bucket is successful no error messages would be there inside deployment logs.
**If installation and connection to our storage bucket is successful, no error messages would be there inside deployment logs.**

## Backing-up the sample namespace
For adding sample namespace to velero backup pool
For adding `sample` namespace to Velero backup pool
```bash
velero backup create sample-namespace-backup --include-namespaces sample

Expand All @@ -141,7 +141,7 @@ velero backup describe sample-namespace-backup

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

If some error occurs inspect the backup logs
If some error occurs, inspect the backup logs

```bash
velero backup logs sample-namespace-backup
Expand All @@ -159,7 +159,7 @@ Verify on Google Cloud Console

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

Our bucket contain backup files of all kuberntes objects that were deployed inside sample namespace.
Our bucket contain backup files of all **Kuberntes objects** that were deployed inside `sample` namespace.

## Deleting object inside sample namespace
```bash
Expand All @@ -174,13 +174,13 @@ velero restore create sample-namespace-backup --from-backup sample-namespace-bac

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

In case of any refer the logs
In case of any error, refer the logs

```bash
velero backup logs sample-namespace-backup
```

Let's verify whether sample namespace has restored or not
Let's verify whether `sample` namespace has been restored or not

```bash
root@my-vm:/work/velero# kubectl get all -n sample
Expand All @@ -199,13 +199,13 @@ 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
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
```

Check if the cluster is ready and accessible
Check if the cluster is ready and accessible:

```bash
root@my-vm:/work# kubectl get nodes
Expand All @@ -214,7 +214,7 @@ test-cluster-2-control-plane Ready master 6m1s v1.19.0
```

### Installing velero inside new cluster
- repeat the above steps to install velero again
- repeat the above steps to install Velero again
- make sure deployment logs displays no error
- verify all components inside namespace velero are running.

Expand Down
6 changes: 3 additions & 3 deletions gcpServiceAccount/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## GCP service account to use with terraform and velero
A service account that has admin access to `google cloud storage` is required for terraform to provision a bucket and for velero to read/write backups to this bucket. <br>
A service account that has admin access to `google cloud storage` is required for **Terraform** to provision a bucket and for **Velero** to read/write backups to this bucket. <br>
Open [google cloud console](https://console.cloud.google.com) and navigate to `IAM & Admin`>`Service accounts`
- create a new service account
- create a new service account.
- Give `cloud storage admin` permission to this account.
- Create a key for this account in `json` format and download it.
- Rename it to `credentials.json` and place it in this folder.
- Rename it to `credentials.json` and place it inside this folder.

0 comments on commit 738e7f3

Please sign in to comment.