Your First Real Kubernetes App!
Read full transcript 18 segments
-
When you're starting to learn When you're starting to learn Kubernetes, it's super important to Kubernetes, it's super important to Kubernetes, it's super important to start building projects that are start building projects that are start building projects that are actually tangible, that do something, actually tangible, that do something, actually tangible, that do something, that that create something, that are that that create something, that are that that create something, that are useful, because that is what makes useful, because that is what makes useful, because that is what makes learning fun. So many courses on the learning fun. So many courses on the learning fun. So many courses on the internet do it wrong because they just internet do it wrong because they just internet do it wrong because they just make you deploy a random engineext pot make you deploy a random engineext pot make you deploy a random engineext pot or a busy box pot that doesn't do or a busy box pot that doesn't do or a busy box pot that doesn't do anything and that doesn't give you any anything and that doesn't give you any anything and that doesn't give you any of the fun reinforcement learning that of the fun reinforcement learning that of the fun reinforcement learning that you should have when you're learning a you should have when you're learning a you should have when you're learning a new skill. So I design my learning new skill. So I design my learning new skill. So I design my learning materials differently and I'm going to materials differently and I'm going to materials differently and I'm going to be starting a series of videos where be starting a series of videos where be starting a series of videos where we're going to be deploying applications we're going to be deploying applications we're going to be deploying applications on a beginner level. So in this video on a beginner level. So in this video on a beginner level. So in this video we're going to be deploying LinkedIn. So we're going to be deploying LinkedIn. So we're going to be deploying LinkedIn. So I've been running LinkedIn for well over I've been running LinkedIn for well over I've been running LinkedIn for well over a year now. It's running on my a year now. It's running on my a year now. It's running on my Kubernetes home lab cluster and it's Kubernetes home lab cluster and it's Kubernetes home lab cluster and it's available from the internet on my own available from the internet on my own available from the internet on my own domain and it is a super simple welldone domain and it is a super simple welldone domain and it is a super simple welldone application where you can just you have application where you can just you have application where you can just you have a browser extension for it. you have a a browser extension for it. you have a a browser extension for it. you have a CLI for it. And if I just want to add my CLI for it. And if I just want to add my CLI for it. And if I just want to add my CubeCraft DevOps community to my CubeCraft DevOps community to my CubeCraft DevOps community to my bookmarks, I just click add bookmark, bookmarks, I just click add bookmark, bookmarks, I just click add bookmark, add the URL, and then it gets the add the URL, and then it gets the add the URL, and then it gets the description, everything. So, it's saved.
-
description, everything. So, it's saved. description, everything. So, it's saved. And then here you go. Here's my LinkedIn And then here you go. Here's my LinkedIn And then here you go. Here's my LinkedIn bookmark. Now, this is great because I bookmark. Now, this is great because I bookmark. Now, this is great because I tend to switch browsers a lot, tend to switch browsers a lot, tend to switch browsers a lot, especially with what's going on with especially with what's going on with especially with what's going on with Firefox recently. So, I'm now back on Firefox recently. So, I'm now back on Firefox recently. So, I'm now back on Vivaldi, and I didn't have to export and Vivaldi, and I didn't have to export and Vivaldi, and I didn't have to export and import my brow, my bookmarks all the import my brow, my bookmarks all the import my brow, my bookmarks all the time. And when I'm visiting a friend and time. And when I'm visiting a friend and time. And when I'm visiting a friend and I can just open my phone, navigate to my I can just open my phone, navigate to my I can just open my phone, navigate to my LinkedIn and just share a bookmark that LinkedIn and just share a bookmark that LinkedIn and just share a bookmark that I wanted to recommend to him. For I wanted to recommend to him. For I wanted to recommend to him. For example, last camping season, I know I example, last camping season, I know I example, last camping season, I know I stored a tent here. And if I just click stored a tent here. And if I just click stored a tent here. And if I just click on the tent bookmark, then I Oh, yeah, on the tent bookmark, then I Oh, yeah, on the tent bookmark, then I Oh, yeah, here it is. This is the tent that I was here it is. This is the tent that I was here it is. This is the tent that I was planning to get this year. So, it's planning to get this year. So, it's planning to get this year. So, it's super useful that this is now stored on super useful that this is now stored on super useful that this is now stored on my HomeLab cluster separately and I can my HomeLab cluster separately and I can my HomeLab cluster separately and I can just switch browsers and it's just fun just switch browsers and it's just fun just switch browsers and it's just fun to have your own self-host application. to have your own self-host application. to have your own self-host application. So, LinkedIn is is great for this. And So, LinkedIn is is great for this. And So, LinkedIn is is great for this. And in this video, we're going to be in this video, we're going to be in this video, we're going to be learning how to deploy this on learning how to deploy this on learning how to deploy this on Kubernetes. So, I have a K3D Kubernetes Kubernetes. So, I have a K3D Kubernetes Kubernetes. So, I have a K3D Kubernetes cluster running in a container, and I cluster running in a container, and I cluster running in a container, and I will make videos in the future about will make videos in the future about will make videos in the future about K3D. But what you should have is um K3D. But what you should have is um K3D. But what you should have is um Rancher Desktop. I recommend that to run Rancher Desktop. I recommend that to run Rancher Desktop. I recommend that to run your first Kubernetes cluster. I have a your first Kubernetes cluster. I have a your first Kubernetes cluster. I have a video on that on my channel that you can video on that on my channel that you can video on that on my channel that you can find when you search for Rancher Desktop find when you search for Rancher Desktop find when you search for Rancher Desktop on my channel. and um or or just any old on my channel. and um or or just any old on my channel. and um or or just any old Kubernetes cluster that you have access Kubernetes cluster that you have access Kubernetes cluster that you have access to. That's all you need for this to. That's all you need for this to. That's all you need for this tutorial. So, LinkedIn runs in a tutorial. So, LinkedIn runs in a tutorial. So, LinkedIn runs in a container, but they don't necessarily container, but they don't necessarily container, but they don't necessarily include include include Kubernetes instructions. They they'll Kubernetes instructions. They they'll Kubernetes instructions. They they'll have Docker instructions, but they won't
-
have Docker instructions, but they won't have Docker instructions, but they won't show you how to run it on Kubernetes. show you how to run it on Kubernetes. show you how to run it on Kubernetes. And this is why these selfhosted And this is why these selfhosted And this is why these selfhosted applications are such a fun challenge applications are such a fun challenge applications are such a fun challenge because they usually don't have helm because they usually don't have helm because they usually don't have helm charts and they don't have instructions charts and they don't have instructions charts and they don't have instructions for Kubernetes. And this is why it's so for Kubernetes. And this is why it's so for Kubernetes. And this is why it's so much fun to do it yourself. So when you much fun to do it yourself. So when you much fun to do it yourself. So when you um have your Kubernetes cluster up and um have your Kubernetes cluster up and um have your Kubernetes cluster up and running then we can start by uh setting running then we can start by uh setting running then we can start by uh setting up the application as a deployment. Now up the application as a deployment. Now up the application as a deployment. Now I have prepared some YAML here and I can I have prepared some YAML here and I can I have prepared some YAML here and I can go to my application here. First of all, go to my application here. First of all, go to my application here. First of all, let's just create our namespace. So I let's just create our namespace. So I let's just create our namespace. So I will create create NS will create create NS will create create NS LinkedIn. And if I do k get ns, now I LinkedIn. And if I do k get ns, now I LinkedIn. And if I do k get ns, now I have my LinkedIn namespace. Now I want have my LinkedIn namespace. Now I want have my LinkedIn namespace. Now I want to be able to do everything in the to be able to do everything in the to be able to do everything in the LinkedIn namespace without having to LinkedIn namespace without having to LinkedIn namespace without having to specify the namespace all the time. So specify the namespace all the time. So specify the namespace all the time. So what I will write is the k config set what I will write is the k config set what I will write is the k config set context nameace linkeding. context nameace linkeding. context nameace linkeding. So if I do k get pods now it will say no So if I do k get pods now it will say no So if I do k get pods now it will say no resources found in the LinkedIn resources found in the LinkedIn resources found in the LinkedIn namespace. So anything I'm going to be namespace. So anything I'm going to be namespace. So anything I'm going to be doing applying is going to be happening doing applying is going to be happening doing applying is going to be happening in the LinkedIn namespace which is a in the LinkedIn namespace which is a in the LinkedIn namespace which is a great little great little great little tip. And I'm going to open create a new tip. And I'm going to open create a new tip. And I'm going to open create a new deployment.yaml file. Oops. And then I'm deployment.yaml file. Oops. And then I'm deployment.yaml file. Oops. And then I'm going to copy over the YAML that I have going to copy over the YAML that I have going to copy over the YAML that I have prepared. Paste that in. Here we go.
-
prepared. Paste that in. Here we go. prepared. Paste that in. Here we go. This is the YAML file. So let's walk This is the YAML file. So let's walk This is the YAML file. So let's walk through this. I have my API version one. through this. I have my API version one. through this. I have my API version one. Kind is deployment. We're not doing it Kind is deployment. We're not doing it Kind is deployment. We're not doing it as a separate pod because we maybe want as a separate pod because we maybe want as a separate pod because we maybe want to scale it up later. The name of the to scale it up later. The name of the to scale it up later. The name of the deployment is linked in. And we're going deployment is linked in. And we're going deployment is linked in. And we're going to be running it in one replica. Now the to be running it in one replica. Now the to be running it in one replica. Now the the label of the application is going to the label of the application is going to the label of the application is going to be linked in. And then we define the be linked in. And then we define the be linked in. And then we define the container that we're going to run. I'm container that we're going to run. I'm container that we're going to run. I'm calling this LinkedIn. and the image is calling this LinkedIn. and the image is calling this LinkedIn. and the image is sysbuker LinkedIn sysbuker LinkedIn sysbuker LinkedIn 139.1. Now, in order to find the latest 139.1. Now, in order to find the latest 139.1. Now, in order to find the latest version, because I did that mistake um version, because I did that mistake um version, because I did that mistake um intentionally, you can go to the GitHub intentionally, you can go to the GitHub intentionally, you can go to the GitHub repo, Sysbrooker LinkedIn, and then you repo, Sysbrooker LinkedIn, and then you repo, Sysbrooker LinkedIn, and then you check out the releases here. And now check out the releases here. And now check out the releases here. And now here we see that actually the latest here we see that actually the latest here we see that actually the latest version is version is version is 39.1. So, I'm going to change this and 39.1. So, I'm going to change this and 39.1. So, I'm going to change this and I'm going I'm going I'm going to get the latest version. And then to get the latest version. And then to get the latest version. And then finally, there is this block called finally, there is this block called finally, there is this block called container port here. So this means that container port here. So this means that container port here. So this means that I'm exposing LinkedIn on the on port I'm exposing LinkedIn on the on port I'm exposing LinkedIn on the on port 1990. The port the container port. So 1990. The port the container port. So 1990. The port the container port. So the port that the container is going to the port that the container is going to the port that the container is going to expose is port 1990. This is important expose is port 1990. This is important expose is port 1990. This is important when we're going to do port forwarding when we're going to do port forwarding when we're going to do port forwarding afterwards. So if I now apply this k afterwards. So if I now apply this k afterwards. So if I now apply this k apply f apply f apply f deploy.l my deployment of linking is deploy.l my deployment of linking is deploy.l my deployment of linking is created. So let's check out k get pods.
-
created. So let's check out k get pods. created. So let's check out k get pods. Yes, it's already running. So, if I Yes, it's already running. So, if I Yes, it's already running. So, if I describe that describe that describe that pod, we see that everything has worked pod, we see that everything has worked pod, we see that everything has worked well. It has started. It has no volumes. well. It has started. It has no volumes. well. It has started. It has no volumes. We're going to get into that a little We're going to get into that a little We're going to get into that a little bit later. And there is nothing um there bit later. And there is nothing um there bit later. And there is nothing um there are no failed events or anything like are no failed events or anything like are no failed events or anything like that in the pot, which is great. So, now that in the pot, which is great. So, now that in the pot, which is great. So, now we need to um connect to this pod, we need to um connect to this pod, we need to um connect to this pod, right? Well, and before I go into that, right? Well, and before I go into that, right? Well, and before I go into that, I just wanted to uh let you know that if I just wanted to uh let you know that if I just wanted to uh let you know that if this went a bit fast for you, if this went a bit fast for you, if this went a bit fast for you, if deployment is still magic for you, if deployment is still magic for you, if deployment is still magic for you, if these ports and port forwarding, if you these ports and port forwarding, if you these ports and port forwarding, if you don't really understand what that means, don't really understand what that means, don't really understand what that means, then I highly recommend that you jump then I highly recommend that you jump then I highly recommend that you jump into my CubeCraft DevOps community. In into my CubeCraft DevOps community. In into my CubeCraft DevOps community. In there I have a Kubernetes fundamentals there I have a Kubernetes fundamentals there I have a Kubernetes fundamentals course which is going to take this at a course which is going to take this at a course which is going to take this at a really slow um stepby-step approach really slow um stepby-step approach really slow um stepby-step approach where it's as if we are sitting there where it's as if we are sitting there where it's as if we are sitting there together in the room with our laptops together in the room with our laptops together in the room with our laptops and I'm just going to explain everything and I'm just going to explain everything and I'm just going to explain everything to you step by step really slowly and to you step by step really slowly and to you step by step really slowly and when you do this course you are 90% when you do this course you are 90% when you do this course you are 90% prepared for the CKD and CKA exams. I've prepared for the CKD and CKA exams. I've prepared for the CKD and CKA exams. I've been getting tons of good feedback about been getting tons of good feedback about been getting tons of good feedback about this and it really goes through deep this and it really goes through deep this and it really goes through deep into the theory and in a practical way into the theory and in a practical way into the theory and in a practical way in a slow way. So it's eight hours long in a slow way. So it's eight hours long in a slow way. So it's eight hours long just the chapter on deployments is 54 just the chapter on deployments is 54 just the chapter on deployments is 54 minutes as you can see name spaces 20 minutes as you can see name spaces 20 minutes as you can see name spaces 20 minutes and next application 30 minutes.
-
minutes and next application 30 minutes. minutes and next application 30 minutes. So it's a lot of depth here. I really So it's a lot of depth here. I really So it's a lot of depth here. I really recommend you check out this course if recommend you check out this course if recommend you check out this course if you're interested in learning you're interested in learning you're interested in learning Kubernetes. You can get access to it by Kubernetes. You can get access to it by Kubernetes. You can get access to it by going to school.com/cubcraft. Now school.com/cubcraft. Now let's see how we can connect to our pod. let's see how we can connect to our pod. let's see how we can connect to our pod. In order to do that we are going to be In order to do that we are going to be In order to do that we are going to be using the port forward using the port forward using the port forward command. And what we do is we do k port command. And what we do is we do k port command. And what we do is we do k port forward and then I'm going to select pod forward and then I'm going to select pod forward and then I'm going to select pod linkeding. I'm just tabbing that and the linkeding. I'm just tabbing that and the linkeding. I'm just tabbing that and the po the port that I have opened locally po the port that I have opened locally po the port that I have opened locally is 8080 but I want to connect to the is 8080 but I want to connect to the is 8080 but I want to connect to the port port port 1990 and now my port forward is open. So 1990 and now my port forward is open. So 1990 and now my port forward is open. So if I now go to my local host here if I now go to my local host here if I now go to my local host here localhost 8080 I should see localhost 8080 I should see localhost 8080 I should see LinkedIn. Here we go. We have our LinkedIn. Here we go. We have our LinkedIn. Here we go. We have our LinkedIn application. Was that easy?
-
LinkedIn application. Was that easy? LinkedIn application. Was that easy? So it's now running on my local machine So it's now running on my local machine So it's now running on my local machine and I'm port forwarding there and that's and I'm port forwarding there and that's and I'm port forwarding there and that's why I can use it as local why I can use it as local why I can use it as local host. But how do we log in? What are the host. But how do we log in? What are the host. But how do we log in? What are the default credentials? Well, the thing is default credentials? Well, the thing is default credentials? Well, the thing is LinkedIn doesn't provide default LinkedIn doesn't provide default LinkedIn doesn't provide default credentials. You have to actually credentials. You have to actually credentials. You have to actually execute a command in the container in execute a command in the container in execute a command in the container in order to do this. So let's see what that order to do this. So let's see what that order to do this. So let's see what that looks like. You do the this command kxse looks like. You do the this command kxse looks like. You do the this command kxse it. So that means we execute a command. it. So that means we execute a command. it. So that means we execute a command. It is It is It is interactive linked and then you select interactive linked and then you select interactive linked and then you select the pod and then in the container we are the pod and then in the container we are the pod and then in the container we are doing python manage.py create super user doing python manage.py create super user doing python manage.py create super user and the username is going to be Misha and the username is going to be Misha and the username is going to be Misha and email is and email is and email is Mishaample.com. That's the command that Mishaample.com. That's the command that Mishaample.com. That's the command that we're going to run. However, my command we're going to run. However, my command we're going to run. However, my command is not correct because this pod name is is not correct because this pod name is is not correct because this pod name is not correct. I have to actually get this not correct. I have to actually get this not correct. I have to actually get this pod name that I have over here. So, I'm pod name that I have over here. So, I'm pod name that I have over here. So, I'm just going to grab just going to grab just going to grab that and I'm going that and I'm going that and I'm going to add that to my command over here. Here we here. Here we go. And if I copy that, I'm just going go. And if I copy that, I'm just going go. And if I copy that, I'm just going to open up a new window and go into my to open up a new window and go into my to open up a new window and go into my K3D dev container. And now I have my K3D dev container. And now I have my K3D dev container. And now I have my port forward open here. And then I have port forward open here. And then I have port forward open here. And then I have my uh I can interact with my cluster my uh I can interact with my cluster my uh I can interact with my cluster with cubectl over here. So I am going to
-
with cubectl over here. So I am going to with cubectl over here. So I am going to execute this command in my execute this command in my execute this command in my container and it's going to ask me for a container and it's going to ask me for a container and it's going to ask me for a password. So I'm going to do a super password. So I'm going to do a super password. So I'm going to do a super secret password called password. It's too common and but I'm password. It's too common and but I'm going to create it anyway. So if I now going to create it anyway. So if I now going to create it anyway. So if I now go to my local host and if I then do go to my local host and if I then do go to my local host and if I then do Misha Misha Misha password, I should be able to log in. password, I should be able to log in. password, I should be able to log in. And yes, here we go. I can now go to my And yes, here we go. I can now go to my And yes, here we go. I can now go to my Cuberef community, which is very useful Cuberef community, which is very useful Cuberef community, which is very useful to store for later, and add to store for later, and add to store for later, and add it. And now my bookmark is added. Yay, it. And now my bookmark is added. Yay, it. And now my bookmark is added. Yay, it's working. So now I have my working it's working. So now I have my working it's working. So now I have my working bookmarks application. Well, if you are bookmarks application. Well, if you are bookmarks application. Well, if you are a bit more familiar with Kubernetes, a bit more familiar with Kubernetes, a bit more familiar with Kubernetes, then you're going to see a few flaws then you're going to see a few flaws then you're going to see a few flaws here. First of all, we're port here. First of all, we're port here. First of all, we're port forwarding. And second of all, what's forwarding. And second of all, what's forwarding. And second of all, what's going to happen when we kill the pod? Is going to happen when we kill the pod? Is going to happen when we kill the pod? Is this going is the data going to persist? this going is the data going to persist? this going is the data going to persist? Well, there's one way to find Well, there's one way to find Well, there's one way to find out. I will go back. I'm going to stop out. I will go back. I'm going to stop out. I will go back. I'm going to stop the port forwarding. And again, if the port forwarding. And again, if the port forwarding. And again, if you're seeing me switch with T-Mox and you're seeing me switch with T-Mox and you're seeing me switch with T-Mox and Vim and all of that is still magic to Vim and all of that is still magic to Vim and all of that is still magic to you, join CubeCraft. I'm going to teach you, join CubeCraft. I'm going to teach you, join CubeCraft. I'm going to teach you everything there.
-
you everything there. you everything there. So now I'm going So now I'm going So now I'm going to get my pods and let's just see if I to get my pods and let's just see if I to get my pods and let's just see if I can restart it. So I will do k roll out can restart it. So I will do k roll out can restart it. So I will do k roll out restart deployment linkeding. So I'm I'm restart deployment linkeding. So I'm I'm restart deployment linkeding. So I'm I'm telling my deployment to restart and if telling my deployment to restart and if telling my deployment to restart and if I would have multiple replicas here the I would have multiple replicas here the I would have multiple replicas here the roll out command would be restarting roll out command would be restarting roll out command would be restarting them one by one which is very beautiful. them one by one which is very beautiful. them one by one which is very beautiful. So you can actually see it here now. So you can actually see it here now. So you can actually see it here now. Then linking is now it was completed. It Then linking is now it was completed. It Then linking is now it was completed. It was scaled down and now a new replica is was scaled down and now a new replica is was scaled down and now a new replica is running. So k get pods. Now we see the running. So k get pods. Now we see the running. So k get pods. Now we see the old one has been garbage collected old one has been garbage collected old one has been garbage collected already. So I now have a new ID here. already. So I now have a new ID here. already. So I now have a new ID here. You see it's a new pod. So in order to You see it's a new pod. So in order to You see it's a new pod. So in order to connect to my linking again I have to do connect to my linking again I have to do connect to my linking again I have to do another port forward. So let's do another port forward. So let's do another port forward. So let's do another port forward. But our ID is not another port forward. But our ID is not another port forward. But our ID is not correct. So I have to adjust correct. So I have to adjust correct. So I have to adjust that. Here we go. Kport forward that. Here we go. Kport forward that. Here we go. Kport forward linkeding with the new ID. And now my linkeding with the new ID. And now my linkeding with the new ID. And now my port forward is up again. And if I go to port forward is up again. And if I go to port forward is up again. And if I go to my local host again, what do you think my local host again, what do you think my local host again, what do you think is going to happen? Take a second. If is going to happen? Take a second. If is going to happen? Take a second. If you know a bit about containers with the you know a bit about containers with the you know a bit about containers with the configuration that we have now, what do configuration that we have now, what do configuration that we have now, what do you expect is going to you expect is going to you expect is going to happen? Let's check it happen? Let's check it happen? Let's check it out. Okay, so here is our LinkedIn out. Okay, so here is our LinkedIn out. Okay, so here is our LinkedIn deployment again. We are still able to deployment again. We are still able to deployment again. We are still able to connect. So that is good. But is our our connect. So that is good. But is our our connect. So that is good. But is our our account still going to work?
-
Misha password. No, it didn't match. It Misha password. No, it didn't match. It does it the user is not there anymore. does it the user is not there anymore. does it the user is not there anymore. And why is that? Well, we didn't And why is that? Well, we didn't And why is that? Well, we didn't provision any persistent storage. So provision any persistent storage. So provision any persistent storage. So when a container runs in Kubernetes, by when a container runs in Kubernetes, by when a container runs in Kubernetes, by default, it does not have any volumes. default, it does not have any volumes. default, it does not have any volumes. It does not have any storage attached to It does not have any storage attached to It does not have any storage attached to it. it. it. This is why we need to provision that This is why we need to provision that This is why we need to provision that storage um ourselves. We need to tell it storage um ourselves. We need to tell it storage um ourselves. We need to tell it where the storage is going to live. This where the storage is going to live. This where the storage is going to live. This is why our our bookmark if we were to is why our our bookmark if we were to is why our our bookmark if we were to log in again is gone. So how are we log in again is gone. So how are we log in again is gone. So how are we going to add the storage here then? How going to add the storage here then? How going to add the storage here then? How do we do that? Well, in the if you go to do we do that? Well, in the if you go to do we do that? Well, in the if you go to the Kubernetes the Kubernetes the Kubernetes documentation, there is a very good documentation, there is a very good documentation, there is a very good article about the persistent volumes and article about the persistent volumes and article about the persistent volumes and how that works. And you need to know how that works. And you need to know how that works. And you need to know this for your CKA and CKD this for your CKA and CKD this for your CKA and CKD uh exams. So, this is a really useful uh exams. So, this is a really useful uh exams. So, this is a really useful topic to dive a bit deeper into, but I'm topic to dive a bit deeper into, but I'm topic to dive a bit deeper into, but I'm just going to show you how you can do just going to show you how you can do just going to show you how you can do this um for this video. So, I'm going to this um for this video. So, I'm going to this um for this video. So, I'm going to copy a copy a copy a new bit of new bit of new bit of YAML. I'm going to quit the port forwarding and I'm going to deploy my forwarding and I'm going to deploy my YAML file again. and paste in the new YAML file again. and paste in the new YAML file again. and paste in the new files. So now I have my persistent files. So now I have my persistent files. So now I have my persistent volume claim. This is how you define volume claim. This is how you define volume claim. This is how you define storage in Kubernetes. And the the name storage in Kubernetes. And the the name storage in Kubernetes. And the the name is linkeding data PVC. I have the access is linkeding data PVC. I have the access is linkeding data PVC. I have the access mode of readrite once. So that means mode of readrite once. So that means mode of readrite once. So that means that it can only be mounted on one pod.
-
that it can only be mounted on one pod. that it can only be mounted on one pod. And then I request one gigabyte of And then I request one gigabyte of And then I request one gigabyte of storage because I'm going to be storing storage because I'm going to be storing storage because I'm going to be storing a lot of bookmarks here, right? a lot of bookmarks here, right? a lot of bookmarks here, right? So the deployment again also has to So the deployment again also has to So the deployment again also has to change because you have to tell the change because you have to tell the change because you have to tell the deployment where the storage is located, deployment where the storage is located, deployment where the storage is located, right? And how do we do that? We do it right? And how do we do that? We do it right? And how do we do that? We do it by adding the volumes volume mounts and by adding the volumes volume mounts and by adding the volumes volume mounts and volumes objects. So I'm going to again volumes objects. So I'm going to again volumes objects. So I'm going to again change this to change this to change this to 39.1 because that was the latest version 39.1 because that was the latest version 39.1 because that was the latest version that we found. We're still going to use that we found. We're still going to use that we found. We're still going to use the same port, but here is a new block the same port, but here is a new block the same port, but here is a new block here. It's the volume mounts block. So here. It's the volume mounts block. So here. It's the volume mounts block. So what this is saying is you need to mount what this is saying is you need to mount what this is saying is you need to mount the volume that's named LinkedIn data the volume that's named LinkedIn data the volume that's named LinkedIn data and mount that in the container at Etsy and mount that in the container at Etsy and mount that in the container at Etsy linkeding data. That's going to be the linkeding data. That's going to be the linkeding data. That's going to be the location where your data is location where your data is location where your data is living. Now this volume is then declared living. Now this volume is then declared living. Now this volume is then declared down here volumes with the name LinkedIn down here volumes with the name LinkedIn down here volumes with the name LinkedIn data. So the LinkedIn data name data. So the LinkedIn data name data. So the LinkedIn data name corresponds with what you have on the corresponds with what you have on the corresponds with what you have on the top over top over top over here and then this volume again refers here and then this volume again refers here and then this volume again refers to the persistent volume claim that we to the persistent volume claim that we to the persistent volume claim that we have provisioned earlier. Do you see how have provisioned earlier. Do you see how have provisioned earlier. Do you see how this works? We have the persistent this works? We have the persistent this works? We have the persistent volume claim up here with the name volume claim up here with the name volume claim up here with the name LinkedIn data LinkedIn data LinkedIn data PVC and here we say oh it has to be 1 PVC and here we say oh it has to be 1 PVC and here we say oh it has to be 1 GBTE. Then we say the volume is the the GBTE. Then we say the volume is the the GBTE. Then we say the volume is the the reference to the persistent volume claim
-
reference to the persistent volume claim reference to the persistent volume claim with the name LinkedIn data PVC which is with the name LinkedIn data PVC which is with the name LinkedIn data PVC which is the same as we have up the same as we have up the same as we have up here. And then in order to mount that here. And then in order to mount that here. And then in order to mount that into the pod into the the and in order into the pod into the the and in order into the pod into the the and in order to have it accessible to the container to have it accessible to the container to have it accessible to the container we have to set a volume mounts block we have to set a volume mounts block we have to set a volume mounts block which is the LinkedIn data at mount path which is the LinkedIn data at mount path which is the LinkedIn data at mount path at C linkeding data. So this is how it at C linkeding data. So this is how it at C linkeding data. So this is how it all works together. So I'm going to all works together. So I'm going to all works together. So I'm going to write this. And now if I do k apply f write this. And now if I do k apply f write this. And now if I do k apply f deployment.yammo, it's going to, as you deployment.yammo, it's going to, as you deployment.yammo, it's going to, as you see, it has created a PVC, but it has see, it has created a PVC, but it has see, it has created a PVC, but it has configured the deployment. So we already configured the deployment. So we already configured the deployment. So we already had a deployment running, but since we had a deployment running, but since we had a deployment running, but since we changed something in it, it doesn't have changed something in it, it doesn't have changed something in it, it doesn't have to delete it. It's just going to update to delete it. It's just going to update to delete it. It's just going to update it with the new information. in this it with the new information. in this it with the new information. in this case with a new volume that we added. So case with a new volume that we added. So case with a new volume that we added. So let's check out our pods. It's now let's check out our pods. It's now let's check out our pods. It's now running. But let's check out if we can running. But let's check out if we can running. But let's check out if we can see our persistent volume claim. k get see our persistent volume claim. k get see our persistent volume claim. k get pvc. Here we go. Here we have our pvc. Here we go. Here we have our pvc. Here we go. Here we have our persistent volume claim. Let me zoom out persistent volume claim. Let me zoom out persistent volume claim. Let me zoom out a little bit so you can see this a little bit so you can see this a little bit so you can see this properly. So the name is linked data properly. So the name is linked data properly. So the name is linked data PVC. Like we said, it is bound and it PVC. Like we said, it is bound and it PVC. Like we said, it is bound and it has a volume named PVC. So if I do k get persistent volume then we see that we persistent volume then we see that we have the the volume is here and then the
-
have the the volume is here and then the have the the volume is here and then the persistent volume claim is over here. persistent volume claim is over here. persistent volume claim is over here. And if that is not clear to you again a And if that is not clear to you again a And if that is not clear to you again a Kubernetes fundamentals course goes deep Kubernetes fundamentals course goes deep Kubernetes fundamentals course goes deep into this and you can also read more into this and you can also read more into this and you can also read more about it in the Kubernetes documentation. So now we have storage documentation. So now we have storage and finally there is the storage class. and finally there is the storage class. and finally there is the storage class. Now this is going to be different from Now this is going to be different from Now this is going to be different from uh any from from the Kubernetes cluster uh any from from the Kubernetes cluster uh any from from the Kubernetes cluster that you're running on. I'm doing this that you're running on. I'm doing this that you're running on. I'm doing this in K3D which is using K3S in a in K3D which is using K3S in a in K3D which is using K3S in a containerized manner. containerized manner. containerized manner. So my default storage class is local So my default storage class is local So my default storage class is local path and note that in my persistent path and note that in my persistent path and note that in my persistent volume claim I did not specify any volume claim I did not specify any volume claim I did not specify any storage class which means that it's storage class which means that it's storage class which means that it's going to take the default storage class. going to take the default storage class. going to take the default storage class. Now if I again do k get sc storage Now if I again do k get sc storage Now if I again do k get sc storage storage class then we see that the name storage class then we see that the name storage class then we see that the name local path has the the suffix default. local path has the the suffix default. local path has the the suffix default. So we know that this is the default So we know that this is the default So we know that this is the default storage class and therefore it has taken storage class and therefore it has taken storage class and therefore it has taken this uh this this uh this this uh this one again I go really deep into this in one again I go really deep into this in one again I go really deep into this in my Kubernetes fundamentals course. Now the now that we have our course. Now the now that we have our persistent storage we can create our persistent storage we can create our persistent storage we can create our account again. So we did that by doing account again. So we did that by doing account again. So we did that by doing kxse it linkeding. So it's now it has
-
kxse it linkeding. So it's now it has kxse it linkeding. So it's now it has the new ID. So you see it's a different the new ID. So you see it's a different the new ID. So you see it's a different ID from the pot that we used before. And ID from the pot that we used before. And ID from the pot that we used before. And then we can just run this python manage then we can just run this python manage then we can just run this python manage by create super user etc. And I'm going by create super user etc. And I'm going by create super user etc. And I'm going to again use to again use to again use password password password password and I'm going to accept that password and I'm going to accept that password and I'm going to accept that anyway. So the super user is created anyway. So the super user is created anyway. So the super user is created successfully. successfully. successfully. Let's do another port Let's do another port Let's do another port forward. Okay. Port forward forward. Okay. Port forward forward. Okay. Port forward pods pods pods linking. I want 8080 on my local system linking. I want 8080 on my local system linking. I want 8080 on my local system and then 1990 is the pod in the and then 1990 is the pod in the and then 1990 is the pod in the container that we have in our YAML file. container that we have in our YAML file. container that we have in our YAML file. So it's now forwarding. And if I now So it's now forwarding. And if I now So it's now forwarding. And if I now refresh my localhost 8080 refresh my localhost 8080 refresh my localhost 8080 again, if I now go to Misha and again, if I now go to Misha and again, if I now go to Misha and password, here we go. I'm now logged in. password, here we go. I'm now logged in. password, here we go. I'm now logged in. But note that the bookmark was gone, But note that the bookmark was gone, But note that the bookmark was gone, right? We added CubeCraft before, but it right? We added CubeCraft before, but it right? We added CubeCraft before, but it is not in the bookmarks anymore because is not in the bookmarks anymore because is not in the bookmarks anymore because the storage is not persistent. So, what the storage is not persistent. So, what the storage is not persistent. So, what are we going to do? We're going to add are we going to do? We're going to add are we going to do? We're going to add it again because this is a super useful it again because this is a super useful it again because this is a super useful resource to save for resource to save for resource to save for later. It's now saved. When you have a later. It's now saved. When you have a later. It's now saved. When you have a Kubernetes cluster with several nodes, Kubernetes cluster with several nodes, Kubernetes cluster with several nodes, then you're going to perform maintenance then you're going to perform maintenance then you're going to perform maintenance and then your pods are going to be and then your pods are going to be and then your pods are going to be killed. The storage is going to be moved killed. The storage is going to be moved killed. The storage is going to be moved elsewhere. And then um the whole idea of elsewhere. And then um the whole idea of elsewhere. And then um the whole idea of Kubernetes is that everything is it's
-
Kubernetes is that everything is it's Kubernetes is that everything is it's transient. So your your storage is transient. So your your storage is transient. So your your storage is persistent but your containers persistent but your containers persistent but your containers themselves don't don't have any data in themselves don't don't have any data in themselves don't don't have any data in them. So you're freely able to kill them them. So you're freely able to kill them them. So you're freely able to kill them to move them around and then the storage to move them around and then the storage to move them around and then the storage gets attached by the CSI driver. Right? gets attached by the CSI driver. Right? gets attached by the CSI driver. Right? So I should now be able to again do a So I should now be able to again do a So I should now be able to again do a roll out roll out roll out restart. And if I do k get pods again, restart. And if I do k get pods again, restart. And if I do k get pods again, we see that this one is now completed we see that this one is now completed we see that this one is now completed and we have a new pod running. and we have a new pod running. and we have a new pod running. Now, this also means that I have to uh Now, this also means that I have to uh Now, this also means that I have to uh do my port forward again because it's do my port forward again because it's do my port forward again because it's now moving to a different port forward. now moving to a different port forward. now moving to a different port forward. And if you want to um prevent having to And if you want to um prevent having to And if you want to um prevent having to change your port forward again, then you change your port forward again, then you change your port forward again, then you should be using a service, a cluster IP should be using a service, a cluster IP should be using a service, a cluster IP service. So, see if you can figure that service. So, see if you can figure that service. So, see if you can figure that out by yourself. If not, I got you out by yourself. If not, I got you out by yourself. If not, I got you covered in my courses where you will covered in my courses where you will covered in my courses where you will learn about Kubernetes networking. So if learn about Kubernetes networking. So if learn about Kubernetes networking. So if you go to my uh if I again do K port you go to my uh if I again do K port you go to my uh if I again do K port forward pods forward pods forward pods linked 8080 9090 I'm now in a new pod.
-
linked 8080 9090 I'm now in a new pod. linked 8080 9090 I'm now in a new pod. So it has been restarted and we saw that So it has been restarted and we saw that So it has been restarted and we saw that before we had to create a new user and before we had to create a new user and before we had to create a new user and our bookmark was gone. So now the our bookmark was gone. So now the our bookmark was gone. So now the expected behavior is that we are able expected behavior is that we are able expected behavior is that we are able to go to our localhost 8080 again to go to our localhost 8080 again to go to our localhost 8080 again refresh and we see our new bookmarks. refresh and we see our new bookmarks. refresh and we see our new bookmarks. Now let's do a um private window just in Now let's do a um private window just in Now let's do a um private window just in case we are don't have any caching here. case we are don't have any caching here. case we are don't have any caching here. Right. So copy Right. So copy Right. So copy that and we are still logged in. So, that and we are still logged in. So, that and we are still logged in. So, Misha Misha Misha password. Here we go. I'm logged in. I password. Here we go. I'm logged in. I password. Here we go. I'm logged in. I can restart my pod. I can port forward can restart my pod. I can port forward can restart my pod. I can port forward to it again. And I can store my to it again. And I can store my to it again. And I can store my bookmark. So, this is our first bookmark. So, this is our first bookmark. So, this is our first application that's running on our application that's running on our application that's running on our Kubernetes cluster. And this is the Kubernetes cluster. And this is the Kubernetes cluster. And this is the beginning of your self-hosting journey. beginning of your self-hosting journey. beginning of your self-hosting journey. Now this is just a very small part of Now this is just a very small part of Now this is just a very small part of this um of this deployment this um of this deployment this um of this deployment because we are now if I go to if I open because we are now if I go to if I open because we are now if I go to if I open up K9s for example and if I exec into up K9s for example and if I exec into up K9s for example and if I exec into the container and I say who am the container and I say who am the container and I say who am I that means I am root. So I can I that means I am root. So I can I that means I am root. So I can actually start installing packages here actually start installing packages here actually start installing packages here and I can start scanning the network. So and I can start scanning the network. So and I can start scanning the network. So we are running this very insecurely.
-
we are running this very insecurely. we are running this very insecurely. This is not secure and this is not the This is not secure and this is not the This is not secure and this is not the way you should be running your way you should be running your way you should be running your containers and also we are now heavily containers and also we are now heavily containers and also we are now heavily dependent on port forwarding to our dependent on port forwarding to our dependent on port forwarding to our container in order to get access to our container in order to get access to our container in order to get access to our uh application. So there are lots of uh application. So there are lots of uh application. So there are lots of more steps that we need to do in order more steps that we need to do in order more steps that we need to do in order to make this persistent. And finally to make this persistent. And finally to make this persistent. And finally this if you remember this was our Etsy this if you remember this was our Etsy this if you remember this was our Etsy LinkedIn path. LinkedIn path. LinkedIn path. What we see here is that we have um our What we see here is that we have um our What we see here is that we have um our data directory and here we see that we data directory and here we see that we data directory and here we see that we have our SQ lite. So our application is have our SQ lite. So our application is have our SQ lite. So our application is actually running SQLite. That's where actually running SQLite. That's where actually running SQLite. That's where it's storing its data on the persistent it's storing its data on the persistent it's storing its data on the persistent volume. Now I prefer to have that in a volume. Now I prefer to have that in a volume. Now I prefer to have that in a separate database. I run Postgress separate database. I run Postgress separate database. I run Postgress databases on my cluster and then I can databases on my cluster and then I can databases on my cluster and then I can point LinkedIning to my database instead point LinkedIning to my database instead point LinkedIning to my database instead of having it run on the disk which I of having it run on the disk which I of having it run on the disk which I prefer because then I can have off-site prefer because then I can have off-site prefer because then I can have off-site backups for my Postgress databases. So backups for my Postgress databases. So backups for my Postgress databases. So we need to secure our LinkedIn we need to secure our LinkedIn we need to secure our LinkedIn application. We need to make it application. We need to make it application. We need to make it connectable to the internet and we want connectable to the internet and we want connectable to the internet and we want to store this in a separate database to store this in a separate database to store this in a separate database preferably. And all of these skills is preferably. And all of these skills is preferably. And all of these skills is what you're going to be learning in my what you're going to be learning in my what you're going to be learning in my uh Kubernetes mastery home lab class uh Kubernetes mastery home lab class uh Kubernetes mastery home lab class which takes you from it like we have which takes you from it like we have which takes you from it like we have been applying YAML files manually. This been applying YAML files manually. This been applying YAML files manually. This is not the way to do it right. This is is not the way to do it right. This is is not the way to do it right. This is just to get you started with learning just to get you started with learning just to get you started with learning but what you want to do is you want to
-
but what you want to do is you want to but what you want to do is you want to learn GitOps. This is the way how you do learn GitOps. This is the way how you do learn GitOps. This is the way how you do it in actual Kubernetes production it in actual Kubernetes production it in actual Kubernetes production environments. So we learn about GitOps environments. So we learn about GitOps environments. So we learn about GitOps theory. We have our deployment master theory. We have our deployment master theory. We have our deployment master class that's already one and a half class that's already one and a half class that's already one and a half hours long. We're going to add storage hours long. We're going to add storage hours long. We're going to add storage and then we're going to secure our and then we're going to secure our and then we're going to secure our LinkedIn deployment. We're going to LinkedIn deployment. We're going to LinkedIn deployment. We're going to learn how to handle secrets and how to learn how to handle secrets and how to learn how to handle secrets and how to inject them as environment variables and inject them as environment variables and inject them as environment variables and where to store them. We're going to where to store them. We're going to where to store them. We're going to handle ingress. We are going to we are handle ingress. We are going to we are handle ingress. We are going to we are going to use tunnels in order to access going to use tunnels in order to access going to use tunnels in order to access our application from the internet. So our application from the internet. So our application from the internet. So this is a complete Kubernetes deployment this is a complete Kubernetes deployment this is a complete Kubernetes deployment master class that is going to show you master class that is going to show you master class that is going to show you how to deploy an application with how to deploy an application with how to deploy an application with production grade standards in your own production grade standards in your own production grade standards in your own home lab. So this video that we have home lab. So this video that we have home lab. So this video that we have done is your start of your journey and done is your start of your journey and done is your start of your journey and you can apply this to all of these you can apply this to all of these you can apply this to all of these different uh self-hosted applications. different uh self-hosted applications. different uh self-hosted applications. But if you want to do it properly and But if you want to do it properly and But if you want to do it properly and securely, then I highly recommend you go securely, then I highly recommend you go securely, then I highly recommend you go to to to school.com/cubcraft and check out the school.com/cubcraft and check out the school.com/cubcraft and check out the the Kubernetes home lab course where the Kubernetes home lab course where the Kubernetes home lab course where you're going to learn everything from A you're going to learn everything from A you're going to learn everything from A to Z in a practical matter. All right, to Z in a practical matter. All right, to Z in a practical matter. All right, guys. Hope you enjoyed this free guys. Hope you enjoyed this free guys. Hope you enjoyed this free tutorial and see you in the next
Summary
The main theme is learning Kubernetes through practical, fun projects, specifically by deploying a self-hosted bookmarking application similar to LinkedIn. The key subject is Kubernetes and the practical takeaway is that building useful applications makes learning enjoyable and provides tangible benefits like cross-browser bookmark accessibility.