Complete Intro to Containers (feat. Docker) Multiple Containers with Kompose
Transcript from the "Multiple Containers with Kompose" Lesson
>> Let's do something fun here. We're gonna say kubectl scale --replicas=, let's go with 5 and be conservative for the moment. Let's say deployment, /web. Okay, now if I look at get all again, you can look up here and see, before I just had one web container running, right?
[00:00:31] You can see this one's just running. But these ones, now it's creating five more versions of this container. And if I run this again, they're probably all running now. Yes, you can see that they're all running. So if I go back here and refresh, any one of these times I don't know actually which container I'm getting.
[00:00:47] But I'm getting a different container probably every single time. So now I've taken this cluster and I've scaled it up. So this is the thing that we had a problem with docker compose, that it didn't have a load balancer in front of it. Kubernetes has this built into it, so it's just load balancing all this stuff for us.
[00:01:06] So depending on how much RAM you can do, let's just say 25, if you don't have very much RAM, don't do this. My computer's probably gonna say, why are you doing this to me? You can see now, I have 25 versions of that container running on my computer.
[00:01:29] Just watch, we can watch the temperature, right there on my computer, and it's just gonna go up. And now, most of them are running. But, how do we feel about that, pretty cool right? I need to see heads, yes Brian. This is very cool, you're very impressed, I'm just kidding.
[00:01:47] And one more time, we'll see that, 25 are desired, 25 are currently running, and 25 are ready. And you can see all of these are now running. And then as soon as I'm done running all these different things, I can just say replicas, 1, and it's just going to scale that back down.
[00:02:07] And we'll see here that it'll say, Kubectl come on, terminating. It's terminating all these different things for us. Now we could do all sorts of fun stuff. We could put like a health check on one of these and then make a container crash, and then it would restart the containers for us.
[00:02:26] It'll do a bunch of really cool stuff for us. It does all that monitoring and restarting and rerunning all this stuff for you out of the box. Okay, and then as soon as we are done with all of this, you can just say kubectl delete all --all. There you go.
[00:02:47] Everything just gets wiped off and you are back to a blank slate again. Okay, last thing here. If let's say, actually, I was very serious about this being a Kubernetes project going forward, I would not run this with compose in production. That's just not the way that I would suggest doing it.
[00:03:10] I would say kompose convert. And then now you can see here, I have web-deployment.yaml, web-service.yaml. It generates all of the Kubernetes files for me. So I will get started with docker compose because I don't remember all of the syntax off the top of my head. I don't want to.
[00:03:27] So I'll do with docker compose first, and then I'll say kompose convert, and then I suddenly have Kubernetes configurations for all my various different services. So it's a good way to get kinda started out of the gate. So Kubernetes is extremely powerful. I just showed you basically the Hello World of Kubernetes.
[00:03:48] It does 9 million more things, right? This is what runs Google's infrastructure, much of that infrastructure. Azure's now run on Kubernetes. It's kind of, the direction of the industry is heading towards Kubernetes in almost every sense of the word. So I'm gonna say that it's useful to know what it is, how it works, why you would use it, and then not necessarily use it unless you absolutely have to.
[00:04:12] Cuz I'm gonna tell you that Kubernetes solves a lot of problems but it creates its own unique set of problems when you're running Kubernetes. Like I said before at the beginning of this, it's a complicated product that solves complicated problems. So if you don't have complicated problems, don't give yourself a complicated problem.
[00:04:32] Is kind of my stance on the matter. Now, what's really cool, what I've shown here and I'm not gonna show you how to do it, do the kind of like conflict of interest a little bit is. I've been showing you how to do things with kubectl or kube control.
[00:04:48] If I wanted to go to Azure Kubernetes service, I would just change my context just like I switch from docker desktop to Minikube. I would just switch that to Azure as my context. And all sudden I'd be controlling my entire Azure deployment of Kubernetes. So everything that I was just running locally on my computer, it works 100% the same way in production.
[00:05:10] So if I just said, scale this to 25, it would go out to the cloud and scale that out to 25. The other reason I'm not gonna show is Kubernetes is not cheap. [LAUGH] So if we did that and I was showing you how to do that in our workshop, you'd probably run up $10 or $20 with the bill or something like that, right?
[00:05:28] It's not cheap. So I left a bunch of links down in the course documents here of getting started on AKS, getting started on EKS, and getting started on GKE. I am partial to AKS, I think it's a good product. So maybe try that one, I don't know.