Complete Kubernetes Course | Deploy MERN app

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there everyone atesh here back again with another video and welcome to the fresh new video on kubernetes I will hundred percent give it to you that probably some of you have tried to understand the kubernetes or even to implement that it is not easy for a beginner it is a really mystery that how the kubernetes work what is in the first place kubernetes is how it is going to make my life easier or where should I get started to learn about kubernetes you have found enough a playlist on Docker but kubernetes is not that simple and I agree with that point but this video is here to change all of that from this video onwards you are going to learn a lot about kubernetes not from the theoretical perspective all those diagrams and presentations are not there in this video we're going to be directly jumping into kubernetes and one of the best way to understand something is to find out why it is there and what all it can do for me so exactly what we are going to be working with that we will be working on a full stack burned app and that app will be deployed using kubernetes the best part is you do not need to have that murder app in fact we are not going to be writing any app these are the containers which are available to us via official people like from Express guys and from mongodb so Nokia code is being written and no code is needed to be downloaded from my GitHub repository or from my Docker repository all of them are going to be coming up from official Docker repository so yes before getting started kubernetes you need to know a couple of more interesting stuff first of all you need to be aware about containerization now I already have a really long video on the docker it's really a fantastic one you only need to watch that before coming into this video in case you are mildly familiar with what Docker is and what containerization is and brief vague overview that yeah it's a kind of a packaging of the application so that we can make images from it that is also more than enough for this video doesn't have this video doesn't have too much of the high-end requirements only thing is you should be aware what Docker is or basically what images are and containerization is if you are ready for that that's it that's all the prerequisite is so getting started with that this video is going to be Hands-On on building and containerizing a full stack application via kubernetes and we're gonna see what all the minimum bare minimum components which are required of kubernetes and instead of going into theories and just the definition I thought this would be a great start of kubernetes of let's just go ahead and get our hands dirty write some commands and get kubernetes in your system yep that is what we are doing we will be talking about kubernetes in AWS and Azure and all that maybe in the future right now let's keep everything onto the local because that's where you have the most control so with this I hope you are excited about this I will walk you through from the documentation and fire up your vs code because I'm all excited to show you how we're going to be doing it and one thing promise this is going to be the most easiest guide of getting started with kubernetes with the Practical project deploying a full stack my nap using kubernetes okay all right enough of the introduction I hope you have already subscribed to the channel because I'm pushing out a lot of content new Fantastic easy way content so go ahead hit that subscribe and let's continue with that before we get started with the kubernetes I would like to thank the sponsor of this video which is rovi rovi is an open source really fantastic and amazing tool for your backend you can connect your database and build Cloud functions you don't need to go with the command line tools and all of that with the Firebase and stuff you build your Cloud functions directly in the browser with the use of rovi and forget about CLI configs and all of them this is your database you match them up and that's what your rovi is I'll talk more about them in a minute first let's get started with kubernetes so couple of things before we get started I would like to introduce you to the hub of Docker so this is where majority of the things are going to come into the picture and the first one obviously we're going to be deploying a which is going to be our database so this is our the database and we'll be using any of the image whichever you want you can just go ahead and use that only thing we will be talking a lot is about the environment variable because mongodb at the time of initialization it requires a root and the password so it's set up so that is our first prerequisite or requirement we'll be getting and then there is also an Express this is something which is mind-boggling this is super interesting what Express guys did they actually made an admin interface which connects to mongodb and you can do all the updates directly in mongodb and basically your web application is almost similar to that your web application also interacts with mongodb but in that case you write a lot of business logic so that things happen like login logout and all of that but in reality if you look from zoomed out version and a big picture of it is just is an application which manipulates the database so in this case we'll be using Express as our web app now it could be your own custom design web app as well it might have more environment variable than what it is available here or less as well but the big picture is that this is an application which interacts with the mongodb so it's the basic how it goes now this is Express we'll be using it and by the way in case you have watched the docker series I have watched through with the a Express in that also so here we have list of table what all is available and required and of course admin username a password and one more there is one more which is I guess a server uh somewhere here this is the one so server admin password and admin username these are the three which are compulsory in the case of Express so these are the variables that we are looking up for now obviously this also needs three things so you might have noticed server This Server is nothing it's just a path of where the database lies in case when you build application using Atlas you provide that when you build application using your localhost mongodb you provide that path in your application so similar way we have to provide this path to the environment variables okay all right this is all done and all clear now let's go ahead and see that how we can actually build up so let's move on to kubernetes first now of course the definition is little bit challenging to understand at least at this point of stage uh surely I'll break it down much more in the eventual videos and you will be having absolute Mastery of kubernetes in over the time right now uh this is really simple it says kubernetes also known as k8s and by the way it's K it's because it's uh one two three four five six seven eight so between the K and S there are eight character yeah it's a really weird way of calling it as k8s but you get the idea it's it's kubernetes it's an open source system for automatically deploying scaling and managing containerized application so one thing is clear this is some kind of orchestration tool a really fancy word orchestration it simply is simple way that you have containerized your application with the docker now you have thousands of these Dockers maybe you have Micro services or something else or maybe just a one single application now you want a wave through which these containers can be brought up brought down if somebody goes down we need to bring it up back and there should be a mechanism to control it and that's what kubernetes offer it there's a lot more for kubernetes to understand it for for example why Google rolled it out as an open source now why not before Google have been using this for so long and it has something to do that AWS was taking over the market and kubernetes is the way to get Cloud free so Google rolled it out so yes we'll talk about these interesting details in history later on right now this is all what we have and it's really simple nothing too much this is all what we got to do and one thing is to note here that kubernetes is mostly about microservices but it doesn't always need to be you can use kubernetes with your regular application but in the case of micro Services it may makes much much sense we're going to go into documentation and there are two keywords where I would like to bring your attention the first one obviously is kubernetes in order to work with kubernetes there are a lot of ways that we can work it through dashboard and apis and command line the one command line which is given to us is Cube CTL it is nothing more than a command line interaction with the kubernetes so that's one portion remember I repeat it again that's one portion of understanding the kubernetes the another half portion is this guy which says a mini Cube yeah minicube is yes it is kubernetes but it's not Cube CTL Cube CTL is a command line interface to interact with kubernetes mini cube is a way to try understand and learn about kubernetes it's kind of a in the kubernetes uh yes I'll walk you through it's a control panel that has a lot of nodes I'll come back on to that in a minute but the whole thing is very very resource consuming in case you want to learn that you have to deploy servers on the cloud which is not really ideal it's not affordable for everyone so that's why a singular application containerized application is given to us known as minicube in which all the drama that is supposed to happen the kubernetes happens in just one container so remember Cube CDL is the way to interact with that command line and the mini cube is like whole big kubernetes things happening inside that but given to us in a smaller form so that we can work out with that okay so we'll talk about rest of the things not right now there are a lot of things in the kubernetes stateless stateful no need to just jump into them as of now so let me walk you through that how does actually kubernetes works and what's the basic overview and definitely we'll come back on to this later one on another video so the idea behind the kubernetes is that you have this main uh control plane so if I go ahead and write this one as control plane there are a lot of names for this one but we're gonna call this one as control plane and this control plane actually monitors a lot of further things as well so let me go ahead and work on with that so in fact I can actually copy this and paste this and paste this so yes there could be a lot of them so a lot of worker nodes are there and you can call them whatever you like the idea is this is the main control panel which is going to be controlling a lot of things and into these smaller worker nodes yes these are known as worker nodes in these worker nodes all the control is being back and forth between the control panel you never ever interact with these worker nodes because they just hold your application all the commands in these worker nodes are being passed on through control panel and yes exactly the cube CTL is the utility which helps us to talk with the control panel that's all that's all we need to understand right now now there are a lot of elements into this that how the agents is being installed and all of that we don't need to worry about all the thing we need to worry about right now at this point is that we talk only to control panel and control panel does this all worker nodes things this is almost like I'm trying to teach you kubernetes in such a way by saying that the sun rises in the East and everybody knows Sun doesn't rise in the east sun is always there the Earth is revolving but we don't introduce that knowledge right now it's not understandable so exactly like that the kubernetes is nothing it has a lot of worker nodes we don't care about worker nodes as of now we only uh care about the cube CTL so the Cube CTL come on Cube CTL so this Cube CTL is the utility which is going to help us to just interact with the control plane and that's all what we have to do okay got it okay we don't care about them so let's go ahead and get rid of that we'll just keep it two of them here so that we know that these are the things okay understandable uh really at this point of time now we need to understand couple of more interesting Concepts which are there and let's go ahead and work on with that first and foremost there is something known as config now why this config is important because whenever we actually go ahead and talk about our application we need to provide a URL to our application that here is a database link you connect with this database and do all interaction there it could be mongodb it could be postgres or it could be anything else so in this case my majority of the problem is that there is need to be a DB URL that I need to provide now in most cases especially when you deploy your application on cloud and something this is usually kept this database is kept into internal Network so where applications lying internal Network the database is there so that the latency is low so that is one of the challenge another challenge in front of me is secrets now these secrets are also known as environment variables now environment variable is something which is common for all developers they try to point their application on certain port a certain key value pairs uh like maybe they want to host things on to S3 bucket of AWS so these all things are kept in the secret mongodb ID and password is also a secret so I need to find a way that how can I keep all of them as a secret so this is my another challenge before I go ahead and talk about kubernetes and all these stuffs so this is my uh well another thing now also I need to talk a little bit about uh deployment as well yes these are terms from kubernetes deployment deployment yeah so this is the deployment and deployment is really really easy it's nothing that is too much to be worried about deployment means simply take my application and just put it into a pod or we saw that as a work or not we'll come back onto these pods and all these what these stuffs are right now as as of now if we just understand that there is a wrapper around our container or our application image somebody is wrapping a part outside of it so that control plane actually can talk with that that's all it is so again no need to repeat that again it's just an image container on which we wrap around a pod so that control plane can talk to it that's all what we do so deployment needs to happen and as you might have noticed this deployment is great but this deployment needs to happen for mongodp so I'm going to go ahead and say mongodb or let's just call this as simply that is fine also so this is where our is and needs to happen or we need to deploy the that's that's what I'm saying as of now so there we go so we got this one and this needs to have uh I guess this yeah better okay so this needs to be happen as a deployment but there is another challenge that although the deployment has happened but right now this deployment is not talking to anybody outside in the mongodb there is a port open same goes for postgres as well and MySQL there is a port that needs to open so that at least the people who are internal in our entire cluster or maybe a VPC whatever it is so in that somebody should be able to talk to mongodb and also if I want to find out hey mongodb what's your name what's the URL where should I access you that is not also like opened up to the world so for that there is another term which kubernetes actually gives us known as service now service is nothing much complicated deployment is super easy we just put that container and make it available service allows us to actually take that deployment and make it available to the world world would not be a correct term to at least the organization that we are having the internal Network that we have and this service exposes all the port in case you have so this is the job of there okay so let's go ahead and do that connection as well so there we go we have a deployment and a service now during this deployment time only we tell the mongodb that hey what are your secrets so this somehow needs to be linked with the secret so that's why we keep this config in which the DB URL comes up and Secret at top so these are almost like a global variable and anybody can refer to them I hope this is now making a lot of sense if service wants to some Town refer to these secrets they can because they are kind of a global if service wants to check or refer something from the config yes they can because they are sort of global variable now same thing needs to happen to our application as well so let me just go ahead copy and paste that and let's go up here and copy that paste that here so same thing needs to go and happen to our web app as well let's call this as web app but it could be anything else as well so this is our web app there we go so the beauty about this is that once I understand that how the deployment of mongodb is done I can actually go ahead and replicate all of this for the web app of course there might be some environment variable that might change of course the image from the mongodb I have to use a different image but you get the idea that it's not too much drastically different and same goes for service as well in the case of mongodb I was opening up the port of mongodb so that and the world can actually go ahead and see that but in the case of web app I have to actually go ahead and open up my port where the application is listening in the case of react app like 3000 is the most common number but this is something we need to share and also this web app needs to be aware of mongodb that hey where can I find mongodb what's the URL of it what is the ID password to interact with that so again yes the point of environment variable also comes up the secrets so that is what the basic is now there is one more last thing that comes up which is something known as a node Port this is a really interesting thing in the world of kubernetes right now all the thing that you are doing so let me go ahead and show you that so right now all the things that you are doing in the world of mongodb uh this is this is happening internally this is happening all inside so far the external world is not aware of it and cannot interact with that for that an additional service is being offered by kubernetes which is known as node pod it's really just a flag that we have to enable now the this can go a really deep and we can just do an entire long video on that but this is the basics of how it is being done so if I go ahead and wrap this up inside this one the note Port is actually something which makes it available for the outside world and that is yes of course we want to do that now we don't want to expose this entire application uh to the external world we simply just want to go ahead and Export this web app to the node Port so that people outside can actually interact now notice here so far it is looking complicated but the advantage that kubernetes gives you is notice right now let's just say we have one of this container as mongodb usually that's the ideal case and this is my worker node for the web app and let's just say a traffic comes up for this web app this entire deployment server is within just one or two line of change I can just go ahead and replicate it now half of the traffic will be managed by this and if I wish more I can just go ahead and replicate this and this will provide me a zero down time I can roll updates to my application and even I can handle my traffic without worrying about anything just changes or configuration changes in the file so good so good and I'm pretty sure this is looking a little bit tiny bit complicated as of now but it is not all we gotta do is work on with the secrets work on with the config and we'll be working with deployment and service one time and then we'll be just copying and pasting it for web app also so this is the advantage of knowing the things once you know the deployment once you can deploy it for mongodb same ways you can go ahead and deploy for web app or maybe postgres or maybe MySQL same way the way you are exposing your services or your ports in mongodb same way you can go ahead and expose them for web app or maybe any other app that you are building in spring or maybe C sharp whatever you like you can go ahead and do that so this makes things easier now yes I understand I have actually opaqued a lot of information from you about kubernetes its control plane services offered and apis and all of that I don't want to bog it down as of now I will surely do it in the upcoming videos right now it's important that we understand this much only so quick summary before we get into practical part we have Cube CTL which helps us to work with the control plane control plane is The Mastermind which helps us to interact with a lot of worker nodes this is a big picture overview of the worker node as of now that we are doing uh so we can have a mongodb and deployment services for one we'll be having web app as deployment and services for one some Global variables so that Secrets can be talked and we also saw that yes we need to install kubernetes but we also need to install minicube to perform these experiments or exercise before we move forward into the course I would like to thank our sponsor rovi and would like to introduce a brief overview about the rovi in this video so first and foremost rovi is available on GitHub you can just check out them onto the GitHub give them a star and show support to these amazing open source projects which are helping a lot to the developers and again open source that means they have earned the trust that how this is all working and there is a guided deployment that how you can work with that I'll show you in some other video later on but right now let me just walk you through what this is and this is clearly mentioned on their website what they do is they actually allows you to interact with your database specially with the Firebase in a much easier and nicer fashion for example we all know that the database given to us by Firebase is super powerful don't get me wrong but the visual aspect can be improved a lot so as you see up here that it offers a lot of 30 types of fields which you can select from the firestore you don't need to just select these fields or add these fields from the code you can just do all of them here and by the way the support for mongodbn post gray is also coming up nicely and then you can just stay on to this and now all of this is going into Firebase and notice here then you can just write your Cloud functions directly and notice here they are using here the convert SVG to PNG you don't need to install it it's already there they'll take care of all of this you just worry about writing your functions itself and whatever the npm packages apis what you want to use they'll just magically take care of that no magic you can read it into your kit into their GitHub as well and this basically is what they do and again I highly recommend to check them out they're really kind enough to help me to keep making more such awesome videos and again go ahead check them out in case you need any help reach me out I'll make another video just on Ruby so that you can understand them a little bit better now again let's move back on to the content all right so this is all what we're gonna do is first and foremost I need to make sure my Docker is up and running so I'm going to go ahead and send the kubernetes first and I'm going to go for the installation part let me just quickly go ahead and see that where the installation part is here it is getting started and learning environment this is exactly it says install Cube CTL and again go ahead and install the cube CTL for Windows or maybe Mac or maybe if you're in Linux go ahead and install that so for Windows it's really simple you can use chocolatey or scoop one single line of installation or you can download the latest release there are a lot of options available all we got to do is make sure we have this uh kubernetes CLI which we call as cube CTL installed all right now before you go there onto that part let me also tell you one more thing that in order to make sure you have mini Cube and all these stuffs in fact let me just go ahead and show you that when we come onto the mini Cube part and we can also go ahead and install this my system also don't have it so I'm going to go out into Apple silicon and I want to install it with the easy way just like there's a chocolatey I have a brew installed Cube CDL as well I'm gonna go ahead and copy this let's fire up the terminal and I want to say Brew install Cube CTL now this obviously is going to take some time probably I need to pause the video or something but in the meantime I would like to also bring you two words another thing which is mini Cube let's go ahead and talk about so it says hello mini Cube and this is where the mini cube is and you can have the mini Cube dashboard let's go ahead into getting started learning environment of course we are learning uh whether you go for let me just close this because we don't need this now we'll check for mac and windows and in both of them you are going to notice that if you look for that hey what is this Cube CTL and all of that it requires some kind of virtualization or containerization uh why I'm telling you both in a different way uh the way how this mini queue works it gives you an entire environment in which the control panels and the worker nodes and as much as you want to spin you can have all of it but it cannot just do it magically it needs some kind of a virtual machine or a containerization environment uh the best one which we have seen for the experiment purpose and what I've personally gone through with my laptop and stuff is the docker environment so if you have Docker installed that means yes all the requirement and prerequisites are done so I'm going to go ahead and fire up my docker and it's going to take just a couple of seconds to fire up my Docker there we go uh don't need tips and all of that and it's going to just take a darker starting now as soon as the docker starts the ideal situation says then only you should start your Cube CTL and mini Cube and all of that these are some of the ones which are from the previous one we don't need to worry about that now let me show you one more thing in the settings if I go ahead notice here the kubernetes is there and you can enable the kubernetes directly from here we don't want to do it we don't want to do it we simply want to keep this up and running so that it shows up at the top that hey Docker is up and running and that is all I need I need to have a Docker installed so we're going to go ahead and cancel that and we're going to just close this one let me bring up my terminal so where is my terminal there we go this one is probably gonna take some time because the Brew is right now installing and updating so let me go ahead and pause the video that in the meantime it just finishes up all the update otherwise we'll be sitting here and talking to each other nothing fruitful so let me go ahead and pause this till the time Cube CTL install and then together we're going to be installing the mini Cube as well that is also a long process all right so yes it took a little bit while to install it but yes we can see that it got installed successfully and everything went okay now same thing happens for you as well maybe you have configured chocolatey scoop wherever you work on Windows so this is all done now the next step obviously is to go ahead and install the mini Cube as well so let's go ahead and find out so this is Cube serial and let's go ahead this should be minicube ah not here still let's go on to kubernetes documentation we want to install the mini Cube hello mini Cube getting started learning environment and we want to install it on the Mac but you can go ahead and follow the guide for Windows as well in case you are on Windows it's really same and again if you are facing installation issues uh we need to check out a lot of your skills as well as your power determination to learn a new topic installation problem is common okay so Brew install uh Cube CDL uh we need to have the mini Cube as well ah this is interesting I I saw this command I'm I saw this Okay so all right not able to see install mini Cube yes I want to learn that and there we go uh to start your cluster we have to go with that so I am on Mac and I am one installed through Homebrew Brew install mini Cube yep really simple command but I wanted to show you through the documentation so let's go ahead and remove that Brew install mini Cube and hit enter now this obviously is a long installation it is little bit of a resource consumption installation as well it requires a little bit of the resource heavy on your system as well but these kinds of installation permission uh this time it was fast probably my internet was a little bit uh faster but this is all what we need now we won't be running any command as of now the max that you probably want to try is just having a cube CTL and dash dash etch or help and probably my bad it's just help and you can see all of that if you're getting a long list of this that means the cube CDL is properly installed you won't be finding any mini Cube command as of now that's a environment so it's not a command line utility that you can find a lot of options on it yes it has some options but we'll talk about that later okay so let's go ahead and remove that all right so we're gonna be keeping this documentation handy because we'll be cheating a lot through the documentation I don't think that should be called as cheating but still okay let me go ahead and fire up my vs code here we go and also let me create a new file on my desktop I'll push this file onto git as well probably or zip it throw it to you as well and we're going to call this one as a cube not really a creative name but you get the point cubemarn okay let's talk about them one by one and you will be understanding and the best part is you will be able to replicate this entire knowledge anywhere that you want okay all right so the first thing that we are going to learn about is Secrets because we are worried about the secrets the most these are almost like environment variable and the way how we are going to be doing it and the way how everybody does it in the world of kubernetes is writing them in the configuration file the configuration files can be written in yaml or Json I prefer my configuration to be in yaml it's much more easier to read less line of characters and less mess around in that and in case you don't know about ml I have created a video already go ahead watch that after this video but right now it's really simple it's just you'll be able to understand everything I'm going to be calling this one as secret and feel free to call it whatever you like I'm gonna call this one as secret uh dot yaml that is the common syntax but the secrets if if they are particularly associated with mongodb or postgres it is common to see this as MySQL Dash secret or something like that I am assuming that my secret is not closely related to just although it is advised that you should create separate files for mongodb secrets on your web app secrets and all of that right now I don't have too much so I'll just call this as secret.yaml again now you know the better conditions and best practices so you can go work with that okay but I don't know how to write the secrets that is the problem so let's go ahead on to the web and call this one that hey how can I write secret I'll search for it and let's go oh not on Mini Cube I wanted to be on kubernetes yeah here we I want to search is Secret and secret command I can write secret there we go and this whole page is going to walk you through that how you can write the secrets so there's a lot of ways how you can write secret as environment variable using secret as file from a pod so there's a lot of ways how you can do it so notice here this is how they write is we can actually go ahead and study this a little bit uh this whole thing is just basic we don't need to worry too much this is a metadata and stuff and then we'll definitely use this that you can provide your environment variable like this a dash that means an array the name what is the name of your secret and then value from you can refer the value from Secret Key reference and we'll be using this so this is one of the many options that we have but if we scroll around there's a lot of ways how you can actually go ahead and do this for example a lot of metadata specs uh a lot lot is there so I'm gonna go ahead and say that use case I want to use case a container environment variable so this looks interesting so API version then a secret then the metadata is there then type O pack so you can research a little bit there are a couple of types how you can mention your secrets OPAC is the best one nobody can seen it see it and the only thing you have to additionally do in the pack is provide your username and password that means the keys and values key could be clear text but the value needs to be encoded as base64 yes not the securest one but the purpose is different here purpose is different so we're going to be using that so all the values that needs to be converted into uh just like that so let's just go ahead and copy this and we'll go back on to our code editor we'll be pasting it all right so this looks good API version is good kind is secret make sure this is exactly that this is important and we're going to be calling this one as it's a secret we have not much so we're going to call this one as secret MySQL secret or just secret whatever you like hey folks uh this is a side note uh that I made a small mistake so in case you don't want to repeat along with me although I have walked you with the debugging process notice here in the secrets I have actually mentioned a metadata as mongodash secret but accidentally in the files like app I have wherever I'm explaining you this environment variable I called this name which where you have to give the file name actually it's a configuration name so I have just mentioned a secret so make sure you edit that as mongodash secret only in the file name that's it let's catch back type is a pack that is fine now let's go ahead and provide a username and password all right so the username for the I'm going to be calling it as user password a really common and for all the tutorial why because it is mentioned in the documentation okay let's just go ahead and say that base 64 n code and there we go this should help us to convert that so we're going to call this one as user feel free to write anything that you like I would say encode and this is the value it gives me I'll copy that value go back and I'll paste this value now it is base64 and we're going to call this one as password and encode that please and this is the value that I got now in case you want to keep your password something different which I highly encourage you to do go ahead and change that now I have put the user and password in the file so that I don't have to remember it again and again I can reference to this file variables and can use it again and again now calling them as a capital username or Capital password is totally up to you I'm gonna refresh that a little bit different so I'm going to call this one as user and this one is going to be Dash password I think we should keep a little bit consistency here mango Dash user would be great doesn't really matter just a variable name so there we go okay let's go back let's see that where we are right now so the problem of the secrets is gone now I do understand I can definitely inject more secrets into this one again the ideal definition guide is keep all of your secrets separate so your web application secret should be web app.secret.yaml bongodb secret.yaml postgres secret.yaml so separate files are always a good idea the next thing is config this is where things actually happens as a magic so what is this config so let me show you by reading the documentation a little bit so there is something known as config map in kubernetes so what is this config map the config map is an API object used to store non-confidential data so this means the secret should not be here it should be non-confidential data pods can consume config map as environment variable great command line argument or as config file this is what we do okay one more line just one more line the config map allows you to decouple environment specific configuration from your container image so that your application are easily portable so what it does is for example let's just say right now you're hosting your entire uh database in within the kubernetes but let's just say one day you decide you want to keep it outside of kubernetes or maybe someplace else maybe mongodb Atlas at that point of time these config Maps makes your life so much easier and yes there are examples as well using config maps and immutables and using how to use config maps and all that a lot of examples are given up here that how you want to use it or how you can actually go ahead and use it so basically what we're going to do is let's just say config map as an object we are going to be using this one uh feel free to copy anything it doesn't really matter I'm going to just copy till the data copy that and we're going to create a config map file so let's just call this one as uh config again the advice is same config Dot yaml and paste it again it's not compulsory to call it as config for only but it could be called for any database or any web application as well the idea behind it is you're going to see mostly available this this config file is available to only for the databases because the database today is in kubernetes tomorrow it might be a standalone entity so that is why it is important now I'm also deliberately skipping some part there is something known as stateful and stateless of the application yes I'm deliberately skipping that otherwise the tutorial will not make sense much to you and will not be easy we'll talk about them in later on so right now this is version one config map is key and very important just like here the secret is important this is a kind of file the file is not determined based on the kind if you call it as config or secret no you can call it superman.h yaml the way how you define the kind here that is what makes the find the file the type of file that you want to interpret it as now metadata we call it as game demo but we're going to call this one as Dash config feel free to call it anything now inside is the data that where actually should I find this so again I told you these are configuration file so mongodb right now is here it could be in the atlas later on so what we're going to say is in this one we're going to say hey this is my Dash URL now this URL uh could be outside or this could be Atlas right now we have nothing so we're going to just keep a remark for ourselves as uh come back here because right now we actually honestly don't know where the URL is why we don't know about this because the URL will be given to us by mongodb the moment we are going to deploy the mongodb and we are going to open it up as a service then the URL will come to us then we'll come back and we'll mark that as a mongodb URL in the config now again you might want to deploy that as here as of now but later on it might be having a different URL different service that might be exposed so depends on based on the use case scenario so we cannot do anything right now let's just move forward and try to deploy the mongodb so deploying the mongodb is really really simple so let's go ahead and work on with that let me get onto code part there we go so we're going to call this one as Dash app dot yaml feel free to call it anything this is my app and I will have also have a web app so that's why I'm calling it one now notice I told you that we need to actually deploy this so yes this is also another kind we need to search for deployment and as I told you deployment is something which once you learn you can replicate that so deployment a deployment provides a declarative update for pods and replica sets I'll I'll tell you what this replica set is simply you describe the desired state in deployment and the deployment controller changes the actual State what is saying you just tell me how many parts you need or how many worker nodes you need you don't worry about it I'll make sure it happens and it works this is the best part about it and we'll see that how the use case actually works you can there are a lot of names here I'm pretty sure you can go ahead and read a little bit about them what I'm worried about is how they actually go ahead and deploy an nginx so that I can study it and I can replicate it for my mongodb I can just go ahead and copy this copy to clipboard go back onto my vs code and paste it all right first of all a lot of spaces is this I think I'll copy this from here because that's actually giving me a lot of spaces which I don't want another base much better much more readable okay so here the API version it says apps V1 uh okay so we're going to keep it as it is so that's what we have copied it's a deployment type Secrets config map yep we have a deployment type then we have a metadata which says the name and it says nginx deployment and it also providing a labels calling up as a key value pair app as nginx okay so far clear that I'll name my deployment something and I'll provide a label for it and label has a common use case in case you are familiar with development label is something which you can keep on referring for in a different part of your file to the same values so yes I get the idea of that then it says spec or specification replicas how many replicas you want remember I told you in here that you can have as many replicas of this web app as you want and this deployment is taking care of it one two or three here it is saying three I want that my mongodb should be just one because right now we are not much aware that we want to use the same volume multiple database some information might be here some not be yes there is a solution of that as well right now we don't want to get into that then it says selector so match label match the label of app which is nginx so yes I get that idea then it says a template okay interesting template also has a metadata which says labels so labels are being used a lot we need to study the labels in a dedicated video it says app engine X so yes I get that this app label is getting repeated a lot of time and then inside the template there is again a specification remember I saw the spec here I saw the spec in line 16 as well and I see that hey this is the container ah this is where the information is so I told you that container is your image and we are wrapping it around with a pod so that our control pane actually can talk about it so rest of all the information about above the spec is all just a wrapper so that it can multiply it or it can reduce it get the point so here you just name your container provide an image and just open up a port for it cool we can actually go ahead and do it so let's try to deploy the mongodb with that so we're gonna go ahead and move on to hub.docker and we'll see uh there let's see hey uh we have a lot of versions of if we go ahead into tags there are a lot of versions of now the six is really popular but we have a 5.0.13 feel free to use any mongodb or even the latest version 5.0 uh we're gonna be going for 6.0 what do you say or we have anything latest uh we can go for latest as well let's go for 6.0 that should be fine or we can go for latest as well but let's go for 6.0 okay let's start with the top by manipulating it I want to don't want to call it as nginx I want to call this one as or mongodb deployment is fine and I'm pretty sure the label should match everywhere so the labels here app mango app Bongo app the name should also be it should be same and consistent everywhere okay so one problem is solved the metadata the labels is consistent the replica is one the selector is always going to match so if it wants to have multiple of containers uh from this template it is going to match the label of to keep a track or maybe increase decrease whatever it does behind the scene and I also have this one being sorted okay good so far the spec we are mentioning the container as so obviously we should use a image so we're gonna say that hey and then simply we have to mention the image so it could be any image you can go ahead and say hey this should be latest this should be 5 this should be 6 whatever makes you happier or makes your application happy we want to go with that now we also are quite familiar and aware that mongodb don't need Port 80 it needs support of 27017 in case you don't know that or forgot that you can always go into overview and look at quick reference in all of these that they obviously mention it somewhere here let me find that 27017 so there we go connect to mongodb from another container you have to make sure that the port is open this is such a common information that you'll find it almost everywhere for for MySQL for post gray for almost everyone all right so this is good so far but we also saw that this is not enough mongodb requires some of the more information especially the environment variables so we need to figure out that how the environment variables are being done it's really really simple we just saw that how environment variable works I will save your time instead of going back into documentation I'll just copy this and I will provide you that we just studied it in fact I'll show you that that we're going to go for secret and let's go for secrets and we're going to say that I want to have a use case of visible to one not visible container variable there we go so notice here in the container we have this name not here we should be having it somewhere we just saw it and let's just say Secrets it takes sometimes a little bit time to find out and we have to provide it as let me find that and EnV and we have zero matches for this one using secret as variable yeah here it is so notice here we can remove this now we have this environment and this is exactly in the container so just like we have the name image we have this environment and we can provide all these values so optional is false we're not going to copy this let's copy this and try to read it so we have opened up this container but we also need to send some of these key value pairs as environment variables so let's go ahead and hit enter and this should be right in the indentation level of where the ports and everything that you have mentioned so we're going to just keep it there and obviously this is going to create a problem for us so we're going to go ahead and provide this up here let me just indent them all right long videos take some time okay let me just indent them so notice here I told you that inside the container we are providing the name that is correct the indentation look at the indentation of the name and look at the indentation where the ports are so inside the container we are providing this name and all the all these things similar to that we should also provide like the port is being provided the environment is provided but the problem is ports and environment are at the same correct indentation this one is not so just select all of them and press Ctrl and the square bracket or command and square bracket it will move the indentation small hacks but you should know about them okay now the first thing is environment name let's first sort this out by going up here it requires this one we actually copied the wrong ones in the docker example I updated it later on uh but I hope you remember that so we're gonna just copy this paste that okay so my variable name is initial root username okay where should I get this value you should get this value a from the secret key reference and yes there is a way of getting a reference from config map file as well remember the kind is always defined from here config map so here we are saying secret so secret we are saying hey get the value from Secret Key reference so this is how the kubernetes works okay we're gonna get that and now all we got to do is provide the name as well as the key value the name is the name of actually the file so we have called this file as not as my secret but just as secret that's all whatever the file name is go with that all right what is the key that you have used in the secret I have used the key of user okay I hope that's a very replicable information so use this key that's all that's all we have to do so notice here I was able to tell all of this from the secret nobody knows it now all right so this is the first environment variable that we have given now we need to obviously give a second environment variable so just duplicate this and we need to go back here password copy that and here is my password take the value from Secret Key reference the name of the file is secret and that is why we call them as secret web app secret postgres secret so it is much more clear in the spec file now after this we're going to go ahead and say hey what's the key that you have used there okay I can tell you that it's the password all right password all right so this is the basic this is all what we got to do is have this one all right so I hope you now are aware that so much we have achieved Secrets config we don't have this debut URL uh we'll get that later on bongodb the deployment part is done let's go ahead and work on with the service part and I told you that this service part and deployment thing is common for so there are a couple of ways how this is being done the first one is easy you go ahead and triple dot triple dashes and then start writing your services file here this means the break of the yaml file or sometimes you're gonna see in bigger of the companies bigger scalable products that these are kept as a separate one but in that case the naming convention is also very clear and in the folder as well all the secrets of goes into one folder all the config goes in one folder all the deployment related information goes in one file and in one folder and the services also go there but we're gonna keep them as it's a small app so we're going to just keep them in one file but feel free to keep it in another file no problem at all the common convention is to keep them in the same file let's go ahead and see what's there into service so the next notice here the service is remaining so here is the service okay let's see and study what's the service does an abstract way to expose an application running on a set of PODS as a network service okay with kubernetes you don't need to modify your application to use an unfamiliar Discovery mechanism so what happens is in the way in the kubernetes the pods keeps on dying and kubernetes get them back now when the Pod gets back up it gets its own IP and every time finding that IP could be really challenging so for that the services actually comes into the picture once you enable or stick a service to a pod or to a configuration it simply says hey if the Pod dies and come back again I really not worried about I just talk to service service discover the pods and all these things I don't really care that's what exactly it is saying this probably might be getting you that yes I'm understanding kubernetes now but I need to dive deep into theoretical part as well yes we'll do that as well now kubernetes give their ports on IP address and a single DNS name for the set of PODS and can be load balanced so yes theory is required but you get the basic idea that a service is required for deployment so that we don't hunt for IP and all these things and this is basically your service really tiny and cute and this is what we'll be doing so there we go API version we don't care we copied it from the configuration as the kubernetes says important is the kind so yes this is a service the metadata whatever you want to call this one as you can call it as my service service whatever you like to call this one I would simply like to call this one as service that would actually make sense Dash service ah this reminds me something that hey we didn't actually fulfill the config here because we didn't know the URL and now we are now aware of the service that hey it's not the IP that I have to hunt I can just refer here as service and it will be available so yes that's the name of my service and as the config file you just go ahead and look for service told you really simple really easy now in case any other application is also looking for some URL or some way to interact with that container or the service you can use the services here all right now spec is selector what should I select now in this case we're going to select based on the key value pair this is really interesting and something that you should know now notice here right now this could be in its own separate file so it has no idea that hey here in the diagram you're telling me that this service needs to be attached to mongodb deployment but right now this is a standalone file it has no idea how should I do that in that case these selectors are useful and we actually worked on these selectors here selector match label app so we should call this exactly that so we're going to call this one as so hey now you are attached the service is attached to the deployment which is of and the ports on which Port you want to interact yes of course TCP but we know that the Target Port this is the Target Port container copy that and paste that so if any application wants to interact with that I told you again many times your application container wrapped around some of the functionality pods and now it can interact so from inside you have said that hey everything I'll do is on Port 27017 outside you are interacting with that but for the world or for your application to interact you need to have the same port now it's not compulsory to same port but your application usually in the database connect with that but you can call this any port that you like no such compulsion having same port good thing but you can change it so notice now I am completely aware that how can I actually bring this up pretty easy in case I have any of my other image I can just change this image very repeatable task that I have achieved okay so you have achieved this much mango deployment service web app and all of that now the next thing that in front of me is deploying my web app now your web app could be any app that is deployed on uh Docker maybe your container from AWS wherever you like I am going to deploy a web app which is Express and I'm going to be using this Express for that and for this what I can do is this is my app but now is going to come up is my web app web Dash app of course Dot yaml and I hope now you can already see that coming that this is almost like a replica except this node Port which we are going to talk about that but this is a repeatable information if it is a repeatable information we can actually go ahead copy this and paste it into web app yep that everybody does that all devops do that but it's not like the Mindless copying we obviously go ahead and study it and do this one so we already saw that metadata it should not be it should be web app so that actually makes sense so if this label is a web app the label should also be a web app so we are calling it as web app deployment let's call it as web app the spec how many replicas you want one two three all of them are going to be connected to the same database so load balancing can be done with just by changing a number you get the idea how this could be done I'll keep it one but you go ahead and try it play with the two or something selector how should we select with that select with web app this time match the labels of web app in the template also the metadata label should be calling it as web app that should be done here comes the container so container wrapped around the Paw or the Pod is wrapped around the container inside yep that's exactly what this is we're going to call this as name as Dash Express and we're going to be using the same thing here as well so we're going to call this one as Dash Express and we'll be using a latest I really don't care which one one you use alright the port now this application actually doesn't run on any port we need to see this port up here so if I go up and look at here this actually is a application which runs on Port 8081 so I have to open up that exact port for this application which is 8081 your poor your application might be listening on Port uh three thousand four thousand which one makes sense now I have to provide these environment variables all right all right so we know that a couple of environment variable needs to come up so let's go here the first couple of them is obviously there is a config server this is something we haven't seen but this admin username and admin password we have seen so we're gonna see this hey copy this this is your environment variable name and you have to get the value from the secret the name is going to be of the file is Secret of course it's not actually a file name it's actually a kubernetes reference it's usually with the file name also but again we need more Theory and the key is user so use that whatever that is okay all right super easy the same is for mongodb password copy that and this one is password but there is one more of a variable which might create a little bit of the issue for a beginner because now we have to provide a server reference as well that hey where this server is actually going on or how we're going to get that information copy that the first easy thing is another environment variable that means another value okay but this doesn't need to come from the secret it needs to come from the config file so the rest of the values will remain same that value from you have to get it but instead of calling it as a secret key reference we're going to call this one as simply config map and map and yes this is exactly the proper name of it secrets are called secret but config is called as config map so config map key reference what is the name of your config so we call it as config uh really not the friendly we should call it as just config but you get the idea we're going to call this one as Dash config so it's just a basic file name hey take the value from the config okay I'll do that I'll go into config and then the key is URL great I'll come back and take the key off Bongo URL you get the idea how the application actually connects so there we go we have actually done with the deployment part but there is one more thing which is remaining which is service we haven't opened up our application yet so that it can be exposed to the entire world okay so this is API version will remain same service remain same we let's just call this one as web app again the same problem comes to this one as well to whom I'm attached with I'm a service but I need to attach with some deployment who is that deployment that deployment is web app and we can go ahead and use a selector remember the selector is web app so we'll copy this the reason why I'm copying it from a special place so that you know where I'm referencing it all right okay so uh we call this one as metadata as oops my bad it should be called as web app talking and working at the same time could be challenging you get the idea so web app service selected is web app okay all right now the ports to be opened up TCP Port great but my port is not this one it is uh 80 81. the Target Port remember the Target Port is coming up from here this is the container Port I'm targeting I could have written that but I want to show you the linkage okay now there is one more thing now this application currently is open up for internal Network this whole big thing your database your container all inside it but you want to access this outside of the world can do it right now for this you need to understand the concept of node Port Port so node port in the kubernetes services notice here there is a node Port so we'll just look for it that where is this note Port is thing so there are end points and there's a lot of things you can study and read surely we will study them notice here this is how they are saying that hey this is your client your cluster IP your backend all this there's a nice diagrams there are a lot of nice diagrams what I want to search for is node Port so there we go and I'll just look for another one there we go publishing your service it says note Port exposes the service of each node IP at a static Port the node port to make the node Port available kubernetes set up a cluster IP address the same as if you have it requested as a service type of cluster IP so if you don't set it anything it's a cluster IP but the idea is cluster IP is only available to you it's a internal Network to expose it as outside you have to go for this and another thing is this node Port you cannot actually go ahead and set any port on this one they are saying as threes triple zero seven so node Port doesn't work on any port as well there's a specific range of ports as well let me go ahead and find out that there we go uh you have to provide a range from three uh this many zeros and then three two seven six seven so this is the only Port range that you can expose your application to outside then from outside you map it up to any domain name or any port that's up to you so we're gonna go ahead and work on with that so we are going to go ahead and say that I want to Define one more of this which is node port and remember this is how they are writing Port Target Port note port and this is what we are doing noteboard and let's just call this one as three zero two double zero whatever whatever makes sense or you can just use exactly this one a lot of people use this one because this is also mentioned in the documentation and that's what we do all right okay a lot of configuration that we have written but this is all what V is required in case we haven't done any typo this should be all to deploy any mod application the advantage is now it's very replicable and you can create so many of these configuration files for so many of the micro services and whole lot of things just one configuration file then deploy maybe uh you want to go for 100 container you can just go ahead and say Hey I want to have 100 containers of my application it will scale it up you don't have to do anything at all so that is the advantage of it but now uh coming back on to the commands uh so we're going to be using a terminal on this one and where is my terminal let me go ahead bring that up here we go so we have installed all these things hopefully they had installed properly now the first thing that we're going to go ahead and do is a mini Cube and we're going to go ahead and start this now mini Cube starting takes a little bit time because it goes ahead onto internet and downloads and pull off some of the base images because everything is containerized if we would have deployed it outside in the cloud or something then it's not mini Cube It's actually an actual machines one of them act as a control plane other one works as a worker node but the advantage is you install kubernetes on just the cluster plane and just give it the point of the machines that here are going to be machine which could be your worker nodes and it deploys the container in all of them of course why Cube CTL but we don't interact with the worker nodes much so this is all it's going to take and shouldn't take much of the time depends on my internet speed but let's give it a try probably all right still gonna take some time so let me just go ahead and pause this all right it took some time it took some time but I hope you can see what all has happened when we said hey mini Cube start we installed it at that time nothing much happened we just got the utility but when we started it gives us a lot of big container which helps us notice here using Docker desktop driver because I didn't have any other virtual machine or something so it used my inbuilt Docker to containerize everything and then it downloaded a kubernetes which is pre-loaded okay that's great now it also created a Docker container CPUs took two without even asking me and a good chunk of memory uh yeah it's it's a decent memory it also generated some control planes and Gnar back rules and all of that will not go much in detail of that remember sun rises in the East okay great so we have now this and that is it that is all we do from here we will not be interacting much with the mini Cube now because it has given us a cube CTL and I told you in the earlier time as well that all we got to do is enter act always and always with cubectl not with mini Cube it's just an environment that was given to us now Russell things we'll be doing from the vs code itself because all of our files actually are here and we don't need to travel to this directory and a good thing is vs code gives us an inbuilt terminal so let's go ahead and work on with that in fact we can go full screen all of this okay all right so let me go ahead and open up my terminal first so that we can have some bigger fonts in the terminal you can see that so terminal and the terminal should have some of the font just give me a second it is good for you uh so that we can have terminal font terminal here we go terminal and all right so now that we have a bigger font in the terminal took a little bit while but we can go ahead and get started so mini cube is running up and running at this time and all we got to do is always interact with the cube CTL and the next that we have to do is simply just ask cubectl that how many pods you are running remember I told you pods containers Big Unit yeah just like that so we're going to say and ask this hey just give me get pod and that actually gives you all the Pod right now there is no resource because we haven't created one the way how you create a resource is a step-by-step manner the first is obviously dump up your secrets and config because I told you these are Global ones the way how to do it is just simply say Cube CDL and then you simply say apply apply is the most humongous command in the cube CTL it does majority of the work for you and we're going to say Dash F to give it a file name the first we want to go ahead and just go provide the secret.yaml Now the secrets are being created told you really really simple after that and then same apply command now let's go ahead and dump our config these we call as Dash config called it anything just a file name told you and yep config is created now let's create mongodb because our application is dependent on that so let's go ahead and call this one as app so Dash app.yaml and notice here it created a deployment and service if this would not be a separate file I would have first given it a deployment file and then a service file really simple and then once this is all being done I'm gonna go ahead and say that hey now this is done so go ahead and say web app.yaml I create I say that hey just create one replica of it if I would have say two three or more it would have created more of these parts so it says web app service is invalid so spec Port node Port forbidden may not be used type as cluster IP so there's something wrong so obviously there is a typo in this somewhere so let's go ahead and work on with the web app so web app.yaml let's see that where we are going wrong and this is the good part of it that it tells you all these things in advance so three zero now let's try one double zeros so that is node Port ports should be all good now and we call this as web app service and what's the name here uh web app deployment and yeah that should be all good let's go ahead and try this out probably I mistyped the port or something web app service is invalid okay let's see that where we are actually making the mistake okay let's first try to run this again one more time if this works and it says no spec dot Port is forbidden let me just go ahead and debug this quickly all right found the bug uh it was something that I missed actually uh so it's really simple just about the selector we actually missed it out during the documentation we were told I never talk uh that here in the spec there was a type of node Port that we have to mention otherwise the default is cluster IP but again no big deal happens with the best of us so there we go we have got this one and selector uh just it should be on the same indentation level so I just saw it here so so selector and then here it is so selector we should actually make it above the selector my bad there we go so we have to mention the type as node port and then you can provide this information and again I check the case sensitivity twice again before going with that so you get the idea okay no big deal let's go ahead and try this out and there we go finally we have got the deployment and the service being spent off okay uh no big deal we have gone through with that we have created all these things now let's try how many parts we actually got so the same command we can just hit the up up Arrow key couple of times and get pod and notice here we are getting the Pod of deployment web app deployment and the sum of the unique IDs with that now by the way you can actually provide this option which is really really handy option of Dash o and wide this is really a common option that you want to get more information so you provide this Dash o wide I have bumped up my font that's why this actually shrinks to the next line uh usually we want smaller font bigger terminal so that we can see all of them in one line so that is better opportunity there okay uh you can also get anything right now we have get got the Pod but you can get anything for example instead of the Pod you want to go for secrets so we are going to go ahead and say hey give me all the secret so there we go and it gives you a secret that hey here is a secret opaque type the data is 2 because we store two values into it and you can also go ahead and grab config map so we can go ahead and say config map and the config map is going to come up this is default it's a certificate that is provided by minicube uh we will talk about that later on so the config is available up here and you can also go ahead and say get services so we're gonna go ahead and say Cube CTL get SVC and it gives you all the services kubernetes is running Services running and web app is running the entirety of the kubernetes is running on this port so that is the basic of it now the only command that sometimes you are going to see uh with the mini cube is or is to get the IP so we can go ahead and say minicube and IP uh this gives you the exact IP that where this entire mini cube is running and this is sometimes important to make sure that we listen to our app but there is a catch here in the recent update of this mini Cube although everything is up and running we don't have any problem and we can just look for it notice here our application is listening on Port 8081 I can go ahead copy this move back here and I go ahead and say hey this is 8081 uh you won't be listening anything this all has to do is how minicube has updated itself in the recent days and you know in order you want to expose this application and really want to check it out on your local machine because minicube is all about local there is a new command that minicube actually gives us is what service you want to really expose it although we have given the node port and stuff that is still compulsory but you have to clearly mention this mini Cube that hey this is the service I want to really see what is happening at that service so for that the only command that you have to take through is mini Cube and then have to say service and notice here there is a lot of things going on you have to mention the service name in this case my service name is I can graph from here after getting SVC copy that and we'll be saying paste that once you do this hit enter now notice here this is starting this it will it is going to open this up as a default now it will open this up now this is opening up on any port this doesn't really matter this is how you actually get your application now it says Docker drivers and all of that so this is starting a tunnel to my application on the same port three one double zero and whatever it is redirecting it on to my this URL and there we can actually go ahead and use that so right now this is not working probably I have done some mistake in that so let me go ahead and fix it and see where the problems are actually there all right so after a small debugging and the session is up and we are able to deploy our app let me show you where I made a mistake and this was an honest mistake I actually did it uh this was not intentional I actually forgot to discuss a little bit about why we are having this metadata we are going to discuss about them in the upcoming videos but metadata is something which is almost you can compare with the class name so whenever you have built any application you write your class name and you export the FI that class name it doesn't really matter what your file name is and same I was trying to show you but actually that skipped my mind so we call this as mongodash config in the config and we call this as metadata as config same goes here as well in the secret we called it as secret that is actually the file exported name but we call it as secret so in the talks I actually went up and just call this one everywhere as just the secret just the secret shouldn't be doing that the name of the file uh the meaning that what I wanted to come conveying that is by the term saying that the file name it is a configuration created inside the cube CTL or the kubernetes what are we going to call it I thought I just said uh we are I just thought that we are writing it as secret but we actually wrote it as just secret so the actual reality is we should be calling this secret reference as Dash secret only reason for that is because in the secret we are calling it as metadata secret if we would have called it as just the secret and nothing like that it's the configuration name is secret so that is the mistake that we did once I fixed up the mistake I flushed it all out I removed all the deployment everything I'll show you how to clean up that as well in a minute and that is the mistake that we did I am pretty sure you are also going to do that the Honest YouTube videos where I don't hide my mistakes I in fact show you so that you learn the debugging process all right so this is the basic and we're gonna work with that so let me show you that how it actually went up and let me show you the commands actually to remove all of this as well well rest of the commands are same and in fact I'll write all these commands in our text file so that you can also learn more about it the way how you actually remove all of the things first you need to learn about that so we have to say is Cube CTL and then we have to delete all the things so just say delete and let's just say you want to delete all the deployments so this is a you should not be doing this into a production environment but here we are just doing it so let's just say we are removing all the deployments so we're going to say dash dash all and then it will remove all the deployments similarly we can go ahead and say Hey I want to remove all the service we're going to go ahead and remove this service and similarly we can go ahead and say I want to remove a secret so it will remove all the secret just like that and remember notice here what it's removing is secret I'll walk you through all these things just in a minute we'll focus more on the command output this time as well what else we have config Maps so we're going to say config map there we go now let's go ahead and deploy it one more time so that we have fixed the bug and again hope everybody remembers the bug was really simple in both the files web app and in the app we were referring to the file as just the secret but we should be referring it as secret the reason for that is in the secret file we are providing a metadata as secret so again the reason why I'm telling you all the theory that how I was able to catch the bug because it will happen to you as well and once you understand the process and see the bug that's where the experience counts so let me go ahead and run this so our Cube CDL is up and running we need to apply so first and foremost we go ahead and say Cube CTL we want to apply and dash F the first file that we're providing is secret and notice here it is creating a secret with the name of Dash secret so this should be referred everywhere and that is the mistake we kind of skip through it so but anyways you get the idea now the next file that we want to apply is the config map feel free to call it anything we are going to call this one as mongoose config that is the file name but surprisingly or just a coincident that in this case we created a metadata as config as well but this file name could be Superman Dash config all that matter is metadata it's almost again same example class that you are exporting all right and then we go ahead and apply for the so app so we're going to say Dash app and we apply that so notice here deployment and the service they also have their metadata so the deployment we call this as deployment this one is service but we could have called it anything in the metadata similar to this we are going to have our web app so we're gonna go ahead and call this one as web app.yaml and again all we got to do is get a mini Cube IP but the same problem remains so many Cube IP we although get this IP and our Port is listening on wherever web app is listening on in this case it's listening on 301 double zero two double zero whatever we have mentioned so I'm going to go ahead and just copy this and if I go on to the browser uh on Port 30100 it doesn't listen to this on on this port still but if I go ahead go back and try to run the same command remember I told you about this command that is recently being updated in the minicube which is expose the service whichever the service you want and we just find out that we call this one as web app dash service by the way in case you don't want to get it or don't know how to get it all you can do is just ask Cube CTL that hey get node and can Dash o a wide onto this one so notice here all this is not readable this is not readable uh but again we can actually get all the Pod that would be I think better get the pod there we go so we have the web deployment and the deployment and similarly you can get the service so let's just go ahead and get the service uh Cube CTL get SVC and there we go so the service that is we want to access is the web app service copy that and then we can go ahead and say Cube mini Cube my bad mini Cube service and we want to get this service up and running and once you do this this actually creates a tunnel and this time we're able to login into database and we can go ahead and create a new database and we can actually interact that so your web application is done so I hope you got the idea that how we were able to debug it and actually solve this problem I'll actually add that as a side note in the video itself so that less people actually face this problem in case those who don't want to experience the debugging but this is the most important part debugging is the most important part so I hope you get the idea that how we can deploy the merred app directly into this but this also brings us our interest into kubernetes that why knowing about metadata is important why knowing about the node Port is important why knowing about the services deployments Secrets config map there could be more services that are offered right now for merlap these much are required so we got the idea of it but maybe there are something else maybe you want to deploy the DNS also so there could be more maybe you want to roll out an update so how to do that and how to achieve that that is where the kubernetes actually comes into the picture I hope while this video I have given you enough of curiosity that you can hit that subscribe as well as can read and learn more about kubernetes that was the goal that is it let's go ahead and catch up in into the next video thank you so much
Info
Channel: Hitesh Choudhary
Views: 68,197
Rating: undefined out of 5
Keywords: devops, cloud, docker, kubernetes, pods, minikube, kubectl
Id: 7XDeI5fyj3w
Channel Id: undefined
Length: 82min 50sec (4970 seconds)
Published: Wed Nov 09 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.