 Hi, hello everyone. My name is Vivek. I am a software developer. I have also been Contributing to canister recently and in this particular session We are going to look into how we can use canister to back up your postgres application but before actually Looking into the demo. Let's talk about postgres and canister a bit So I think most of us already know that postgres is a Relational database that is being used by most of these companies on production But if we talk about canister canister is an open source project that can be used by used by Whoever is running their databases on on Kubernetes So it can basically be used by the teams to manage manage data of the stateful applications That is running on Kubernetes cluster So it can it can be used either by those teams or it can also be used by The the products that is working in the same space as as the backbone to to achieve a Workflow or to run a workflow now We are calling canister a Kubernetes native native framework because it very heavily uses Kubernetes API's custom custom resources or custom API's to achieve all these things that we just talked about If we talk about the basic building blocks of of canister project So we basically have introduced three custom API's or three custom resources Profile blueprint and actions it so the workflow that we have been talking about so for example if There are some things that you want to do while backing up your application You can define all those things in a specific resource that is called blueprint resource And we have introduced all these we introduce all these Custom resources as soon as you install canister So to specify this entire workflow you can create a blueprint resource now When you have specified a blueprint resource, you will have you will have to actually call Something from that workflow from that blueprint and to call it's a particular action For example backup action you can create an action set and that is the reason we have introduced another another resource Called action set So once you specify once you create an action set You also have to specify a blueprint where that action is present and you can also specify the action from that blueprint So this is where this is how action sets and blueprints work together. Now if we talk about profile So, let's let's take an example or let's talk about this use case where you have taken backup of your Application and you want to export it or you want to upload it to a particular centralized object location, let's say and that is where profiles come in the picture So you can create a profile to specify the details about your object store Now that we know about all those all those custom resources Let's talk about how all these things work together to achieve backup and backup and let's say restore So if you see here, we can see that The first step to actually back up your application is going to be Creating the action set action set is actually the step where the Action or backup action. Let's say actually gets triggered So as soon as we create the action set or our controller cancer controller is going to figure out the blueprint From the action set and it is going to get that blueprint to actually see or to actually get to know What are all the things that are specified in the blueprint and in the blueprint we can specify all these workflow using canister functions and that is that is What we have specified here using cube exec and cube tasks cube exec and cube tasks are some of the functions that we support In in blueprint and as soon as we figure out a phase or a step from the action We can we run where I say we I mean canister controller runs that particular action And if that action needs to let's say upload the data to a particular object store in that case We use profile. So this is how all these things work together to actually achieve backup and restore Now that we have set up a very basic understanding of canister Let's go ahead and try to actually see how we can how we can use canister to backup postgres So first of all, we are going to we already have a Kubernetes cluster setup and we are going to Create a namespace Canister and this is where we are going to install The canister operator or canister application. So if you see here to install canister We are using hell chart from this particular repo because we know that canister is distributed as as a Helm application. So if you try to get all the parts from canister namespace, you can see that the part is Successfully running and once we know that the part is successfully running what we can do is we can go ahead and try to Create the post base database. So I install the post base database so we want to install that in post base hyphen test namespace and So that is the reason we have created the namespace and now we are going to install The postgres database and we are going to again use help chart that is being maintained by Bitnami. So As soon as I hit enter, we should be able to see a pod in the in the Postgres hyphen test namespace and we will have to wait for this pod to be up and running and Once that particular pod is up and running what we can do is we can insert some Data in in a specific database just so that we can may make That something bad happened and the data was deleted and then we would actually restore that data So now that we see the part is running. Let's exit into That part and then we are actually going to insert some data into a database So this is how we are trying to get the we are trying to connect to the postgres database And we have if you see here, we have specified username and password and once we are into the postgres Shell what we can do is we can we can see all the databases that are that are there already We see that there are three three databases. So let's go ahead and create one database called test and then connect to that connect to That database once we have connected to that database Let's go ahead and try to try to create a table and to create a table We have to we have to run this particular command and once table is created what we can do is we can we can also Create a table inside or sorry, we can we can insert a row inside that table And now that the row has been inserted, we can see all the all the entries from that table using select query And now that now that we have if you see we have installed canister we have installed postgres database We have also inserted a query or a row inside inside the new table that we have created Now what we have to do is we have to integrate this postgres database with canister And when I say we have to integrate what we have what I mean is we have to create the respective blueprint and profile resources So to do that, I am going to create the profile resource So if you see here, I'm using this cancurtle utility that gets shipped with Canister and I'm also specifying that the object storage that I'm using is the S3 compliant There are some other supported as one as well that you can that you can check and I have also set the credentials in these environment variables and if you See here. We are also Creating this profile in the postgres hyphen test namespace So profile should be created created or must be created in in the namespace where your Application is running so as soon as I hit enter this this profile Should be created and once the profile is created. We are going to create the blueprint So meanwhile, it's being created. Let's go ahead and try to look into the blueprint resource So if you see here in this blueprint API or resource We are just trying to specify some actions and these actions are backup and restore and for every action We can specify some steps or phases So for example here, if you see this is one phase similarly, you can specify any other phase as well if if your use case requires that and When we have created this blueprint, we can run a specific action if you say here The name of this action is backup So we can run this particular action by specifying that in the in the actions it so if you see here the the Profile has been created and to create the blueprint. We are just going to copy this URL I'm going to I'm going to specify this GitHub repo in the slides as well So if you want to check that out, you can do that So create hyphen F and blueprints must be created in in the namespace where controller is running So we know that controller is running in canister namespace. So I'm going ahead ahead and Hitting enter now that the blueprint has been created. What we have to do is we have to actually Create the create the action set and to do that. I'm going to use I'm going to use this particular command again So if you see here Create action set and this cancetal command is actually going to create an action set resource and That is going to trigger Trigger the action that we have specified here. So if you see We are creating action set We want to run backup action from this this blueprint that we have created here and we are also specifying The object that the object where or against which the blueprint should Work on and we also have to specify the profiles Let's go ahead and try to specify the profile here So if you see here actions that has been created successfully and now canister operator is Actually our controller is actually doing the things that it is supposed to so if we describe the the action set If you see it the the in the events we can see that The controller is actually executing this PG dump step or phase right now So what we will have to do is you will have to wait for that PG dump step to be completed and as soon as that step is completed What we are going to do is we are going to just to mimic that Something bad happened We are going to delete the things from the database and then we are going to restore it from the backup that we have created so if I If I see if I try to describe the action set once again If you see here, it says that the action set has been Completed successfully. So now that the action set has been completed successfully. Let's exit into into The database once again and this time we are going to delete the records that we have inserted because we have taken We have taken the backup and to delete that what we are going to do is we are going to get the Postgres shell and Then if you list all the databases, we can see that this database is there and let's run drop database test and if you see the database has been dropped successfully and now we are just able to see 33 rows here. So now that we have deleted the data from the database Let's go ahead and try to try to restore. So To restore the to restore the data, we are if you see here, we have also specified what should happen In case of restore action. So if you see here, we are again creating an action set by specifying by specifying the the The backup action set. So if you remember when we created when we created a backup action set We did get we did get one Let's say Identifier of the action set and this is the this is the identifier. So we want to run Restore from this particular backup action set and as soon as I hit enter if you see the restore action has also been created And let's go ahead and try to describe this action set so We also have to specify on the namespace and if you see here It sees the action set restore has been completed successfully So now that it has been completed Let's again go ahead and log in into into the database to check if the data has been actually actually restored or not. So Getting the shell of postgres and if we list all the databases, you can see here that this database has been Restored successfully and we can actually connect to that database and we can see that there is a table with Roe inserted in it and this is this is what we deleted to immediate disaster So now Now that we have looked into the demo if you see this is exactly what we wanted to show in this particular session We can the thing that I want to emphasize on is we can actually define the way Using which we want our application to be backed up and that can be done using using blueprints If you want to get in touch with us, you can obviously join canisters slack workspace You can look into the issues in cancer GitHub repo if you want to contribute to them and we also get into bi-weekly Community meetings, so you can try to join them as well. Thank you so much