WEBVTT 00:00.540 --> 00:06.090 In this demo, we're going to deploy the voting application on our mini cluster. 00:06.840 --> 00:10.650 So here have created a new project folder called Voting App. 00:11.100 --> 00:17.400 So the first thing that we are going to do is to create the pod definition files for each component 00:17.460 --> 00:18.540 within the application. 00:19.320 --> 00:21.240 So let's begin with the voting app itself. 00:21.300 --> 00:27.780 So we will name this part definition file as voting app pod camel. 00:28.880 --> 00:31.820 And let us build this pod from scratch. 00:31.850 --> 00:36.950 So we will begin with the API version and set it to V1 and the kind. 00:37.040 --> 00:37.910 We'll be pod. 00:40.280 --> 00:45.500 The method section would have the name she'll be watching App Dash Pod. 00:47.190 --> 00:49.450 And let's add a couple of labels. 00:49.630 --> 00:55.620 The first label would be the name, which can be the same as the name of the pod, which is voting at 00:55.630 --> 00:56.440 Dash Pod. 00:56.980 --> 00:59.320 And the second label will be. 01:00.590 --> 01:06.920 The name of the application, which is the demo voting app, so we'll kind of use that label for all 01:06.920 --> 01:08.960 the components part of this application stack. 01:08.990 --> 01:15.440 That way we can group the components of a single application together by assigning the same kind of 01:15.440 --> 01:16.440 label to all of them. 01:17.490 --> 01:22.890 But there will still be a different label for each component to differentiate from each other. 01:23.640 --> 01:30.150 So let's add the specked section and here the first thing that we're going to add is the name of the 01:30.150 --> 01:30.720 container. 01:31.290 --> 01:36.960 So we'll use voting app as the name of the container and the image we will make use of the custom image 01:36.960 --> 01:43.170 that we have built from the Docker samples budding app, get a repository page, which is here. 01:43.500 --> 01:48.720 So we will use the custom images that we built under the code cloud docker hub repository. 01:49.260 --> 01:54.360 The name of the image here is called cloud slash example voting app underscore vote. 01:59.320 --> 02:01.360 With Attack of me one. 02:03.150 --> 02:09.030 Now, we will also specify the port for this voting application as a container port property. 02:09.150 --> 02:14.040 So this should be the port on which the application listens for this voting app. 02:14.070 --> 02:15.450 And we know that its port 80. 02:15.540 --> 02:18.430 So we'll send it to port 80 next. 02:18.660 --> 02:21.450 Let's create the port definition file for the result app. 02:21.810 --> 02:26.190 So, again, I'm going to create a new file here called a Result App Port. 02:26.250 --> 02:34.290 And because this is a pod definition file like like before we can simply copy the template from the 02:34.290 --> 02:41.550 voting app file we just created and then we will just make changes to the name and labels and the image. 02:41.940 --> 02:49.740 So let us change the name to a result app pod and we will make the same change to the label and then 02:51.120 --> 02:55.020 the app label will remain the same as all of these are part of the same app. 02:55.080 --> 03:00.390 And again, let's make the change to the container name to result app. 03:00.900 --> 03:07.830 And here the image will also be changed to code cloud slash example voting app underscore result with 03:07.830 --> 03:09.360 the same tag off we want. 03:09.730 --> 03:13.200 And the result application is also exposed on the container port 80. 03:13.440 --> 03:15.570 So we will leave that assess. 03:16.620 --> 03:20.170 Next, let's create the pod definition file for the reddest pod. 03:20.280 --> 03:24.480 So I'm going to name the pod definition file as Radice Dashboard. 03:24.720 --> 03:25.140 Yamal. 03:26.810 --> 03:30.230 And again, I'm going to make use of the previous part as the template. 03:31.390 --> 03:33.370 And we will change the name of the pod. 03:38.130 --> 03:40.090 So we'll change it to read his part. 03:40.170 --> 03:42.600 And we will use the same as the label. 03:44.180 --> 03:48.800 And let's name the container as redis and the inmates should be also be read as. 03:54.110 --> 04:00.080 And the container port for it is we will change it from Port 80 to six three seven nine, because this 04:00.080 --> 04:02.500 is the default port for the Redus image. 04:03.530 --> 04:06.850 So let's save this and now let's create another part. 04:06.920 --> 04:09.670 Now, this time for our database will name it. 04:10.460 --> 04:11.550 Postgrads Dashboard. 04:11.780 --> 04:12.230 YAML. 04:14.120 --> 04:19.250 And as before, we are going to copy paste one of the pod definition files here and we'll make changes 04:19.250 --> 04:19.790 to the name. 04:23.680 --> 04:27.550 So this one will be progress dashboard and the same for the label. 04:34.420 --> 04:37.190 Now, the name of the container would be post. 04:37.630 --> 04:44.320 And the image we can also use the postcard image itself without any tag, which means that it will make 04:44.320 --> 04:46.300 use of the latest postgrads image. 04:46.870 --> 04:52.900 The container port for post Chris Cual database is five, four, three, two by default. 04:53.350 --> 04:54.520 So we will add that in. 04:54.940 --> 04:57.950 And we also have to add a couple of other environment variables here. 04:57.970 --> 05:03.190 So this is to make sure that we specify the postcrisis username and password for the database. 05:04.630 --> 05:10.630 So as we saw in the previous lecture, the source code of the worker and the result part has the password 05:10.630 --> 05:14.260 for the post PostgreSQL database hardcoded in them. 05:14.290 --> 05:20.170 So we must specify the initial password to be set for the database here as environment variables. 05:22.880 --> 05:31.580 A better way to do this would be to use secrets or some kind of world to passing these credentials and 05:31.580 --> 05:36.440 not have these credentials in a plain text format, in a file. 05:36.830 --> 05:39.720 But those are out of scope for this. 05:40.370 --> 05:46.880 We discuss about these concepts in much detail in our advanced courses on CORONETS, they seek ANC 80 05:46.880 --> 05:47.450 courses. 05:47.930 --> 05:53.480 We discuss about environment variables, services, secrets and other concepts. 05:54.050 --> 05:59.210 So for this example, to work, we have to make sure that we specify these two environment variables 05:59.270 --> 06:01.750 in the Postgres put definition file. 06:01.790 --> 06:09.860 So for this, we will make use of an IAN resection, which is a list of dictionaries, and we will have 06:09.860 --> 06:13.580 the environment, variable name and value entered in them. 06:13.940 --> 06:18.050 So it must be postgrads and score user for the user name. 06:20.690 --> 06:25.950 And postgrads and his core password in and as a password, all in caps. 06:26.070 --> 06:29.630 Now, the value for Bolt would just be PostgreSQL. 06:29.940 --> 06:30.420 For now. 06:31.840 --> 06:37.310 And again, just to retrade, we are adding these values because the work report and the result pod 06:37.760 --> 06:40.340 uses these credentials while connecting to the database. 06:40.430 --> 06:44.390 And if you don't configure these, the worker will not be able to connect to the database. 06:44.510 --> 06:49.970 And as a result, the total voting count may not add up. 06:50.630 --> 06:50.920 All right. 06:51.380 --> 06:58.330 So in case you run into issues with the vote count not updating, I'm not able to view the results then. 06:58.520 --> 07:01.490 This is probably an area that you can check. 07:02.540 --> 07:04.880 So now we've created four parts. 07:05.690 --> 07:10.060 The postscripts part, the red is board the two front and application parts. 07:10.460 --> 07:14.280 The result and the voting at the last one is the worker pod. 07:14.960 --> 07:17.360 So let's create a new file for the worker pod. 07:17.600 --> 07:21.170 Our reporter Yamal and I'm going to copy paste the definition file. 07:28.800 --> 07:31.500 So in here, let's make changes to the name. 07:31.950 --> 07:38.990 So let's change the name to work report and the same for labels and the name of the container will be 07:39.000 --> 07:39.750 worker app. 07:39.840 --> 07:43.770 And the image is a worker instead of vote. 07:48.930 --> 07:55.570 And one important change here is that we must remove the ports section because, as we discussed, the 07:55.570 --> 07:58.040 worker app has no services listening. 07:58.510 --> 08:00.910 So no port definition is required. 08:01.630 --> 08:05.710 So as a result, we can delete this entire section over here. 08:07.270 --> 08:12.250 So we now have five definition files for all our micro services. 08:12.460 --> 08:18.610 Next, we will create services to expose these parts except for the for the worker. 08:18.670 --> 08:19.810 So let's get that going. 08:20.830 --> 08:24.250 Let's start by creating the service definition files. 08:25.330 --> 08:29.040 So let's start with one of the internal services, which is redis. 08:29.170 --> 08:33.060 So we'll call the file as ready as Dasch Service or Yamal. 08:35.830 --> 08:40.570 So we will start with the API version, which is we want and the kind is service. 08:43.660 --> 08:45.400 Let's add the metadata. 08:47.160 --> 08:50.890 And the name of the service we will use as readies itself. 08:52.470 --> 08:56.970 So remember that this is important and will add a couple of labels. 08:57.690 --> 09:00.460 The name would be said to reduce is service. 09:00.930 --> 09:06.800 And the second one is the one we have been using for all the other objects, which is demo voting app. 09:07.770 --> 09:13.950 Now, next, we will add the specs section, and within this we will add the ports. 09:14.820 --> 09:19.930 So for readers, we know that the port to be used is six three seven nine. 09:20.100 --> 09:24.720 And we'll also add the target port, which is also going to be six three seven nine. 09:25.350 --> 09:30.240 Now, we don't need to specify anything else like a node port because this is going to be an internal 09:30.240 --> 09:30.720 service. 09:31.560 --> 09:33.720 Now, let us add the selector. 09:34.200 --> 09:40.260 So in order to link the service to the port, we must specify the same labels configured for the port. 09:40.470 --> 09:45.810 So let's copy the labels from the pod definition file and we'll pasted under these electrode section. 09:49.230 --> 09:54.030 Now, since this is an internal service, we're not going to expose it outside on the network. 09:54.060 --> 09:55.470 So that should be good. 09:55.650 --> 09:58.830 So this file is now complete, so let's save it. 09:58.890 --> 10:02.640 And next, we will proceed with the creation of the Post Chris service. 10:02.670 --> 10:05.670 So now let us create the Post Credit Service file. 10:06.210 --> 10:08.520 We'll follow the same approach as before. 10:08.550 --> 10:11.960 Will name this as post Chris service dot yaml. 10:12.600 --> 10:17.610 And the easiest way to create a service and now is to just copy the contents of the ready service file 10:17.640 --> 10:18.540 and pasted here. 10:19.020 --> 10:20.850 So again, we will make the appropriate change. 10:20.860 --> 10:23.190 So if you remember the architecture from the lecture. 10:23.670 --> 10:26.720 The name of the Postgres database must be DBI. 10:27.030 --> 10:31.760 So this is because a worker app expects the name of the process postgrads database to be DBI. 10:31.800 --> 10:36.270 So if you name it anything else, you'll find that the connection will fail. 10:36.300 --> 10:39.210 So I will now change the labels. 10:40.380 --> 10:42.030 These labels could really be anything. 10:42.060 --> 10:43.560 So it doesn't really matter. 10:44.220 --> 10:49.560 Let's name it as postgrads service and we can even name it as DBI service. 10:50.820 --> 10:56.740 And let's change the port to five, four, three, two, because that's the port and miss the post, 10:56.740 --> 11:01.420 Chris databased runs and again, this will be five, four, three, five, four, three, two. 11:01.860 --> 11:05.200 And let's make sure that we copy the labels from the pod definition file. 11:05.230 --> 11:09.460 So here we will copy the name label, which is set to post Chris Pod. 11:10.420 --> 11:15.880 So let's delete the older selectors and the labels and then replace it with a new one. 11:16.660 --> 11:20.530 So now we're done with the two internal services. 11:21.100 --> 11:26.210 Let's now proceed to creating the external facing services, which is the voting service and the result 11:26.210 --> 11:26.770 service. 11:27.670 --> 11:30.190 So let's start with the Voting App Service. 11:30.220 --> 11:32.570 Let's create a new file called Voting App Service. 11:32.580 --> 11:37.300 Start YAML and we will copy the contents of the other file and then paste it here. 11:45.210 --> 11:47.330 Again, let's change the name to voting service. 11:47.400 --> 11:49.290 Let's change the label as well. 11:49.320 --> 11:53.690 And we we know that this is a front and application which runs on Port 80. 11:53.770 --> 11:59.700 So let's set that port no as a service port and as the target put. 12:02.630 --> 12:08.480 And as before, we'll copy the labels from the definition file. 12:15.260 --> 12:19.650 So the next step would be to create the final service, which is the result service. 12:19.710 --> 12:26.580 So let's call the file as a result of that service Dot Yamal and that's copy the voting App Service 12:26.820 --> 12:28.530 definition file into here. 12:31.330 --> 12:35.950 And then again, we changed the name to result and everything else is the same. 12:36.340 --> 12:43.990 And we will update the this electrode section with the labels off the pod, the result pod. 12:45.310 --> 12:49.360 We actually created them as internal services like the others. 12:49.970 --> 12:56.140 Now we've created the voting app and result app service as internal services like like the others. 12:56.470 --> 12:58.760 But they're supposed to be externally accessible. 12:58.840 --> 13:01.460 So we must set there Type two node port. 13:02.050 --> 13:07.170 So since we have not specified any type, it would be considered as cluster IP. 13:07.660 --> 13:08.740 So let's do that now. 13:09.010 --> 13:09.970 And each service. 13:11.210 --> 13:19.970 Requires will set the type to note notochord, and each service also requires an additional port specification 13:20.360 --> 13:21.590 for the node port. 13:21.680 --> 13:26.120 And we will set that to thirty thousand four for the voting app. 13:27.790 --> 13:31.870 Can now we will go and update the same on the result service. 13:31.930 --> 13:35.490 So we will set the type to know the port. 13:36.020 --> 13:38.390 And we will add a node port port. 13:38.540 --> 13:43.040 Number of thirty thousand five for the result up service. 13:45.650 --> 13:45.870 OK. 13:45.960 --> 13:51.750 So we are done with all the all the files and we have completed the creation of the port and service 13:52.080 --> 13:58.830 Yamal definition files, and we will now proceed with the creation of these objects and we'll then try 13:58.830 --> 14:01.950 to access the application on the Web browser. 14:03.080 --> 14:09.950 So we will switch to the terminal of our system and we are in the voting app directory, which is where 14:09.950 --> 14:12.560 we created all the port and service definition files. 14:13.070 --> 14:15.410 So now we can start creating these objects. 14:15.620 --> 14:21.020 So first, let's check if there are any port or deployments or services running on the server. 14:21.650 --> 14:27.170 So when we see we see that there are there is nothing except for the default community service. 14:27.700 --> 14:29.360 There is there's nothing else running. 14:29.870 --> 14:34.670 So let's start with the port and the service for the voting application. 14:34.930 --> 14:35.090 Right. 14:35.510 --> 14:40.850 So we'll start with one by one and we'll test to make sure that they're working as expected. 14:41.000 --> 14:43.310 And then we'll proceed further. 14:43.850 --> 14:50.060 So to create the pod, we will use the code to create command and specify the pod definition file. 14:50.750 --> 14:55.610 And similarly, let's create the service using the service definition file for voting app. 14:57.120 --> 15:00.110 So let us know, inspect the status of the pod and service. 15:00.150 --> 15:07.130 So if we want to see the pod and the service in a single command, we can run the cube, could get parts 15:07.140 --> 15:12.600 command and specify the service as SBC and separated by a comma. 15:12.930 --> 15:15.750 And so it would list both the objects. 15:16.500 --> 15:20.670 So we can see that the service for the wedding app is created. 15:20.700 --> 15:22.290 And it is of type node port. 15:22.410 --> 15:24.750 And the port is also created. 15:24.780 --> 15:26.310 And it is in the running state. 15:27.380 --> 15:32.430 Now, before we proceed further, let's test to see if that bit is working right. 15:32.480 --> 15:39.530 So what we could do is simply access the Voting App Service using a new RL, which could be formed by 15:39.530 --> 15:41.930 the IP of the mini cube node. 15:42.050 --> 15:48.000 So if you know the IP, you could just use the port number, which is thirty thousand zero for the port 15:48.020 --> 15:50.960 number of the service and viewed in the browser. 15:51.350 --> 15:58.070 Or if you're not sure about the IP, you could run the command mini cube service and specify the name 15:58.070 --> 16:01.310 of the service with the desk that you are all option. 16:01.970 --> 16:04.520 And it'll give you the URL that you can use. 16:04.550 --> 16:10.790 So we will copy the URL and we will try to access this in our local browser on my system. 16:11.240 --> 16:14.540 So here I am at your local browser and I'm going to try and access this. 16:14.570 --> 16:18.290 And as you can see, we are now able to load the voting application. 16:18.470 --> 16:21.710 So that's that's one step which is complete. 16:22.250 --> 16:26.780 Now, let's not try and cast any vote for now as we don't have the databases ready. 16:27.590 --> 16:31.490 Now, let's go ahead and create the remaining objects, the parts and services. 16:31.520 --> 16:32.600 So back to the terminal. 16:32.630 --> 16:37.700 The next port and service that we created is the reddest part. 16:37.730 --> 16:42.050 So we run the Cube Cuttle create command with the reddest part definition file. 16:42.110 --> 16:43.400 And then the service file. 16:45.110 --> 16:49.390 And that's before we run the coop to get parts and service command. 16:49.690 --> 16:53.110 And as you can see, the red is part and service are created. 16:53.770 --> 16:57.700 The service is now the cluster i.p because this is an internal service. 16:58.370 --> 17:00.910 And let's create the Postgres database. 17:01.050 --> 17:01.280 Now. 17:03.030 --> 17:07.820 We'll create the Postgres database with the Postgrads definition file. 17:10.370 --> 17:16.130 And as well as the service definition file for creating the service, again, let's check the status 17:16.220 --> 17:22.310 and we can see that the post cross board is in the running state and similar to the aready service. 17:22.820 --> 17:31.160 We can see also that the postgrads service is up as well with its name set to DBE. 17:32.420 --> 17:32.580 Right. 17:32.760 --> 17:39.210 So now that both are redis and postgrads parts and services are up and running, we can now create the 17:39.390 --> 17:40.110 worker pod. 17:40.640 --> 17:41.250 And to do this. 17:41.280 --> 17:46.130 We will use the cubicle, create command with the work report definition file. 17:50.320 --> 17:57.370 So let's check the status of the pod, and I can see that the worker pod is also now in there running 17:57.370 --> 17:57.730 state. 17:59.260 --> 18:02.980 Now, finally, let us create the pod and service for our result application. 18:03.070 --> 18:05.290 So let's do the same thing as before. 18:05.770 --> 18:07.800 Keep on the cuddle. 18:08.590 --> 18:16.180 Create a result up command and let us run the create the result app service as well. 18:17.590 --> 18:17.840 OK. 18:17.930 --> 18:21.950 So now let's check the status of all the parts and services. 18:22.370 --> 18:29.030 And now you can see that all of our five parts are up and running and we can see that we have to node 18:29.330 --> 18:34.340 port services, one for our cell service and one for our wedding service. 18:35.300 --> 18:40.400 The other two services that we created are De Redis and Atabay service, which are internal only. 18:41.190 --> 18:44.060 So we've already accessed the voting application. 18:44.420 --> 18:48.530 Let us also generate the euro for our result service. 18:49.250 --> 18:53.330 So for that, I'm going to use the same commanders before the mini of service. 18:53.480 --> 19:01.160 Wedding Service Command will give us a euro to access our voting app and let us change the name here 19:02.010 --> 19:03.010 to get the. 19:03.100 --> 19:03.560 There you are. 19:03.560 --> 19:04.580 All of the result. 19:05.390 --> 19:06.950 So we now have both the worlds. 19:07.610 --> 19:10.490 So let's go back to our Web page. 19:10.760 --> 19:13.890 And here we have the voting application, which is running on port. 19:14.110 --> 19:15.220 Thirty thousand four. 19:16.150 --> 19:19.970 Let's copy and paste the new URL. 19:24.190 --> 19:27.340 So this is going to be thirty thousand five. 19:28.060 --> 19:31.750 So let's try and cast a vote here. 19:31.900 --> 19:34.920 So I'm going to click on the dogs selection. 19:35.730 --> 19:40.780 And here you can see that there's a checkmark against the vote that we selected, which indicates that 19:40.780 --> 19:42.550 our vote has been recorded. 19:43.030 --> 19:51.080 Now, as it has been saved in the red, this database and you can also see that below that there is 19:51.100 --> 19:54.820 this particular Web page is being processed by the voting app pod. 19:55.510 --> 20:03.220 Now, if you go to the results page, you can see that the dog's application has 100 percent of votes 20:03.550 --> 20:06.790 because in this case, we just have one vote and that was for dogs. 20:07.480 --> 20:08.980 And I can also change that. 20:09.070 --> 20:10.320 What if I if I won? 20:10.390 --> 20:10.720 So. 20:11.910 --> 20:17.010 I could go back and click on Cats and I can see that and the result has changed to cats. 20:17.820 --> 20:18.690 So that's our demo. 20:19.470 --> 20:25.320 We have successfully deployed a multi-tier application on a governance cluster and we have confirmed 20:25.590 --> 20:26.920 that it's working right. 20:27.510 --> 20:33.270 So the data actually goes through from one end all the way to the through the British database, to 20:33.270 --> 20:39.200 the work report, to the PostgreSQL database and to the result pod. 20:39.270 --> 20:41.730 So it's working as expected. 20:42.330 --> 20:43.440 Well, that's it for now. 20:43.590 --> 20:45.370 And I will see you in the next one.