Blockchain on Kubernetes | Deploying ETH Blockchain on K8s | Blockchain Primer

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
it's difficult to ignore the term blockchain and cryptocurrencies in the current age whether you are looking at a regional short film or you are looking at any newspaper everything or the other talks about either cryptocurrencies or the underlying technology which is blockchain most of us know what a blockchain is and in this video i am going to try set up a blockchain within a kubernetes cluster in layman's term it is like setting up a database within a self-managed kubernetes cluster and blockchain is another managed framework where you're going to deploy different applications in this particular video we are going to concentrate only on the blockchain setup and in the further videos if you guys like it we can deploy smart contracts and other decentralized applications on the ethereum blockchain so we are going to set up quorum-based blockchain in this particular video if you don't know what is quorum querum is a type of blockchain which was built over the ethereum blockchain so querum is like an abstraction which adds more security over the existing blockchain which is the ethereum so if you know there are different blockchain services and ethereum is one of them bitcoin has its own blockchain most of these decentralized finance applications the device they call it they are all built over ethereum and there is a blockchain service which is called as quorum which is almost similar to hyperledger fabric so hyperledger fabric is another framework which is built over ethereum and querum is another blockchain service which is built over ethereum so we are going to use quorum and deploy that into a kubernetes cluster so in order to do that i am going to follow the developer guide in achieving that before that i want to have a kubernetes cluster so i can install mini cube in my machine but i just wanted to show you by deploying that within an ec2 instance maybe in the future videos we can deploy the querum inside eks but right now i'm just going to spin up a mini cube within an ec2 instance and install quorum in that and run some test net test nodes within that right so we can see how the blockchains are getting stitched and etc so let's launch the ec2 instance i'm going to launch a ubuntu instance i'm going to use the ubuntu 20 version and i'm going to spin up a bigger machine so i'm going to spin up let's say t2 large right this particular machine has eight gig of memory and i'm going to use that particular machine i'm going to have the settings as default uh nothing is going to change and i'm going to increase the space of my disk to 16 gb because the blockchain gets deployed within the whole um system right i mean within the whole storage like how you use a database when you have a database to have its own space it's all present inside the storage right so we need to expand that storage so same way for the blockchain to be installed we need the storage space so i'm just installing 16 gig of space for that i'm going to add some tag uh let's use this tag for this particular user to instance a squirm blockchain so this will be just the ec2 instance name nothing else i'm going to create a security group with just my ip address this is my current ip address all right so i'm going to use my terminal to connect to the ec2 instance so that i can show you guys from my local machine i'm going to use an existing pair which i have already created so i'm going to use it so that's it so the ec2 instance is going to get created meanwhile uh what i can do is i can open my terminal i have my terminal here let's go to the instance if the instance gets uh to a initializing state i think we can connect to the instance let's wait for it meanwhile if i go to the quorum i can get the documentation on how to install quorum right so querum is basically a ethereum blockchain service which is based on which is written using golang right uh if you see here there are two different uh blockchain servers right the hyperledger one and the gokura so i'm going to use the goquarum so i can open the documentation here if i want to create only the applications which i want to deploy within the go quorum then i can use the quorum quick start this i can do in the next video first we will try to set up the blockchain first so that we can understand how difficult or easy it is to set it up inside kubernetes right so that's why i wanted to show you with gokuram which is one of the easiest blockchains which i have seen so let me go to the documentation of quorum so i will leave these documentation links in the description so that you can take a look um let me go to the concept getting started and inside getting started there is an install uh option here right so here if you see uh you can download some docker images let's go to the with kubernetes section so that's why it is called as cuban it is qub because it's based of quorum and then it can be deployed inside kubernetes so it's just a nerdy way of giving names right i mean kubernetes um so let's come back to the ec2 instance and see if it is ready so that we can connect yeah the instance is ready let's connect to the ec2 instance i'm just going to copy this command uh for some weird reason aws gives the certificate file in the name of dot cert and then when they connect it just gives bim so i'll just use serve so this should connect to our ec2 instance and i'm connected so i want to change my username to root so that i can install different stuff so i'm doing a sudo su inside the ac to instance this will have the root permissions i'll just do a clear i'm just going to reduce this so that you can see the documentation as well uh meanwhile as i mentioned i want to deploy the whole quorum within a kubernetes cluster right here we don't have a kubernetes cluster it's just the ec2 instance which is just a bare bone metal right i want to install kubernetes for that i'm going to first uh get the cube ctl which is the command line um for kubernetes so i'm just pasting the command so whatever commands i'm just running i'll paste all these in a github repository and then i will give that as a link inside the description so that you can walk through what all commands i had run so i'm just running them one by one based on what i have in my notepad in the other screen so what i have done here is i've downloaded the cube ctl which is the cli for kubernetes and i'm just giving some permissions then i'm just giving copying that into the local so that we can have cubectl here so if i do cube ctl version i should be able to see the version and it can you can see that there is no server running so it says that there is nothing running so the next one i need to install is docker right i mean docker is the basis for kubernetes and if you need to use mini cube you need docker pre-installed in the machine so i'm going to install docker so for that i'm going to run the docker install command so i'm going to do a sudo get app update and then i'm going to install docker right i'm going to update the ubuntu machine with all the security patches which are present and then i'm going to install docker so that's what i have done here so this is installing docker within this particular ec2 instance now once docker is installed we need multiple things right we need mini cube and also we need golang because for ethereum uh the quorum right that for the quorum we need collag here right so i need to install golang as well so i'm going to do that as well so if you see here docker got installed let's do docker yes nothing is running so we have docker ready the next uh thing is installing mini cube so i'm going to install mini cube before that for docker i mean i had some issue in my um environment when i wanted to kickstart mini cube i had to install this contract plugin so i'm just installing that that's what i'm doing here the next command i'm going to pass is the curl for is the installation command for uh mini cube right so let me copy that and then so this is the installation command for mini cube and i'm just running it this will download the mini cube cli and then it will just install mini cube and i think it's done let me check what is the mini q version it says 124 that's the version of mini cube so we have mini cube ready we can just do a mini cube start but before that i want to also install golang so let me install everything and then start the mini cube right so i'm going to install golang and then set some predefined paths so that's what i'm doing here i'm just getting golang installing it setting some environment variables so that we can use it so and the core version which i'm using is here 1.16.4 you can use any version i'll just pick the version which i got right you can pick the latest version as well i just picked a random version because if you see here quorum wanted the golang which is greater than 1.13 so i i just picked 1.16 right but you can use the latest one as you now that's done uh once this is done we can follow the quorum gokuram documentation meanwhile let me start mini cube to see if mini cube has got installed successfully and it's okay so so in order to start mini cube i'm just going to use the no vm driver option because i don't have any vm installed this itself is a vm right i'm not having any additional vm to run docker right so that's what i'm doing here i'm just using the docker the vm driver none option so this should bring up our mini cube instance within the cc2 instance so meanwhile let's go back to the documentation for quorum so in this documentation this walks us through how you can get the quorum client libraries and also quorum has a quaran ctrl command like how you have um cube ctl for kubernetes for cuban it is like you right they have a qctl using which you can deploy it into the kubernetes cluster so this is basically an abstraction over the cube ctl which can do a lot of kubernetes specific commands right um and if you see here the dependencies they have mentioned as docker and also the kubernetes runtime here they have given links for the mini cube installation if you have the linux then you can use this i use the similar command and once that's done once the mini cube has been started you can start initializing the network so if you see here qctl will initialize the network within kubernetes right generate will create the network so for example here uh by default quorum will require three nodes in a cluster because um if you are creating a blockchain network right in in case of blockchain we don't call them as blockchain clusters right i mean we call them the blockchain network so within a network you can have three or more participants right so participants are different nodes which are participating in the network right and that's why we have initialized the network with three different nodes right and we are creating that network and finally we are going to deploy the apps in the network so the deploy network will just deploy an app we are going to create a sample app which is the cake shop which is present here and we are going to deploy it uh and again when you're creating the um querum uh network you can provide the different consensus algorithm so if you don't provide ibft you can have istanbul you can have there's one more cbft i think so you can have different consensus algorithm which you want to use within that network once you create it you're done understood right i mean once the blockchain network is created it's like setting up a database right i mean you you you have that ready right and then you can deploy your application or decentralized applications or dabs right those dapps can be deployed into the network using the deploy command and finally i i'm going to show you um by executing the so get this nothing but the cli for ethereum right the g f is basically golang specific that's why it is called get g right and i'm going to execute um the block number inside the quorum node one right so we're going to create a test uh um what you call contract within the node nodes within the cluster so that's what is doing uh happening here once that's done we are going to check what is the block number so that way we know that some test data is being pushed right so that's what we are going to do now coming back to the terminal let's see if things are up yeah mini cube is up uh let's do a cube ctl get pods to check uh yeah so cubesater is connecting get namespace yeah so we have multiple namespaces right we just got created so we have everything ready within the ec2 instance now we can just follow the steps in the um quorum documentation right so i'm going to copy the qctl installation command right so let this download the qctl and then we should be able to check if qctl is good so we can just say qctl help this will check if the qctl command line interface is installed yeah it is got installed uh the kubernetes is installed we can use now the qctl to interact or deploy stuff using quorum right now coming back to uh the documentation here so we need to set some environment variables i'm just going to set some environment variables to create some configuration files in the current directory so currently if you see there is nothing in this directory it's just the golang zip file nothing is there the my config.yaml is going to get created um right i mean and let's check for it right so first i'm going to create the um quaran node i'm going to initialize this particular quarant node and the command for that is this so i'm just going to initialize saying uh my nodes are these right and this is the consensus algorithm right to set the default values you can okay so you can create the file uh the next command is obviously create the network i'm just going to use the create network command let me run it yeah so this is downloading some containers from um container quorum engineering and that's the kubernetes container so it's downloading these containers and i feel this is the quorum node uh it's going to deploy that as a pod right i mean obviously to run anything within kubernetes you need containers right and it's downloading a container so that it can be run as a pod and that's what it's doing i guess so it's downloading the newer version yeah so that is completed uh the generation of quran k it resources all over done it has also created some files if you see here there is an out file there is a let's look at the out file right okay it's a directory yeah so if you can see that there are a bunch of yaml files which got created uh let me go into the deployments right you will have uh four different quorum nodes let me paste it now this is the file which gets used to uh deploy within the cluster so it has generated so if you see here the command which we gave right what was the command so the command was generate network so the generate network command using the cube ctl the kubernetes created bunch of yaml files for kubernetes right specific configurations right and it has all those details within that yaml if you have time and if you want to explore you can just open this yaml and then take a look at them what they are doing but i'm just going to show you by just deploying the network right so let me go back and let me paste now if you see here this applied a bunch of uh commands it created config maps it created a persistent volume claim like i mentioned um blockchain is like a database right and it needs some storage and that's where persistent volume claim will be helpful wherever we had the storage present right it also has bunch of config maps it also has services deployed for each node you using which you can communicate with the pods there are also again some config maps specific to the nodes addresses etc and finally we have the deployments created for each of these nodes right now coming back to the status here if you see here there are so there is a part which is called quorum node one deployment and it has two containers in it right i mean one container is up the other container is coming up this is where the sidecar approaches um happening so there are two containers within the pod i don't know what each of them does but i know one is specific to the um quorum right so done i think um if you can see the message right i mean the quorum network is ready to go to run the test contract check the blockchain num uh the block number and the g8 attached to a node in the network run the yeah so they're saying that you can run a test contract by running this right so before running a test contract i want to see uh what is the current blockchain number right or the block number so let's run this command which is the qctl gf exec quorum node one and then the block number right the block number right now is zero if you see the blockchain is empty right now this is like querying a database when you do a select star from or select count star what do you get zero right initially when you create a table so that's how it is so the blockchain um infrastructure is ready and it is that simple right if you look at it we just ran bunch of commands and then the infrastructure is ready now the real challenge comes in when you deploy applications on these and then run those applications right so we are not going to see that in this particular video but we are going to run a test contract which is already present within the um example here right so i'm going to use uh these commands i'm just going to run them right i mean obviously it's not going to harm it's just going to update our existing parts so let me run it meanwhile i will come back to the uh steps so the next steps are listing the quorum nodes ah yeah we did not see the quorum nodes right i mean i wanted you to show the quorum nodes right there are four nodes in the um quorum right now so let's look at that right so the command for that is qctl ls nodes so if you see here there are four nodes it doesn't show the name but if you run this particular command right i mean if you just say cube ctl ls nodes all it will show you uh what are the different node data so see here there are different node specific urls these are um things which are specific to the blockchain network so you see here there is a quorum version what version of the blockchain quorum which is running the transaction manager is basically the component which takes care of interacting with the blockchain which is uh tessera tessera is a client which can connect to the transaction manager which can validate each of your smart contracts right so let me clear this out now coming back to adding and deleting so you can add additional nodes for example if you want to add more nodes we can just say add node i can just do an add node okay i think i just added it already there i i think i just pasted it right now so if i run the nodes again so you can see that there are 5 nodes now to run a test contract i'm going to run the qctl test contract so this is an embedded api which is already present inside kubernetes that's why the qctl knows that this is the test contract and it's going to run on a node which is quorum node one right and if you remember when we ran the uh the previous the gf command right i mean we were trying to check the um what was the yeah block number right if you see here the block number was zero when we ran previously now if i run this right the block number if you see here it's 559 right so there are a lot of test messages which have been pushed and then each of those messages are basically creating different blockchain networks so basically transactions are happening in the background and that's why we see those block numbers increasing right i mean right now you see it's 64. right all these are happening in the background 65 and it's increasing right because the um the whole test network or the test contract the whole test contract has created different transactions within our um quorum cluster or the quorum network and it's just running right i mean see that it's 17 now there are different blocks getting created destroyed etc right now how do you check what's happening within kubernetes right i mean it's all magical right i mean i didn't do anything i didn't record anything it's all happening magically right now in order to see what's happening inside the network you can use the pods get those logs from the pods so i can do a cube ctl logs and then i can give a particular base this particular guy and then hyphen f uh i think uh what was the container name i think i don't know the container name but i can yeah so there are two containers one is the tessera and then the other one is quran so i'm going to use the quorum container so let's do hyphen c like i said there is two slash two right one is tessera which is the client and the quorum is basically the server right so i'm going to get the logs of the quorum right so see here the logs are just pouring in right i mean this is where the test contract is just sending some transactions and they're just calculating different smart contracts right basically the consensus uh which is happening within the whole network right i mean it's trying to check within the node there are different nodes each nodes are trying to validate those transactions etc right so smart contracts are nothing but the business logic on what needs to be done in the next video we will try to deploy an application right and in that application we might be creating smart contracts right imagine in layman's terms smart contracts are like business logics something like efl sloops right that's it so we're going to do that in the next video but for now i hope you understood that um it's not that tough to set up a kubernetes uh to set up a blockchain network within kubernetes right now coming to the next command so there are different commands i think one was it was creating a public and private whatever test contract here you can create a only a private contract if you just say pass private and we already ran this particular command to identify how many blocks are there right now let's let's run the blocks again right to see how many are there so right now it's 115 so there are a lot of transactions which are happening so the block count is increasing right there is also a command to log into that particular node and then do something right if you run this particular command called get attach right you can log into the node so i'm going to show that by login to the node but i don't know what to run right i mean i am here to learn what needs to be done within the cli so if you see here i am logged into the quorum node 1 right and i can execute or enter different blocks within the node here right instead of doing this you can use tessera so tessera is the client which is running as a side car using which you can communicate right i mean maybe you can trigger some rest end points using that you can communicate with the quorum but if you want to directly communicate with the quorum this is how you can do it you can use the get cli and then run some commands from here so i'm going to exit it now so that's it so you can just say get servers we had a lot of services see here there are different services we also saw that there are cube ctl get config there are config map right there are different config maps which are all created right you can take a look at it explore more but at a high level if you see quorum has created an abstraction over kubernetes using kubernetes using which we can deploy the whole network within kubernetes and you can deploy smart contracts within the whole network so i hope this particular video was interesting uh let me know your comments thoughts uh on how the whole blockchain experience was using quorum and do try out um in your own machine or maybe spin up an ec2 instance if you have a mini cube installed locally in your machine you can try installing quorum in that and then maybe you can deploy a smart contract within it before i could do it and if you have any links or anything which you think would be helpful for me to learn about smart contracts or dabs do share that in the comment section below as always if you like the video go ahead and like it if you haven't subscribed to the channel go ahead and subscribe to it meet you again in the next video thank you very much
Info
Channel: Tech Primers
Views: 1,113
Rating: undefined out of 5
Keywords: techprimers, tech primers, consensys, quorum blockchain, blockchain on K8s, blockchain on kubernetes, ethereum, goquorum on k8s, blockchain setup, kubernetes on blockchain setup, how to setup blockchain on kubernetes, blockchain tutorial, blockchain setup for beginners, setup blockchain from scratch, how to setup blockchain, how to setup ethereum, evm, setup evm, setup blockchain on AWS
Id: Xw4FfuMh3T0
Channel Id: undefined
Length: 25min 29sec (1529 seconds)
Published: Wed Dec 08 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.