1 00:00:00,270 --> 00:00:00,780 ‫So 2 00:00:03,630 --> 00:00:05,230 ‫we're going to go fast. 3 00:00:05,240 --> 00:00:05,640 ‫All right. 4 00:00:09,280 --> 00:00:11,970 ‫Then we're going to end the show because we're past our hour. 5 00:00:11,970 --> 00:00:15,240 ‫I want to get you guys some feedback. 6 00:00:15,240 --> 00:00:15,480 ‫All right. 7 00:00:15,810 --> 00:00:17,860 ‫The first one up is Jacob. 8 00:00:18,030 --> 00:00:23,480 ‫There's a whole lot of documentation here. I love documentation Dockerfiles by the way. 9 00:00:23,580 --> 00:00:25,620 ‫It's totally fine to put as much as you want. 10 00:00:25,620 --> 00:00:30,420 ‫This is actually a YAML file so now we're talking about Compose. Documentation in Dockerfiles or 11 00:00:30,420 --> 00:00:31,980 ‫Compose files. Either way. 12 00:00:31,980 --> 00:00:34,550 ‫Always a good thing. 13 00:00:34,680 --> 00:00:34,920 ‫All right. 14 00:00:34,920 --> 00:00:39,530 ‫So he's using a version 3.0 7 which means it's probably for Swarm or something in production like 15 00:00:39,530 --> 00:00:43,680 ‫Kubernetes using the Compose on Kubernetes feature set. 16 00:00:43,800 --> 00:00:53,150 ‫He's using the official Elastic images from the Elastic there. 17 00:00:54,780 --> 00:00:56,880 ‫Let's see you've got your healthcheck. 18 00:00:56,880 --> 00:00:57,690 ‫Fantastic. 19 00:00:57,690 --> 00:01:00,140 ‫You've got healthchecks. That's great. You've got configs. 20 00:01:00,210 --> 00:01:01,220 ‫That's great. 21 00:01:01,290 --> 00:01:05,610 ‫You're setting it on a specific network and you're doing host mode on the port 22 00:01:05,640 --> 00:01:12,930 ‫so you're giving this direct access to the NIC instead of going through the overlay networks and the 23 00:01:13,560 --> 00:01:14,220 ‫routing mesh. 24 00:01:14,220 --> 00:01:15,300 ‫That's good. 25 00:01:15,300 --> 00:01:17,420 ‫Then, let's see. 26 00:01:20,020 --> 00:01:21,420 ‫We've got to deploy down here. 27 00:01:21,420 --> 00:01:24,750 ‫Oh, and you're doing endpoint mode DNS round robin. 28 00:01:24,750 --> 00:01:26,310 ‫Kudos to you. 29 00:01:26,310 --> 00:01:29,320 ‫This is something that a lot of people don't realize. 30 00:01:29,490 --> 00:01:37,200 ‫Whenever you're running something in Swarm and you want to disable the virtual IP that sits in front 31 00:01:37,200 --> 00:01:44,190 ‫of every overlay service, you want to do that for databases where you only have one node, right, which 32 00:01:44,190 --> 00:01:48,660 ‫is a lot of times even if you're doing a mirror of a database you're usually running each one of those 33 00:01:48,660 --> 00:01:49,820 ‫in their own service. 34 00:01:49,890 --> 00:01:56,760 ‫So there's one instance in a service and that that task of that instance of a container, you don't 35 00:01:56,760 --> 00:02:01,140 ‫usually want that virtual IP in front of it because it's now an extra hop. It's another NAT translation. 36 00:02:01,340 --> 00:02:03,250 ‫It's more potential problems. 37 00:02:03,270 --> 00:02:10,230 ‫If you set endpoint mode to DNS round robin here, that effectively turns off the VIP and has direct 38 00:02:10,230 --> 00:02:11,460 ‫access to that container. 39 00:02:11,460 --> 00:02:12,820 ‫Kudos to you. 40 00:02:12,900 --> 00:02:18,300 ‫I don't see that very often because people don't catch that one. You're also using replicas 41 00:02:18,300 --> 00:02:18,820 ‫too. 42 00:02:19,320 --> 00:02:25,090 ‫Resource limits of 4G for a gig that's great. 43 00:02:25,140 --> 00:02:31,350 ‫Always I recommend always setting resource limits and reservations if you can because that's going to 44 00:02:31,350 --> 00:02:34,920 ‫help things all get along inside your cluster. 45 00:02:35,040 --> 00:02:35,330 ‫Yeah. 46 00:02:35,340 --> 00:02:38,820 ‫Looks like it's running on Docker Swarm. Sweet. 47 00:02:40,910 --> 00:02:42,120 ‫Coordination 48 00:02:44,090 --> 00:02:45,110 ‫Master. 49 00:02:48,080 --> 00:02:48,420 ‫All right. 50 00:02:48,420 --> 00:02:50,220 ‫More of the same. 51 00:02:50,490 --> 00:02:51,030 ‫More of the same. 52 00:02:51,030 --> 00:02:52,210 ‫Good stuff. Good stuff. 53 00:02:52,350 --> 00:02:58,810 ‫You're bind mounting a volume. You're not bind mounting. You're using a named volume. 54 00:02:59,170 --> 00:03:05,170 ‫You've got placement constraints here so you're putting this on a node that is hard coded to a specific 55 00:03:05,170 --> 00:03:08,950 ‫name. You know you want this one to run on that node only. 56 00:03:09,040 --> 00:03:15,130 ‫Of course, the weakness here is that if that node goes down, it won't be able to place it anywhere 57 00:03:15,130 --> 00:03:15,390 ‫else. 58 00:03:15,400 --> 00:03:20,040 ‫Hopefully you've taken that into consideration. 59 00:03:20,260 --> 00:03:20,950 ‫All right. 60 00:03:20,950 --> 00:03:22,840 ‫Master2, so that's how you're doing this. 61 00:03:22,840 --> 00:03:29,110 ‫It looks like you have master1, master2 hard coded in as separate services and master3. A 62 00:03:29,110 --> 00:03:34,750 ‫lot of people have to do it this way that when you have a multi-node database cluster, it's usually easier 63 00:03:34,990 --> 00:03:37,290 ‫to put each one of these as their own service. 64 00:03:37,300 --> 00:03:42,550 ‫So you've done that. It would be nice if we could just make one service with three replicas. 65 00:03:42,550 --> 00:03:50,530 ‫You can find that with some examples using the autopilot pattern. If you look up autopilot pattern IO, 66 00:03:50,860 --> 00:03:56,650 ‫or if you just Google your database technology with the word autopilot, sometimes you can find configurations 67 00:03:56,650 --> 00:04:00,270 ‫and automation scripts that will help you do it all in one service. 68 00:04:00,340 --> 00:04:02,360 ‫There's pros and cons to each. 69 00:04:02,380 --> 00:04:05,080 ‫I personally tend to just do it the way you're doing it. 70 00:04:05,680 --> 00:04:10,180 ‫I feel like it's simpler even though it's more YAML and it's a little bit more verbose. 71 00:04:10,180 --> 00:04:11,490 ‫One thing you could do here. 72 00:04:11,620 --> 00:04:16,710 ‫One huge improvement is if these are all all the same parts here. 73 00:04:16,710 --> 00:04:17,080 ‫Right. 74 00:04:17,080 --> 00:04:23,710 ‫All the same stuff, you can template that, shorten this file significantly by only putting that in a template 75 00:04:23,710 --> 00:04:24,400 ‫block. 76 00:04:24,580 --> 00:04:29,490 ‫I talk more about that in this... 77 00:04:29,740 --> 00:04:33,450 ‫This right here, Jacob. I'll put this in chat. 78 00:04:33,490 --> 00:04:38,610 ‫This is three different advanced Docker Compose features that a lot people don't use. 79 00:04:38,710 --> 00:04:42,310 ‫One of them is on templating. 80 00:04:42,370 --> 00:04:49,490 ‫So if you see the example here, you can you can throw the templating right there. 81 00:04:49,810 --> 00:04:52,530 ‫Basically what you're saying is this is what I want in the template 82 00:04:52,540 --> 00:04:57,810 ‫and this is where I want you to put it, over and over in each image, or in each service rather. 83 00:04:57,850 --> 00:05:02,290 ‫So, a lot of that boilerplate stuff, like you could template the whole thing or you could just template 84 00:05:02,290 --> 00:05:06,550 ‫parts of them and have multiple templates, and Docker has documentation on that. 85 00:05:06,550 --> 00:05:10,890 ‫That would help make your file smaller and we call it dry. 86 00:05:10,900 --> 00:05:11,170 ‫Right. 87 00:05:11,170 --> 00:05:16,030 ‫Doing things once. Don't repeat yourself. 88 00:05:16,030 --> 00:05:16,950 ‫D R Y 89 00:05:17,180 --> 00:05:18,710 ‫You could do that. 90 00:05:18,710 --> 00:05:22,730 ‫That would help you alleviate a lot of this repetitive stuff especially around the healthchecks 91 00:05:23,150 --> 00:05:25,940 ‫and the deployment stuff. 92 00:05:25,940 --> 00:05:30,740 ‫Then you've got your data nodes. Everything's looking good there. You're using your healthchecks. You've 93 00:05:30,740 --> 00:05:42,250 ‫got your network set. Your volumes. Let me go down past some of this. You're hard coding stuff to each 94 00:05:42,250 --> 00:05:44,800 ‫node. I really wish 95 00:05:49,140 --> 00:05:53,220 ‫that we had a way to tell it don't run...like here's a placement constraint. 96 00:05:53,220 --> 00:05:54,920 ‫Don't run it on one 97 00:05:55,020 --> 00:05:57,270 ‫that is where the other ones run. 98 00:05:57,300 --> 00:06:02,730 ‫There's some hope for you. There's two things you can do here. You can look at placement preferences. 99 00:06:03,180 --> 00:06:08,340 ‫If you have your different nodes in availability zones and you simply want your database to make 100 00:06:08,340 --> 00:06:15,270 ‫sure that it has one copy in each availability zone, like an AWS or something, then you can add labels 101 00:06:15,270 --> 00:06:23,910 ‫to each node. Then you just go in here and say I would prefer you to spread these out over my label. 102 00:06:23,940 --> 00:06:28,770 ‫You just give it a label and a placement preference instead of a constraint, will allow it to put 103 00:06:28,770 --> 00:06:33,220 ‫those on the different servers in the different zones. 104 00:06:33,270 --> 00:06:40,080 ‫But the cool thing here is if one zone, or one server, goes down, it will still be able to reassign that 105 00:06:40,080 --> 00:06:41,490 ‫somewhere else. 106 00:06:41,490 --> 00:06:47,520 ‫Now the worst case here is that two of these are running on the same server but that's probably not 107 00:06:47,520 --> 00:06:53,220 ‫so bad if you're able to...I mean one thing might be the data getting the data from one zone over the 108 00:06:53,220 --> 00:06:56,080 ‫other. Once you've solved some of those problems. 109 00:06:56,110 --> 00:06:56,940 ‫Yeah. 110 00:06:57,030 --> 00:07:01,050 ‫Yeah. You're saying, so I can use constraint and allowed to lose one of the physical nodes. 111 00:07:01,050 --> 00:07:01,260 ‫Yeah. 112 00:07:01,290 --> 00:07:07,050 ‫The thing here is you're you're making it a little bit more brittle by assigning it to Node host 113 00:07:07,050 --> 00:07:11,760 ‫names. You have to those specific hosts up. Ideally, like if you're in AWS or something 114 00:07:11,760 --> 00:07:14,460 ‫where you can have your servers auto create. 115 00:07:14,460 --> 00:07:17,340 ‫So, if a server dies it all creates a new one. 116 00:07:17,840 --> 00:07:18,150 ‫Yeah. 117 00:07:18,180 --> 00:07:22,680 ‫If you've accounted for all that, great. There's nothing wrong with placement constraints in this way. 118 00:07:22,680 --> 00:07:26,490 ‫It just means that those nodes have to be there or those containers die. 119 00:07:26,490 --> 00:07:33,030 ‫The other thing is there is a new feature coming in 19.03 and the way you learn about these new features 120 00:07:33,450 --> 00:07:43,950 ‫is if you go to Docker on github and you go to Docker-ce releases. I will post this in chat and you 121 00:07:43,950 --> 00:07:48,510 ‫can look up new Swarm features. There is a new Swarm feature version that will allow you 122 00:07:48,510 --> 00:07:56,130 ‫to run replicas but tell it never run more than X of these replicas on the same node. Super cool feature 123 00:07:56,160 --> 00:08:01,590 ‫and helps people ensure that their databases don't all get assigned the same node. You might want 124 00:08:01,590 --> 00:08:07,020 ‫to check that out as a more flexible way to ensure they're not on the same note. 125 00:08:07,980 --> 00:08:12,910 ‫I think if I scroll down down to Swarm. 126 00:08:13,510 --> 00:08:20,320 ‫Yeah. Added support for maximum replicas per node. That's a new feature in the forthcoming 19.03 release 127 00:08:20,320 --> 00:08:25,750 ‫that's already in prerelease now so we should be seeing this within the next few weeks or months. 128 00:08:25,750 --> 00:08:26,560 ‫You can check that out. 129 00:08:26,560 --> 00:08:29,490 ‫That might help you with the constraints. 130 00:08:29,600 --> 00:08:30,170 ‫All right. 131 00:08:30,360 --> 00:08:31,590 ‫I want to move ahead a little bit. 132 00:08:31,590 --> 00:08:34,610 ‫Sorry I can't review all this. I'm moving it down at the bottom. 133 00:08:34,650 --> 00:08:40,430 ‫You got your networks, attachable true and proxy. 134 00:08:40,770 --> 00:08:41,940 ‫All looks good there. 135 00:08:41,940 --> 00:08:48,150 ‫You got volume so you're using the default volume driver so that that way that means that all of this 136 00:08:48,150 --> 00:08:50,220 ‫data is stuck on the node that it's on. 137 00:08:50,910 --> 00:08:57,120 ‫If you have any shared storage, you might consider REX-Ray or another volume driver so that you can get 138 00:08:57,120 --> 00:09:01,680 ‫that storage off that disk. That way, when one of the nodes fails and it wants to create that somewhere 139 00:09:01,680 --> 00:09:04,950 ‫else, it will reattach that database volume 140 00:09:04,950 --> 00:09:05,850 ‫on the other node. 141 00:09:05,920 --> 00:09:06,390 ‫All right. 142 00:09:06,480 --> 00:09:14,800 ‫You may have already looked at that. You've got traefik certificates. I could talk about that for 143 00:09:14,800 --> 00:09:19,720 ‫a while but we're going to run out of time. I'll leave the traffic certificate stuff for another 144 00:09:19,720 --> 00:09:23,970 ‫day. Then you've got configs and other files. 145 00:09:23,980 --> 00:09:27,750 ‫This is great. Using all the configs. 146 00:09:29,340 --> 00:09:30,390 ‫As you should. 147 00:09:30,390 --> 00:09:34,800 ‫I don't see Secrets in here. I'm assuming at some point you're doing to need Secrets and you might need 148 00:09:34,800 --> 00:09:42,780 ‫to store those in Secret somewhere. Other than that great YAML. Definitely one of the better ones I've 149 00:09:42,780 --> 00:09:43,200 ‫seen. 150 00:09:43,200 --> 00:09:45,750 ‫I think there's very little to do here. 151 00:09:45,750 --> 00:09:51,300 ‫I think in terms of making it sort of using all the perfect features. The templating is a thing. Considering 152 00:09:51,300 --> 00:09:56,580 ‫different volume drivers and considering the new feature. If not placement preferences, the new feature 153 00:09:56,580 --> 00:10:19,110 ‫for max replicas per node. 154 00:10:19,120 --> 00:10:20,620 ‫Thanks for watching. 155 00:10:20,620 --> 00:10:26,050 ‫You can click SUBSCRIBE AND the notification bell to get an alert when I go live so you can join and 156 00:10:26,050 --> 00:10:28,110 ‫ask your Devops and Docker questions. 157 00:10:28,150 --> 00:10:32,980 ‫You can watch some of my other videos over there and you can do what I'm about to do and just go take 158 00:10:32,980 --> 00:10:33,460 ‫a nap.