Ravindra BagaleCourses & study guides मराठी

Chapter 76: DevOps Projects Part 6: Kubernetes Canary Helm RBAC NetworkPolicy Quotas EKS Microservices Velero Upgrade

76.8 Project 47: Back up and restore a cluster with Velero

Friends, Velero copies cluster objects to S3 and can restore them. Today we install tips, back up a demo namespace, delete it, restore it, and note schedules and RPO RTO.

What you will build in this project

  1. Backup of demo-backup namespace.
  2. Restore after delete.
  3. Schedule tip.
  4. RPO RTO note.

1. Start from a real company story

At CRED in Bengaluru, Arjun had etcd snapshots but no object-level restore when a namespace wipe hit billing.

Velero drills became monthly. Rough past cost: about ₹90 lakh in manual rebuild overtime.

Today we practice that restore.

Velerobackup createS3 BSLCompleteddelete nsdisasterrestoreobjects back
Picture 1: cluster → Velero → S3 ; disaster → restore → namespaces back

Ravindra Bagale's Tip

Students celebrate backup create and never restore. Untested backups fail on the real day. Restore every month. Keep that habit.

2. Start and prepare

Step 1: Why Velero

Why: Object backup. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.

What: echo. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.

Example 1: a1

Type this:

echo 'Velero backs up Kubernetes objects and optionally PersistentVolume data'

You will see:

Velero backs up Kubernetes objects and optionally PersistentVolume data

What it means: What Velero is.

Example 2: a2

Type this:

echo 'Backups go to object storage: S3 or compatible'

You will see:

Backups go to object storage: S3 or compatible

What it means: Where backups live.

Example 3: a3

Type this:

echo 'Restore can recreate namespaces Deployments PVCs and more'

You will see:

Restore can recreate namespaces Deployments PVCs and more

What it means: What restore does.

Step 2: Install version

Why: Server up. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.

What: velero version. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.

Example 4: b1

Type this:

echo 'Install tip: follow velero.io docs for your cloud provider plugin'

You will see:

Install tip: follow velero.io docs for your cloud provider plugin

What it means: Install docs host.

Example 5: b2

Type this:

echo 'velero version'

You will see:

velero version

What it means: CLI talks to server.

Example 6: b3

Type this:

echo 'kubectl get deploy -n velero'

You will see:

kubectl get deploy -n velero

What it means: Velero server Running.

Step 3: S3 BSL

Why: Bucket. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.

What: s3 mb. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.

Example 7: c1

Type this:

echo 'aws s3 mb s3://shop-velero-backups --region ap-south-1  # when AWS lab is approved'

You will see:

aws s3 mb s3://shop-velero-backups --region ap-south-1  # when AWS lab is approved

What it means: Bucket tip.

Example 8: c2

Type this:

echo 'velero backup-location get'

You will see:

velero backup-location get

What it means: Backup storage location.

Example 9: c3

Type this:

echo 'Never store backups only inside the same cluster disks'

You will see:

Never store backups only inside the same cluster disks

What it means: Off-cluster habit.

3. Build the main pieces

Step 4: Demo workload

Why: Something to save. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.

What: kubectl create. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.

Example 10: d1

Type this:

echo 'kubectl create namespace demo-backup'

You will see:

kubectl create namespace demo-backup

What it means: Demo namespace.

Example 11: d2

Type this:

echo 'kubectl create deploy demo -n demo-backup --image=nginx:1.27-alpine'

You will see:

kubectl create deploy demo -n demo-backup --image=nginx:1.27-alpine

What it means: Demo Deployment.

Example 12: d3

Type this:

echo 'kubectl get all -n demo-backup'

You will see:

kubectl get all -n demo-backup

What it means: Confirm objects exist.

Step 5: backup create

Why: Take backup. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.

What: backup. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.

Example 13: e1

Type this:

echo 'velero backup create demo-bak --include-namespaces demo-backup'

You will see:

velero backup create demo-bak --include-namespaces demo-backup

What it means: Create backup.

Example 14: e2

Type this:

echo 'velero backup describe demo-bak'

You will see:

velero backup describe demo-bak

What it means: Watch phase Completed.

Example 15: e3

Type this:

echo 'velero backup get'

You will see:

velero backup get

What it means: List backups.

Step 6: delete restore

Why: Prove restore. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.

What: restore. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.

Example 16: f1

Type this:

echo 'kubectl delete ns demo-backup'

You will see:

kubectl delete ns demo-backup

What it means: Simulate disaster.

Example 17: f2

Type this:

echo 'velero restore create demo-restore --from-backup demo-bak'

You will see:

velero restore create demo-restore --from-backup demo-bak

What it means: Restore from backup.

Example 18: f3

Type this:

echo 'velero restore describe demo-restore'

You will see:

velero restore describe demo-restore

What it means: Watch restore Completed.

4. Automate and verify

Step 7: PVC schedule

Why: Volumes cron. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.

What: get deploy. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.

Example 19: g1

Type this:

echo 'kubectl get deploy -n demo-backup'

You will see:

kubectl get deploy -n demo-backup

What it means: demo Deployment should return.

Example 20: g2

Type this:

echo 'Include PVCs with --default-volumes-to-fs-backup or cloud snapshots'

You will see:

Include PVCs with --default-volumes-to-fs-backup or cloud snapshots

What it means: Volume tip.

Example 21: g3

Type this:

echo 'Schedule tip: velero schedule create nightly --schedule="0 2 * * *" --include-namespaces shop'

You will see:

Schedule tip: velero schedule create nightly ...

What it means: Cron schedule.

Step 8: Filters

Why: Narrow scope. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.

What: filtered. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.

Example 22: h1

Type this:

echo 'velero backup create filtered --include-resources deployments,services --include-namespaces shop'

You will see:

velero backup create filtered --include-resources ...

What it means: Filter resources.

Example 23: h2

Type this:

echo 'Exclude secrets tip: --exclude-resources secrets when another vault owns them'

You will see:

Exclude secrets tip: --exclude-resources secrets when another vault owns them

What it means: Secrets tip.

Example 24: h3

Type this:

echo 'Label selectors can back up only app=shop Pods objects'

You will see:

Label selectors can back up only app=shop Pods objects

What it means: Selector tip.

Step 9: RPO RTO drill

Why: Business numbers. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.

What: RPO. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.

Example 25: i1

Type this:

echo 'RPO is how much data you accept to lose; RTO is how fast you must be back'

You will see:

RPO is how much data you accept to lose; RTO is how fast you must be back

What it means: RPO RTO.

Example 26: i2

Type this:

echo 'Drill restores every month; a backup never tested is a hope'

You will see:

Drill restores every month; a backup never tested is a hope

What it means: Drill habit.

Example 27: i3

Type this:

echo 'Store backup encryption keys outside the cluster'

You will see:

Store backup encryption keys outside the cluster

What it means: Key habit.

5. Harden and accept

Step 10: Logs IAM

Why: Debug. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.

What: logs. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.

Example 28: j1

Type this:

echo 'velero backup logs demo-bak | tail'

You will see:

velero backup logs demo-bak | tail

What it means: Debug failed backups.

Example 29: j2

Type this:

echo 'Common fail: wrong IAM for the S3 bucket'

You will see:

Common fail: wrong IAM for the S3 bucket

What it means: IAM tip.

Example 30: j3

Type this:

echo 'Common fail: BSL Available false after credential secret typo'

You will see:

Common fail: BSL Available false after credential secret typo

What it means: BSL tip.

Step 11: Cleanup

Why: Cleanup. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.

What: cleanup. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.

Example 31: k1

Type this:

echo 'Optional cleanup: velero backup delete demo-bak; kubectl delete ns demo-backup'

You will see:

Optional cleanup: velero backup delete demo-bak; kubectl delete ns demo-backup

What it means: Cleanup.

Example 32: k2

Type this:

echo 'Save backup and restore commands with timestamps in your notebook'

You will see:

Save backup and restore commands with timestamps in your notebook

What it means: Artifact.

Example 33: k3

Type this:

echo 'Next project upgrades the cluster with zero downtime habits'

You will see:

Next project upgrades the cluster with zero downtime habits

What it means: Bridge.

Step 12: Acceptance

Why: Arjun signs off. We do this before the next step so mistakes stay small and easy to undo. Read the output carefully; the numbers and names tell you if the machine is healthy.

What: All green. Follow the numbered examples below. Type each command, read the exact output, and match the meaning line before you move on. That is how real teams learn a tool.

Example 34: z1

Type this:

echo 'Backup Completed and restore brought demo Deployment back'

You will see:

Backup Completed and restore brought demo Deployment back

What it means: Checklist restore.

Example 35: z2

Type this:

echo 'Off-cluster object storage configured'

You will see:

Off-cluster object storage configured

What it means: Checklist storage.

Example 36: z3

Type this:

echo 'Arjun: PASS'

You will see:

Arjun: PASS

What it means: Project 47 accepted.

Check yourself

Q1. Who fixed CRED?

Arjun

Q2. Docs host tip?

velero.io

Q3. Backup command family?

velero backup create

Q4. Restore flag?

--from-backup

Q5. Storage kind?

S3

Q6. Untested backup is?

a hope

Friends, you backed up and restored a namespace with Velero. Did you understand? Let us try it once more. Add a nightly schedule and a restore calendar invite.

Lab: try at home

  1. Install Velero per docs.
  2. Create demo workload.
  3. backup create and describe.
  4. Delete and restore.
  5. Note schedule RPO RTO.

Recap

  • Off-cluster storage.
  • Test restores.
  • IAM for S3.
  • Schedules beat memory.
  • Know RPO and RTO.