‫All right, now that we've learned all about Swarm scaling with overlayed networking and routing mesh,
‫I want you to actually go through the process of creating the assets, or the objects, that you need to
‫deploy in a Swarm scenario.
‫So we're no longer using the docker run command, but the networking and the volumes are kind of the
‫same but slightly different.
‫I want to give you a real-world scenario of a multi-tier app, and we're going to use Docker’s Distributed
‫Voting App.
‫It's actually called the Example Voting App.
‫You might have seen it in Docker keynotes, or in other labs or tutorials.
‫It's a pretty common, and I think, a great app, because it's got at least five roles to it, or different
‫containers that you need to deploy.
‫And they all serve a special function and they're actually doing stuff that actually works, actually does
‫what it's supposed to do.
‫And so you can play with it and it has very typical, distributed architecture components like the web
‫frontend and the worker backend,
‫and the key value in a database. I think it's really helpful to do. In this case, you're going to use
‫the directory swarm-app-1. It's actually in our course repo. In there is nothing but a readme and
‫an image. From that readme, you're going need to create the volume and a couple of networks and five
‫services that are needed for this app to fully function.
‫It may help you to try some of these commands locally, or actually write them in your text editor
‫and sort of compose them, because they are going to be a little complex, right. When you do that docker
‫service create, you’re going to have to connect it to a specific network, and open up ports, and call it
‫a specific name, and use a specific image. So, it might be easier to edit it locally and then just cut
‫and paste into your shell, wherever your Swarm is at.
‫But that's just me.
‫Everything is going to use Docker Hub images because in the production Swarm you don't want to be building.
‫That's not a process you want on your production Swarm, typically.
‫Usually, you want to do your building either through some automated online service like Docker Hub or
‫Docker Cloud, or somewhere in your CI/CD pipeline that's not eating resources on your production Swarm.
‫In this scenario, we can imagine that our images are being built elsewhere and stored on Docker Hub and
‫we just need to pull those down, whatever the latest versions are, into our Swarm.
‫And I'll just say this, like many things in Computer Science, this is one half science, one half art form.
‫Your commands could be in totally different orders, or have totally different option orders than mine.
‫You might call your networks different things.
‫That's fine.
‫At the end result is that the application works, that they're able to talk to each other in the proper
‫way, that you've got all the ports published and that you’ve got the data protected in a volume.
‫Let's take a quick look at what you're up against.
‫Imagine you're having to design the commands and the architecture for this.
‫And this is what the developer would give to you that wrote this app.
‫Well in this case, it's probably lots of developers that wrote this app, right?
‫Because we've actually got a web frontend that's in Python we've got a Web backend that's running
‫in Node.
‫We've got a worker process that's running in .NET and then we've got a Redis key value store and
‫a PostgreSQL database.
‫This is actually something I see more and more often, where different teams are writing different parts
‫of a solution, and they're able to just pick the language that they think is best for that scenario.
‫And in the world of containers, this kind of application really shines. Because our applications are
‫all segmented,
‫they can still technically run on the same machine but they're all protected from each other so that
‫you don't end up with Node conflicting with dependencies on Python or whatever.
‫You’ll also notice here the traffic flow, and the voting-app doesn't have it,
‫but it should have a little arrow coming in that this is where the users would be coming in on the voting-app
‫part.
‫And you can see that the voting-app actually has to push your votes for this application which, by the way, you’re
‫going to be voting for cats and dogs.
‫It'll be pushing that into Redis and then the worker will actually be checking the Redis system for anything
‫in the queue and then be pushing the results into Postgres which will then be shown on a WebSockets
‫backend that's actually live-updating as you're voting.
‫If we jump into the Directory real quick I've put some notes in here to help you along the way because
‫there's a few things that are a little different and new.
‫But, the services area would be kind of written like it was from someone who knew their application but
‫didn't know actually how to implement this in Docker. And that's a pretty common scenario.
‫You can see that in the services I've listed which image you need to deploy,
‫the actual name that you need to give it, because those are important.
‫These are images that are, unfortunately, hard coded for what names they are going to look for on the network.
‫Ideally, you'd want applications that you could configure on the fly for what they need to do for names,
‫but, in this case, vote is going to specifically look for a DNS record called redis. You can see that
‫there's actually two networks here. We have a frontend and a backend network. That's pretty typical
‫also of a larger application where you maybe want to protect your database on a backend network so
‫that the frontend user app doesn't have direct access to it.
‫And that's what we are showing here and you’ll notice that the worker actually is connected to two networks.
‫So when you use your create command, remember you're using docker service create not docker run.
‫So when you using your docker service create command you're going to need to specify the --network
‫twice, once for the frontend, and once for the backend.
‫Obviously, you know to create your networks first.
‫So some of that’s specified up here. And if you need the image again the architecture diagram is also in
‫here, just in case that helps conceptually with how you're going to deploy this.
‫And, of course, you're going to have the Docker documentation. You might need to use the --help on
‫the service create command that will give you all the various options that you might need.
‫You only are going to need three or four of those. If you get stuck with the commands themselves, you
‫might want to review the actual documentation, which I will put into the resources of this section.
‫But this particular document under Swarm actually goes into creating services and configuring services.
‫So, it's a little wordy, but it's got a lot of information in it that might help you if you get stuck
‫in here.
‫The next video I will actually run through this whole thing myself as if I was you.
‫Good luck and have some fun.