Getting started with Docker and Kubernetes for Web Developers on Digital Ocean #DevRel #OpenSource

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so you've built an awesome app in ruby or python or node and it's working on your local machine but you want to get out in the real worlds other people can use it too and deploying apps can be expensive you might pay five dollars over here for one and then another five dollars over there for another and when you get to five or ten apps it gets really expensive what happens if there's a way to deploy multiple apps of different technologies on one location in this video we're going to be using docker and kubernetes with digital ocean and whoa well hold on it might sound scary but i'm actually going to do it all through digitalocean's ui but of course you can still do it via the cli too we will actually deploy multiple nginx servers and create subdomains that show you they're working i will also show you what not to do because it can end up very expensive with you realizing too late just like i did and if you make that mistake you get a nice surprise so there are a few little gotchas then in the future all this could be tied together with our code on github with a github action where you deploy from a branch or release but i'll leave that part for another time let me know in the comments below if that's something you'd be interested in before we get into it my channel is about getting you into open source full stack web development devops so you can get the job clients and money that you deserve if that sounds interesting give this video a thumbs up and subscribe to my channel below and hit the bell button so you get notified every time i go live and post a video also you can come and chat to me and our awesome eddie hub community in discord between videos and live streams so before i show you digitalocean's dashboard let's talk about what is a container a container is a standard unit of software that packages up code and all of its dependencies so the application runs quickly and reliably from one computer environment to another a docker container image is a lightweight standalone executable package of software that includes everything needed to run the application code runtime system tools system libraries and settings container images become containers at runtime and in the case of docker images become containers when they run on the docker engine available for both linux and windows based applications containerized software will always run the same regardless of the infrastructure yes the same which means no more saying it works on my computer containers isolate software from its environment and ensure that it works uniformly despite differences for instance between development staging and production containers are a good way to bundle and run your application in a production environment you also need to manage these containers and run the applications ensure that there's no downtime therefore if a container goes down another one needs to start and take its place this is where kubernetes comes in think of it like kubernetes wrapping your docker containers it manages them for you kubernetes provides you with a framework to run distributed systems resiliently it takes care of scaling failover and deployment for example kubernetes can easily manage a deployment for your system it does rolling deployment and it can also do rollbacks but we'll get into that in a second kubernetes service discovery and load balancing exposes a container using its dns name or their own ip in if the traffic to the container is high kubernetes will able to load balance and distribute the network traffic so that deployment remains stable when it comes to storage kubernetes allows you to automatically mount a storage of your choice such as local storage public cloud providers and more i mentioned roll outs and rollbacks you describe the state of your deployment and kubernetes will change the actual state to your desired state at a controlled rate for example you can automate kubernetes to create containers for your deployment remove existing containers and make sure they adopt all the resources in the new container you can also tell kubernetes how much cpu and memory each container needs and it'll make sure they fit onto the right nodes kubernetes also can restart replace and kill failing containers so that none are exposed to your users until they are ready to be used also kubernetes can manage secret and sensitive information such as passwords oauth tokens ssh keys and you can deploy and update secret application configuration without rebuilding your containers and also without exposing them right now that you know what docker is then you know what kubernetes is let's jump in digitalocean's dashboard and let's get our hands dirty and look at some of those exciting things as you can see behind me i've got the digital oceans control panel and i've gone to the kubernetes tab on the left hand side and then we've got this nice big blue button to create a kubernetes cluster you can also get there directly by going to the top right create green button clicking on it and selecting kubernetes they do the same thing now i've hit create it's going to take us to the form so we can decide where he wants it what version etc by default the latest is selected i highly recommend sticking with the latest i'm going to choose london because that's the closest to me in terms of the node plan i'm going to go for the basic which is 10 a month and a single node it will give a warning to say to prevent downtime during certain situations that two nodes is better but that's fine we're going to have rolling deployments so therefore there should be no downtime during that moment only if something goes wrong i'm going to keep the name the same so let's hit create cluster it takes a few minutes to create but while it's being created there are things that we can do it gives suggestions on what to install so they're cli so we can manage the kubernetes cluster also the digital ocean cli as well so we can do some more management there gives you a config to download i'm going to go straight to the install one click app and it lists a few popular options and you can also go to the marketplace where you can select lots of other free applications but all we need here is the nginx ingress controller so i'm going to click install and that will install once the kubernetes cluster is up and once it finishes we'll also get a big blue button at the top here right next to actions where we can go to the kubernetes cluster dashboard and we can do some more management there where we can actually install our containers and our applications why this is being set up one thing to note i'm going to keep reminding you that when we go to the kubernetes cluster control panel and we install apps if you select external it will create a load balancer for each container and you don't want that because that can get very expensive that's why we're installing the app ingress that will then create a load balancer to point external traffic to our kubernetes cluster we just need one of those it costs 10 dollars a month so it's 10 for the kubernetes cluster 10 for the load balancer that's ingress but then from that we can employ an unlimited amount of apps therefore bringing the cost down and down and you can even deploy apps for your friends so that will github action so it's all automated they don't have access to your keys and so forth lots of things that can be done and then you're only limited by the resources on the cluster let's give that a few minutes [Music] now you can see that our kubernetes cluster is green and also ingress has been installed and so we've got this blue button at the top if i click this blue button we get a new tab and you're going to see graphs and green and green ticks and you might see some red ones in a bit but you've got information about your kubernetes cluster the parts you're probably most interested in are deployments pods services and ingress and there's nothing at the moment we're going to add something to this so let's deploy something so if we go to the top right actually before we do deploy something let's go back to here and if we click on kubernetes on the left you'll see that we have a single cluster we've got a single clusters created very recently and then if we go to networking and then go to load balances we also have one load balancer and that is because we installed ingress if we just installed the kubernetes cluster we wouldn't have this so we're paying ten dollars for this and ten dollars for the kubernetes cluster but that is it we can now install loads of apps so let's install something so as i mentioned here at the top right click on the plus button we're going to create it from form so really nice and simple if we say nginx i'm going to call it 10 i've created loads i have recorded this video many times and every time there is an issue like i'm out of focus or sound isn't recorded or my screen wasn't captured so many problems so let's just go 10 because we are going to create some sub domains and i don't want to reuse any existing ones due to dns and then the actual container image is called nginx we want a single pod and service we want internal remember i said earlier if you pick external yes it'll be reachable externally but you'll have a load balancer for each deployment which you don't want because it will charge you ten dollars per deployment so we're going to choose internal and we're going to expose this in a moment using the ingress load balancer that we added earlier so we'll say port 80 port 80 and we'll deploy so that's one being deployed and so while that's being deployed you can see the gray icon it's deploying let's deploy a second one as well so we're going to call it number 11. the container image is the same engine x again the same internal and it's going to be 80 80 and let's hit deploy so now we've got two deployed so while both of those are deploying what we need to do is we need to update ingress so it can root traffic through to these two nginx containers so next we'll go plus again but this time we're going to create it from a yaml config and so there is a little bit of config here here's one i prepared earlier and you will see that it is quite straightforward we specify the api version and what kind it is this is targeting ingress some metadata we'll call it web so it appears as web in our list and namespace we'll just give it default and we want two rules let's call it nginx 10 hyphen test dot dashboard hub.io and we're going to create the subdomains in a moment in digitalocean and you'll see how straightforward it is and we're going to route through to the service which is engine x10 then next we're going to do the same again but we'll call it nginx 11 hyphen test dot dashboard hardware io the domain that i use for startup that i created a while ago that is currently in the holding pattern so don't worry and then we're going to create it to be engine x11 service and it's going to go through on port 80. so we're going to hit upload let's get this going and so now that's going to start doing its bit and literally in a minute it will be ready to go we've got our services and we've created our ingress 10 seconds ago and it's still probably being set up just while that's happening let's go back to chill ocean and if we go to networking and we go to domains and we go to dashboard hub so we're going to create some subdomains let's create engine x 10 and you can see underneath it's already auto completed it to say engine x10 dashboard io but i'm going to put a hyphen test at the end just in the future if i ever forget to delete this now in the future i'll know that it was just a testing domain and we're going to route through to let's check our load balancer so if we open a new tab we're going to load balances we'll see that it's a 565 so we want to go through to a565 check it's the right one go through the load balancer and we're going to create the records let's hit create let's do a second one which we're going to call 11 and it's going to go through to the same load balancer and to create subdomains is free so now we've got these two being created so now if we go to engine x 11 hyphen test dashboard hub.io you'll see it says welcome to nginx but let me prove to you that we are controlling this so if we go back to ingress and we hit edit and on one of them let's just pick the second one to number 11 if we change that from 80 to 81 and hit update give that a moment to update but very quickly we should then see that the nginx page should now show bad gateway because the domain works and it's pointing to the right load balancer but once it's rooting through into the kubernetes cluster it can't find the right container so let's have a look 503 service temporary unavailable and what we can do is we can go back we can hit edit change that back to 80 and then in a moment we will see that this will be back up and running and shows us nginx that's how quick and awesome it is so you can deploy nginx python node ruby php anything that you wish or for fixed price which i think is excellent other things to note don't choose the external option when making a deployment but also the other thing to note is when you do delete deployment so if i delete number 10 now for example that will disappear in a moment but you must remember that it's still running and you would need to also delete it from here as well when you destroy the kubernetes cluster the load balancer with ingress should also go however if you created external containers that got a load balance automatically created for them those will not be deleted so don't get caught out like i did and have lots of orphaned load balancers which you're being charged for let's go back to deployments we've only got engine x11 and if we go back to services you can see 10 is still running if i hit delete and delete this from running services and you can see now it's disappeared but if we go to the nginx page this is showing us number 11 engine x11 if it refresh it is still there if i refresh maybe i'll click on one of these to show you that it's working refresh that is still there 10 went but 11 is still up and running and that's it now you know how to deploy a container to your own kubernetes cluster that isn't costing you the earth because some of the kubernetes managed services are really expensive any questions any thoughts let me know in the comments below and i'm going to dig deeper into this and deploy some of our community projects onto our kubernetes cluster so i want to learn a lot more about it as well so we can learn together don't forget give this video a thumbs up hit subscribe if you have not already it really helps support channel and if you hit the bell button you get notified every time that i go live and post a video also don't forget to join our discord channel so we can chat between live streams and videos we have such an awesome community who are doing regular hackathons together lots of awesome open source projects they want to help you and they want to learn from you as well remember collaboration first and code second i'll also show you what not to do because it can end up very expensive expensing doesn't make sense
Info
Channel: Eddie Jaoude
Views: 1,702
Rating: 5 out of 5
Keywords: open source, tech, code, webdev, developer, coder, fullstack, javascript, typescript, node, firebase, opensource, machine learning, github, web developer, cypress, ci, cd, circleci, DevOps, PDD, Pipeline Driven Development, devlife, digital nomad, interview, branding, mentoring, dashboardhub, react, angular, react vs angular, strengths, weakness, business, startup, startup life, meetup, devrel, mermaid, diagrams, documentation, developer advocate
Id: YrM0UPsnY1Q
Channel Id: undefined
Length: 15min 0sec (900 seconds)
Published: Wed Feb 17 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.