DevOps Tutorials | Kubernetes cluster backup and restore with Velero - Kubernetes cluster backup

CLOUD LEARN HUB
6 Sept 202220:13

Summary

TLDRThis video discusses Valero, a backup and restore tool for Kubernetes clusters. It emphasizes the importance of backups for disaster recovery and data preservation, regardless of a cluster's resilience. The presenter introduces Valero, which utilizes cloud providers' block storage snapshot features to snapshot persistent volumes and restore cluster objects. The video covers backup strategies, including full backups and namespace-specific backups, and demonstrates how to install Valero, take backups, and restore from backups. It also shows a practical scenario where a namespace is deleted and then recovered using Valero.

Takeaways

  • 😀 Kubernetes backup is crucial for disaster recovery and maintaining data integrity.
  • 🛠 Valero is a backup tool for Kubernetes clusters that leverages cloud providers' block storage snapshot features.
  • 📈 Valero supports full backups, namespace-specific backups, and resource type backups, offering flexibility in backup strategies.
  • ⏰ Backups can be scheduled to run periodically, ensuring ongoing data protection.
  • 🔍 Valero is useful for recovering from disasters, such as accidental namespace deletions or failed Kubernetes API upgrades.
  • 🔄 It facilitates environment replication and major updates, such as moving from development to production.
  • 💾 Backups include both Kubernetes state (etcd) and application data on persistent volumes.
  • 📋 Prerequisites for using Valero include a running Kubernetes cluster and the installation of the Valero tool.
  • 🔧 The Valero client and server must be installed, and the server should be running to perform backup and restore operations.
  • 🔄 The process of restoring a deleted namespace demonstrates Valero's ability to recover from data loss scenarios.

Q & A

  • What is the importance of backup in Kubernetes?

    -Backup in Kubernetes is crucial for disaster recovery and ensuring data integrity. It allows you to restore your cluster objects and persistent volumes to a previous state in case of failures, data loss, or accidental deletions.

  • Why is it essential to have a backup and disaster recovery plan for Kubernetes clusters?

    -A backup and disaster recovery plan are essential to recover from catastrophic events, such as accidental deletions, cluster failures, or network issues, and to maintain the availability and resilience of your applications.

  • What is Valero and how does it relate to Kubernetes backup?

    -Valero is a backup tool for Kubernetes clusters that takes snapshots of your clusters' persistent volumes using cloud providers' block storage snapshot features. It allows you to perform full backups or backups of specific namespaces or resource types.

  • Can Valero be used for periodic backups in Kubernetes?

    -Yes, Valero can be used to schedule backups to be executed periodically, providing a flexible approach to backup strategies depending on the needs of the environment.

  • What are some scenarios where backup and recovery in Kubernetes are necessary?

    -Backup and recovery in Kubernetes are necessary in scenarios such as accidental namespace deletion, failed Kubernetes API upgrades, network outages, or when replicating environments from development to production.

  • What are the prerequisites for using Valero to backup a Kubernetes cluster?

    -The prerequisites for using Valero include having a running Kubernetes cluster and installing the Valero tool in your environment.

  • How can one verify if a backup taken by Valero has been completed successfully?

    -To verify if a Valero backup has been completed, you can use the command `velero backup describe <backup-name>` which will show the details including the completion status, start time, and expiry date of the backup.

  • What happens if a namespace is accidentally deleted in a Kubernetes cluster?

    -If a namespace is accidentally deleted, it can lead to loss of services and deployments within that namespace. However, with Valero, you can restore the deleted namespace and its resources from a previously taken backup.

  • How does Valero help in recovering from a disaster in a Kubernetes cluster?

    -Valero helps in disaster recovery by allowing you to restore your cluster to a previous state using the snapshots taken during the backup process. This can be done by issuing a restore command with the specific backup name.

  • What are the steps to restore a Kubernetes cluster using Valero after a disaster?

    -To restore a Kubernetes cluster using Valero, you first ensure Valero is installed and running, then use the command `velero restore create --from-backup <backup-name>` to initiate the restore process, and finally verify the restoration by checking the restored resources.

Outlines

00:00

🔒 Importance of Backup in Kubernetes

The speaker introduces the topic of backup and restore tools in Kubernetes, emphasizing the necessity of backing up data before going to production. They highlight the importance of having a solid backup and disaster recovery plan, regardless of the cluster's resilience. The tool 'Velero' is introduced as a solution for backing up Kubernetes clusters, which takes snapshots of persistent volumes using cloud providers' block storage snapshot features. The speaker also discusses the different types of backups one can perform with Velero, such as full backups or backups of specific namespaces or resource types, and the flexibility to schedule backups.

05:02

🛠 Setting Up and Using Velero

The speaker provides a step-by-step guide on how to set up and use Velero. They begin by pulling down the Velero GitHub repository and installing the Velero client. The process involves downloading the Velero server, dealing with errors that arise during installation, and ensuring that the prerequisites for backup are met, such as having a running cluster and Velero installed. The speaker also mentions the documentation available on the Velero website for further guidance on installation and backup procedures.

10:03

🚀 Deploying an Application and Taking a Backup

After successfully installing Velero, the speaker proceeds to deploy an Nginx application within the Kubernetes cluster. They demonstrate how to check the deployment status and ensure that Velero and the Nginx application are both deployed correctly. The speaker then walks through the process of taking a backup using the 'velero backup create' command, explaining how to verify the completion and details of the backup.

15:04

🔄 Simulating Disaster and Restoring from Backup

The speaker simulates a disaster scenario by deleting a namespace that contains the Nginx application. They demonstrate how to delete the namespace using 'kubectl delete namespace' and verify that the services and deployments are gone. After the deletion, the speaker shows how to restore the deleted namespace and its resources using Velero's 'restore create' command. They verify the restoration by checking the namespace and services, confirming that the cluster has been successfully restored from the backup.

20:08

🏁 Conclusion

The final paragraph is a brief conclusion or a placeholder indicating the end of the discussion. It does not contain any content, but it signifies the completion of the video script.

Mindmap

Keywords

💡Valero

Valero is a backup and restore tool used in Kubernetes environments. It is crucial for disaster recovery and data preservation, as it allows users to take snapshots of cluster states and persistent volumes. In the video, Valero is introduced as a tool for creating backups of Kubernetes clusters, which can be full or partial, and can be scheduled for periodic execution. The script mentions using Valero to take backups before going to production, highlighting its importance in ensuring data integrity and cluster recovery.

💡Kubernetes

Kubernetes is an open-source container orchestration platform for automating deployment, scaling, and management of containerized applications. It is the central theme of the video, as the script discusses the importance of backing up Kubernetes clusters to ensure high availability and resilience. The video script emphasizes the need for a solid backup and disaster recovery plan regardless of how robust the Kubernetes cluster is.

💡Backup

Backup refers to the process of creating a copy of data to prevent data loss in case of system failures or disasters. In the context of the video, backup is a critical operation for Kubernetes clusters to ensure that data and cluster states can be restored to a previous state. The script discusses various scenarios where backups are essential, such as before going to production or when migrating clusters.

💡Disaster Recovery

Disaster Recovery (DR) is a strategy to prepare for potential disasters, such as data loss or system failures, by having a plan to recover and restore critical functions and data. The video script mentions the importance of a disaster recovery plan in conjunction with backups, emphasizing that even highly available Kubernetes clusters need a strategy to recover from catastrophic events.

💡Persistent Volume

Persistent Volume (PV) in Kubernetes is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using storage classes. The script explains that Valero takes snapshots of persistent volumes, which are crucial for backup because they store the stateful data of applications running in the cluster.

💡Namespace

A Namespace in Kubernetes is a logical partition that allows resources to be grouped together. The video script uses the term 'namespace' when discussing the backup and restore process, highlighting that backups can be taken at the namespace level, allowing for more granular control over what is backed up and restored.

💡Snapshot

A snapshot, in the context of the video, refers to a point-in-time capture of a disk's data. Valero uses cloud provider block storage snapshot features to create snapshots of Kubernetes clusters' persistent volumes, which can later be used to restore the cluster to a previous state. The script mentions snapshots as a core feature of the backup process.

💡Cluster Migration

Cluster Migration is the process of moving a Kubernetes cluster from one environment to another, such as from a development environment to a production environment. The video script discusses the use of backups during cluster migrations to ensure that the new environment has the same state as the original.

💡Deployment

In Kubernetes, a Deployment provides declarative updates to applications and their resources. The video script refers to deployments when demonstrating the backup and restore process, showing how Valero can back up and restore deployments within a namespace.

💡Data Integrity

Data Integrity ensures that data is accurate, consistent, and remains unaltered. The video script underscores the importance of maintaining data integrity through backups, especially before critical operations like going to production or performing major updates. It is a fundamental aspect of ensuring that the backup and restore process is reliable.

Highlights

Valero is a backup and restore tool used in Kubernetes environments.

Backup is crucial for data and cluster security in production environments.

Regardless of cluster resilience, a solid backup and disaster recovery plan are essential.

Valero takes snapshots of Kubernetes clusters' persistent volumes using cloud provider features.

Valero supports full backups, namespace-specific backups, and scheduled backups.

Backups are necessary for disaster recovery, accidental deletions, and API upgrade failures.

Backups are also important for environment replication and major updates.

Backups should include Kubernetes state, persistent volumes, and application data.

Prerequisites for backup include an up-and-running cluster and the installation of Valero.

Valero's GitHub repository provides installation instructions and use cases.

The video demonstrates how to download, install, and verify Valero.

The process of deploying an Nginx application in Kubernetes is shown.

A step-by-step guide on how to take a backup of Kubernetes resources using Valero.

Demonstration of deleting a namespace to simulate a disaster scenario.

Restoring a deleted namespace using Valero to showcase the recovery process.

Verification of successful restoration by checking the restored namespace and services.

Transcripts

play00:00

in this video I'm going to talk about

play00:02

the Valero one of the backup

play00:07

and restore tools which we are using in

play00:12

kubernetes so um uh we know

play00:15

um whenever you work in any environments

play00:18

we always talk about the backup right we

play00:22

always take to whether we have taken the

play00:25

backup of our data or not so

play00:30

so uh whenever you go to the Productions

play00:33

we always take the backup of your data

play00:36

or the cluster so here you know in this

play00:39

kubernetes backup are also important

play00:41

okay so it's very important to take the

play00:46

back up before going to the Productions

play00:48

or any any other environments data is

play00:51

very important so uh it's not uh it's no

play00:54

matter how highly available or resilient

play00:57

your kubernetes cluster is it is

play01:00

important to have a solid backup and you

play01:03

store plan and just Disaster Recovery

play01:06

plan okay so uh that's why I uh going to

play01:10

talk about here one of the tool okay

play01:14

that's called uh

play01:16

Bolero for backup in the store for our

play01:19

applications okay so uh we are going to

play01:23

uh The Tool uh let's uh talk about what

play01:27

about the tool is doing okay so Valero

play01:33

has become one of the backup tools for

play01:37

kubernetes cluster nowadays because uh

play01:39

this is one of for the cnca project and

play01:43

uh it's a takes the snapshot of your

play01:46

clusters

play01:48

persistent volume uh using one of your

play01:51

uh Cloud providers block storage

play01:53

snapshot features and uh later you can

play01:58

restore your cluster objects and

play01:59

persistent volumes to a previous state

play02:03

basically and so so uh you can use

play02:06

Valero to perform full backups full

play02:09

backups or you can backups of some of

play02:13

the name space age or resource types or

play02:16

can be scheduled backup to execute them

play02:19

periodically so it depends how means or

play02:23

what kind of backup you want to take

play02:25

whether the name space or you want to

play02:27

critically take so it's all depends on

play02:30

up to you okay but why we want to take

play02:32

that back up the Clusters Okay so

play02:37

backup you know right so where why you

play02:40

need a backup and Recovery mechanism

play02:42

cluster let's suppose something goes

play02:44

wrong so to recover from the disaster or

play02:47

someone accidentally uh let's suppose

play02:50

delete it the name space or your

play02:52

kubernetes API upgrade failed and you

play02:56

have to revert back your network went

play02:58

down now your cluster is not reachable

play03:02

um

play03:03

or any Mutual disasters happen right so

play03:08

that's why to recover from the that

play03:12

states the backup is important okay

play03:15

also when you replicate the environments

play03:18

uh from development to staging or

play03:22

um whenever you doing the major update

play03:24

upgrade from um tape to acceptance or

play03:27

Productions you take the backup position

play03:30

or when you are doing the migration of

play03:32

kubernetes clusters from one environment

play03:34

to another environments Okay so what are

play03:37

the things you take the backup here

play03:40

okay so when you talk about the backup

play03:43

basically uh

play03:47

so when you talk about the backup two

play03:52

things you need to backup kubernetes

play03:54

stores uh in a state in its City so uh

play03:59

basically it just stores the master its

play04:01

City and relevant certificate which we

play04:04

should be backed up okay and then the

play04:08

application data okay it's a

play04:12

also

play04:14

yeah

play04:16

yeah it's also uh take the backup of

play04:19

your application data persistent volume

play04:21

uh because in let's suppose you will be

play04:25

having the any application running your

play04:27

clusters and uh uh if your cluster goes

play04:31

down or it's not reachable it's very

play04:34

important to have the backup people

play04:35

applications right so

play04:39

um yeah so

play04:41

what is the prerequisites uh to have the

play04:43

backup your cluster should be up and

play04:45

running okay and uh you have to install

play04:49

uh the Valero in your environment so so

play04:53

uh you can go to the Valero site here

play04:56

okay Valero dot IO and you can see the

play04:59

use cases here Disaster Recovery cluster

play05:02

migrations backup reference so these are

play05:03

the use cases this have also explained

play05:06

about how you can do the installations

play05:08

how you can took the backup everything

play05:11

is has been um explained here in this

play05:13

page so you can go and uh

play05:17

uh read about this document so uh this

play05:21

uh web page uh let's go uh to the demo

play05:24

uh how we can take the backup how you

play05:28

restores we will also see one scenario

play05:31

wherever I will uh I will uh delete some

play05:33

namespace or cluster and how I will

play05:36

recover that so so uh let's uh start

play05:41

yeah so uh I'm going to start the lab

play05:44

here so first what I will do I will uh

play05:47

uh pull down the Valero GitHub repo okay

play05:52

um to start so I have also prepared uh

play05:56

the document here uh how to take backup

play05:59

migrate our uh

play06:01

kubernetes clusters I have prepared here

play06:04

okay so I will basically follow the

play06:07

steps I have written down the all the

play06:09

commands here

play06:10

I have also written here so let's uh

play06:13

first uh

play06:16

clone the

play06:18

apto Valero

play06:22

okay so what we'll do uh it will pull

play06:25

down the value of GitHub repo okay uh

play06:29

yeah once it is done

play06:31

um you what you have to do you have to

play06:33

download and install the uh your client

play06:36

here okay so

play06:39

you can

play06:42

download and install the Valero client

play06:46

from here

play06:55

okay

play06:57

so uh once it's done uh we will check

play07:00

the version of our value which

play07:03

installed in this

play07:06

cluster okay so let's uh

play07:12

first download it

play07:15

once it is downloaded

play07:17

then

play07:20

we will extract this top file here

play07:24

meanwhile I will go and copy this

play07:28

command

play07:31

yeah now it will take some time because

play07:33

it's a very big file

play07:41

uh you can

play07:43

go and refer this is the uh

play07:48

Valero GitHub project okay so uh you saw

play07:53

right I I

play07:54

downloaded or pulled this GitHub project

play07:59

github.com here

play08:03

so this is the project which I uh

play08:05

downloaded uh in my local in my cluster

play08:08

basically okay so

play08:11

um it is downloaded okay so now you

play08:15

extract it okay

play08:18

so once it is done I will add Valor

play08:22

directory to uh the path okay

play08:25

so let's wait for some time and

play08:30

let's go back

play08:32

and

play08:35

copy this

play08:44

yeah so it is done

play08:47

extracted

play08:49

Okay so

play08:55

you can see we are getting some error

play08:57

here okay uh because why I'm getting

play09:01

this error uh because uh this Valero is

play09:05

not started yet okay

play09:09

um so we will start that we will create

play09:12

the Valerio specific credential file

play09:14

here first

play09:15

okay so let's do it here

play09:26

it's done then we will start the server

play09:30

here

play09:33

we will uh get all the steps on the

play09:37

Valero web page okay

play09:40

and

play09:42

let's see again I'm getting the error

play09:45

let's see how can I uh

play09:48

solve this one okay it's something I

play09:51

have missed okay so I have not installed

play09:55

the fellow A8 so let's install it now

play10:00

I got I have just installed the client

play10:02

now I am installing the server

play10:11

so uh once it is done you can see this

play10:14

uh deployment Valero created Valero is

play10:17

installed so when you now run the Valero

play10:22

version

play10:24

it should now keep

play10:28

the W details about your version So

play10:31

currently we are getting version one one

play10:33

zero so uh uh now you will not get any

play10:36

error because your Valero is installed

play10:39

you can see here showing this Valero is

play10:41

installed

play10:43

okay so what next to what I'm going to

play10:46

do uh once uh this Valero is installed

play10:50

um say our main purpose uh okay again

play10:53

I'm getting some error why waiting for

play10:56

server status request to process

play11:01

wait

play11:03

uh sometimes it takes time yeah so I

play11:06

think it will show it should work

play11:12

uh time weight okay so what I will do I

play11:15

will uh again install this uh sometimes

play11:19

uh

play11:21

um we Face ratio

play11:24

so let's see

play11:32

yes so you see uh now I got the client

play11:36

and server detail so don't worry uh when

play11:40

you get uh this type of error uh again

play11:42

you install uh the Bell Arrow okay so

play11:46

we'll

play11:47

um because I I faced this issue before

play11:49

so I know um how to solve this so you

play11:52

can do the similar things here now what

play11:55

I'm going to do here now I'm going to

play11:59

uh deploy here one nginx application uh

play12:04

in my cluster

play12:06

yeah so if you go and see uh Cube CTL

play12:13

get

play12:16

deployments you see there is no resource

play12:20

so what I am going to do I am going to

play12:21

deploy one um

play12:25

application nginx applications

play12:28

why it's not

play12:30

Okay so

play12:34

deployments

play12:38

why it's not showing

play12:43

keeps it will get the comments

play12:47

where is it installed in space okay so

play12:50

basically it's uh deployed in nginx

play12:53

hyphen

play12:54

um example name space so what I will do

play12:58

I will go to

play13:00

and in x

play13:09

okay so you see uh

play13:13

there is even application named nginx

play13:15

iPhone deployment is deployed here you

play13:18

can also uh see what are the namespace

play13:21

is available here so Cube CTL get NS so

play13:26

this is the one which uh uh and the next

play13:30

application is deployed in this name

play13:32

space and this is the Valero or name

play13:34

space so where your Valero is installed

play13:36

okay so what I'm going to do next uh we

play13:41

already checked that your Valero and

play13:44

nginx is deployed okay

play13:48

um you can

play13:50

also check using this command here

play13:53

so

play13:54

you see value is deployed also okay what

play13:59

I am going to next uh we also checked

play14:02

our nginx is deployed

play14:04

um

play14:05

here we already checked this now we will

play14:08

uh take the uh backup okay so uh once uh

play14:13

Valero and nginx deployment is

play14:15

successfully created what I'm going to

play14:18

backup our resources okay so to take the

play14:21

backup of our resources this is a

play14:23

command where a row backup create nginx

play14:26

iPhone backup so let's go

play14:35

okay so what you see here it's saying

play14:38

there's Valero request nginx backup

play14:40

submitted successfully and uh you can

play14:43

describe this command uh to see more

play14:46

about uh uh what

play14:49

is backed up here okay so you can see

play14:53

yeah yeah with this command you can

play14:56

verify if the backup has been completed

play14:58

or not so you can see it's showing that

play15:01

it's it's completed so your backup is

play15:03

completed uh it will show you the date

play15:06

and time or what time it will um started

play15:09

what are the expiration day expiry date

play15:11

so all these things uh you can see here

play15:13

okay so what I will do now

play15:17

um we have taken the backup everything

play15:19

now we will delete the namespace okay so

play15:23

that's our purpose right we want to

play15:25

check whether we are able to uh recover

play15:28

our

play15:30

like uh

play15:32

cluster or not right so what one in this

play15:36

example I am going to uh do some

play15:38

disasters like I'm going to uh delete

play15:41

one name space so you know right we have

play15:44

um namespace

play15:46

uh called nginx hyphen example where our

play15:50

nginx application is deployed right so

play15:55

what I'm going to do so we will going to

play15:58

delete now this so the command is Cube

play16:01

CTL

play16:03

um delete command here

play16:11

you can also type

play16:14

um if you are so fast Cube CTL

play16:17

uh Delete

play16:22

namespace

play16:29

and then your name is this name

play16:33

so what's our name space name name space

play16:36

name is nginx hyphen example let's do

play16:39

copy and paste here

play16:44

Okay so

play16:46

it will get deleted in some time

play16:48

uh okay so once it is deleted we will uh

play16:52

check that and the next service and

play16:53

deployment are gone right so

play16:56

okay

play16:58

so how will you check that so it's very

play17:01

simple again Cube CTL get deployment and

play17:04

this name space right

play17:07

so let's verify that

play17:11

it's saying that sorry it's so my

play17:14

mistake I have in the wrong command here

play17:21

okay so no this was found because uh why

play17:23

because I have already deleted right so

play17:26

what I will do now I have to recover I

play17:28

have already taken the backup of this so

play17:31

I I can um easily um restore this right

play17:35

so you will also give verify the

play17:38

services so everything is deleted you

play17:41

you go up obviously we have deleted the

play17:46

uh name space so we'll not find anything

play17:49

in this particular name space so what

play17:52

I'm going to do I will uh restore

play17:56

uh the

play17:58

cluster okay so how will you do this uh

play18:02

uh command first we also check this view

play18:06

uh verify everything

play18:11

yes nothing is there

play18:18

okay so nothing is there

play18:21

so this is the command to restore so I'm

play18:25

going to uh uh restore here

play18:31

so how will you restore the command is

play18:34

Valero restore create hyphen iPhone from

play18:37

backup and the backup name this is the

play18:40

name of the backup right so what you see

play18:43

here uh restore request submitted

play18:46

successfully uh run Valero restore

play18:50

describe all these things so let's do uh

play18:53

we will see

play18:56

verify that it's a restore or not first

play18:59

okay

play19:01

so it's saying completed so now next uh

play19:08

run the command

play19:10

restore get

play19:16

okay

play19:18

okay so you can see it's uh restored

play19:21

completed zero warning zero errors and

play19:25

now we restore so we can go and check

play19:28

whether our name space is back or not

play19:32

okay so uh I will quickly go and then

play19:35

qctl

play19:36

get NS

play19:40

so you see name nginx example is back

play19:44

here okay

play19:47

yes so this is the service okay this

play19:51

service is available here

play19:54

now

play19:55

Cube CTL get already we got this name

play19:58

space yeah so we verify that we restored

play20:02

our cluster here okay uh we just wrote

play20:07

the name space here so it's it's very

play20:11

simple ah

Rate This

5.0 / 5 (0 votes)

Etiquetas Relacionadas
KubernetesBackupRestoreData SafetyDisaster RecoveryCloud StorageCluster ManagementDevOpsIT InfrastructureTechnical Tutorial
¿Necesitas un resumen en inglés?