1 00:00:04,660 --> 00:00:09,800 ‫This is me walking through the assignment for the secrets compose file that we're going to put 2 00:00:09,800 --> 00:00:11,600 ‫in our swarm stack. 3 00:00:11,600 --> 00:00:17,070 ‫This file was left over from our previous assignment when we were dealing with Drupal. 4 00:00:17,360 --> 00:00:21,910 ‫That was under a compose assignment 2 directory. 5 00:00:22,160 --> 00:00:28,040 ‫Now I'm up at the top here, and I know we covered this previously but I didn't mention it in the slide, 6 00:00:28,550 --> 00:00:30,890 ‫is that this version needs to be 3.1. 7 00:00:31,100 --> 00:00:38,980 ‫Because a stack and swarm will not accept any secrets in a file unless it's at minimum 3.1 8 00:00:39,020 --> 00:00:40,090 ‫compose format. 9 00:00:40,280 --> 00:00:45,730 ‫The worst case, though, is if I left it at the 2 and I forgot, when I try to deploy my stack, it'll 10 00:00:45,740 --> 00:00:51,440 ‫just say, 'Sorry, cannot use compose version 2 file.' So, it'll just be pretty obvious that you need to change 11 00:00:51,440 --> 00:00:51,810 ‫it. 12 00:00:53,330 --> 00:00:58,910 ‫All right. The next one was, I needed to change this image. We're not going to build a custom image 13 00:00:58,970 --> 00:01:02,260 ‫on our stack because, remember, swarm doesn't build. 14 00:01:02,360 --> 00:01:04,480 ‫At least not in the current version. 15 00:01:04,730 --> 00:01:14,270 ‫We're going to...um...go back to the official Drupal, 8.2, because in production, we should always pin our versions. 16 00:01:15,140 --> 00:01:19,820 ‫I'm going to just get rid of this build here. Technically, in a stack, 17 00:01:19,820 --> 00:01:22,780 ‫I can leave the build command here, but it'll just ignore it. 18 00:01:22,780 --> 00:01:25,070 ‫I'll actually just tell us, 'Hey. Don't need this build. 19 00:01:25,070 --> 00:01:27,710 ‫I'm not going to use the build. I'm going to just pull down the image. 20 00:01:27,710 --> 00:01:28,580 ‫Thank you.' 21 00:01:28,580 --> 00:01:35,030 ‫We could just leave it, but I'm going to, for this example, not be distracted by that thing and just 22 00:01:35,120 --> 00:01:43,910 ‫delete that line. Then I'm going to go down here to the environment, and we need to change this because 23 00:01:43,910 --> 00:01:47,830 ‫we're no longer going to use an actual password. We're going to use the file. 24 00:01:48,350 --> 00:01:53,930 ‫Then this is so this postges is just like the previous lectures where we talked about how the official 25 00:01:53,930 --> 00:01:57,710 ‫images now have this option for the file to support secrets. 26 00:01:57,710 --> 00:02:01,980 ‫Now I just have to give it the location of the file instead of the actual secret itself. 27 00:02:02,060 --> 00:02:08,630 ‫So, run secrets and we're going to call this one psql pw. 28 00:02:09,170 --> 00:02:11,240 ‫And then I need to actually specify the secret. 29 00:02:11,230 --> 00:02:21,980 ‫So, down here, under secrets, I want to call it psql pw. Then it's going to be external, which means 30 00:02:21,980 --> 00:02:27,710 ‫that we're creating it on our own from the command line and that it's not the stack's responsibility to 31 00:02:27,710 --> 00:02:28,350 ‫create it. 32 00:02:28,350 --> 00:02:30,910 ‫This is actually just a boolean value. 33 00:02:31,100 --> 00:02:33,890 ‫So, I specify that as true. 34 00:02:34,220 --> 00:02:36,660 ‫Oh, and then I almost forgot. I go up here, 35 00:02:36,670 --> 00:02:42,140 ‫I've got to add the secrets. I have to list it. 36 00:02:42,410 --> 00:02:42,740 ‫All right. 37 00:02:42,740 --> 00:02:44,980 ‫That looks good to me. 38 00:02:44,990 --> 00:02:51,350 ‫We're going to copy this over to the server on node1 of our swarm, and then we'll give the stack 39 00:02:51,350 --> 00:02:52,340 ‫a shot. 40 00:02:52,970 --> 00:02:53,260 ‫OK. 41 00:02:53,270 --> 00:02:59,650 ‫I have copied over the compose file from my local machine, so we should be able to do a docker 42 00:02:59,640 --> 00:03:09,650 ‫stack deploy now, -c docker compose, and I'm going to call it drupal. 43 00:03:10,180 --> 00:03:13,690 ‫And that's what happens when you forget to create the secret first. 44 00:03:13,690 --> 00:03:22,030 ‫So, just like the instructions said, I'm going to create the secret, and I'm going to just put some random 45 00:03:23,260 --> 00:03:24,370 ‫characters in here. 46 00:03:28,290 --> 00:03:35,650 ‫docker secret create psql pw, pass in the value. 47 00:03:35,660 --> 00:03:36,040 ‫OK. 48 00:03:36,130 --> 00:03:40,370 ‫Now, I should be able to deploy the stack. There we go. 49 00:03:40,720 --> 00:03:47,130 ‫So, docker stack ps drupal. 50 00:03:47,390 --> 00:03:49,860 ‫I've got my postgres and my drupal. 51 00:03:49,940 --> 00:03:59,160 ‫So I should be able to bring up a browser and go to node1 8080, and there we go. 52 00:03:59,300 --> 00:04:01,830 ‫I can install a Drupal. 53 00:04:01,870 --> 00:04:04,770 ‫Let's actually test to see if that password worked. 54 00:04:05,890 --> 00:04:10,320 ‫This is not actually required, but I just want to test it anyway. 55 00:04:10,600 --> 00:04:16,300 ‫postgres...postgres...postgres... 56 00:04:16,530 --> 00:04:17,910 ‫Database password... 57 00:04:20,590 --> 00:04:24,450 ‫postgres...there it goes! It worked! 58 00:04:25,490 --> 00:04:26,300 ‫All right. 59 00:04:26,490 --> 00:04:27,120 ‫And we're done.