Complete Intro to Containers (feat. Docker)

Multiple Containers with Kompose

Brian Holt

Brian Holt

SQLite Cloud
Complete Intro to Containers (feat. Docker)

Check out a free preview of the full Complete Intro to Containers (feat. Docker) course

The "Multiple Containers with Kompose" Lesson is part of the full, Complete Intro to Containers (feat. Docker) course featured in this preview video. Here's what you'd learn in this lesson:

Brian demonstrates how to run multiple containers using Kompose, how to delete all of the newly created containers, and how to convert all files to Kubernetes files.


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?

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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?

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.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now