In this demo, we're going to deploy the voting application on our mini cluster.
So here have created a new project folder called Voting App.
So the first thing that we are going to do is to create the pod definition files for each component
within the application.
So let's begin with the voting app itself.
So we will name this part definition file as voting app pod camel.
And let us build this pod from scratch.
So we will begin with the API version and set it to V1 and the kind.
We'll be pod.
The method section would have the name she'll be watching App Dash Pod.
And let's add a couple of labels.
The first label would be the name, which can be the same as the name of the pod, which is voting at
Dash Pod.
And the second label will be.
The name of the application, which is the demo voting app, so we'll kind of use that label for all
the components part of this application stack.
That way we can group the components of a single application together by assigning the same kind of
label to all of them.
But there will still be a different label for each component to differentiate from each other.
So let's add the specked section and here the first thing that we're going to add is the name of the
container.
So we'll use voting app as the name of the container and the image we will make use of the custom image
that we have built from the Docker samples budding app, get a repository page, which is here.
So we will use the custom images that we built under the code cloud docker hub repository.
The name of the image here is called cloud slash example voting app underscore vote.
With Attack of me one.
Now, we will also specify the port for this voting application as a container port property.
So this should be the port on which the application listens for this voting app.
And we know that its port 80.
So we'll send it to port 80 next.
Let's create the port definition file for the result app.
So, again, I'm going to create a new file here called a Result App Port.
And because this is a pod definition file like like before we can simply copy the template from the
voting app file we just created and then we will just make changes to the name and labels and the image.
So let us change the name to a result app pod and we will make the same change to the label and then
the app label will remain the same as all of these are part of the same app.
And again, let's make the change to the container name to result app.
And here the image will also be changed to code cloud slash example voting app underscore result with
the same tag off we want.
And the result application is also exposed on the container port 80.
So we will leave that assess.
Next, let's create the pod definition file for the reddest pod.
So I'm going to name the pod definition file as Radice Dashboard.
Yamal.
And again, I'm going to make use of the previous part as the template.
And we will change the name of the pod.
So we'll change it to read his part.
And we will use the same as the label.
And let's name the container as redis and the inmates should be also be read as.
And the container port for it is we will change it from Port 80 to six three seven nine, because this
is the default port for the Redus image.
So let's save this and now let's create another part.
Now, this time for our database will name it.
Postgrads Dashboard.
YAML.
And as before, we are going to copy paste one of the pod definition files here and we'll make changes
to the name.
So this one will be progress dashboard and the same for the label.
Now, the name of the container would be post.
And the image we can also use the postcard image itself without any tag, which means that it will make
use of the latest postgrads image.
The container port for post Chris Cual database is five, four, three, two by default.
So we will add that in.
And we also have to add a couple of other environment variables here.
So this is to make sure that we specify the postcrisis username and password for the database.
So as we saw in the previous lecture, the source code of the worker and the result part has the password
for the post PostgreSQL database hardcoded in them.
So we must specify the initial password to be set for the database here as environment variables.
A better way to do this would be to use secrets or some kind of world to passing these credentials and
not have these credentials in a plain text format, in a file.
But those are out of scope for this.
We discuss about these concepts in much detail in our advanced courses on CORONETS, they seek ANC 80
courses.
We discuss about environment variables, services, secrets and other concepts.
So for this example, to work, we have to make sure that we specify these two environment variables
in the Postgres put definition file.
So for this, we will make use of an IAN resection, which is a list of dictionaries, and we will have
the environment, variable name and value entered in them.
So it must be postgrads and score user for the user name.
And postgrads and his core password in and as a password, all in caps.
Now, the value for Bolt would just be PostgreSQL.
For now.
And again, just to retrade, we are adding these values because the work report and the result pod
uses these credentials while connecting to the database.
And if you don't configure these, the worker will not be able to connect to the database.
And as a result, the total voting count may not add up.
All right.
So in case you run into issues with the vote count not updating, I'm not able to view the results then.
This is probably an area that you can check.
So now we've created four parts.
The postscripts part, the red is board the two front and application parts.
The result and the voting at the last one is the worker pod.
So let's create a new file for the worker pod.
Our reporter Yamal and I'm going to copy paste the definition file.
So in here, let's make changes to the name.
So let's change the name to work report and the same for labels and the name of the container will be
worker app.
And the image is a worker instead of vote.
And one important change here is that we must remove the ports section because, as we discussed, the
worker app has no services listening.
So no port definition is required.
So as a result, we can delete this entire section over here.
So we now have five definition files for all our micro services.
Next, we will create services to expose these parts except for the for the worker.
So let's get that going.
Let's start by creating the service definition files.
So let's start with one of the internal services, which is redis.
So we'll call the file as ready as Dasch Service or Yamal.
So we will start with the API version, which is we want and the kind is service.
Let's add the metadata.
And the name of the service we will use as readies itself.
So remember that this is important and will add a couple of labels.
The name would be said to reduce is service.
And the second one is the one we have been using for all the other objects, which is demo voting app.
Now, next, we will add the specs section, and within this we will add the ports.
So for readers, we know that the port to be used is six three seven nine.
And we'll also add the target port, which is also going to be six three seven nine.
Now, we don't need to specify anything else like a node port because this is going to be an internal
service.
Now, let us add the selector.
So in order to link the service to the port, we must specify the same labels configured for the port.
So let's copy the labels from the pod definition file and we'll pasted under these electrode section.
Now, since this is an internal service, we're not going to expose it outside on the network.
So that should be good.
So this file is now complete, so let's save it.
And next, we will proceed with the creation of the Post Chris service.
So now let us create the Post Credit Service file.
We'll follow the same approach as before.
Will name this as post Chris service dot yaml.
And the easiest way to create a service and now is to just copy the contents of the ready service file
and pasted here.
So again, we will make the appropriate change.
So if you remember the architecture from the lecture.
The name of the Postgres database must be DBI.
So this is because a worker app expects the name of the process postgrads database to be DBI.
So if you name it anything else, you'll find that the connection will fail.
So I will now change the labels.
These labels could really be anything.
So it doesn't really matter.
Let's name it as postgrads service and we can even name it as DBI service.
And let's change the port to five, four, three, two, because that's the port and miss the post,
Chris databased runs and again, this will be five, four, three, five, four, three, two.
And let's make sure that we copy the labels from the pod definition file.
So here we will copy the name label, which is set to post Chris Pod.
So let's delete the older selectors and the labels and then replace it with a new one.
So now we're done with the two internal services.
Let's now proceed to creating the external facing services, which is the voting service and the result
service.
So let's start with the Voting App Service.
Let's create a new file called Voting App Service.
Start YAML and we will copy the contents of the other file and then paste it here.
Again, let's change the name to voting service.
Let's change the label as well.
And we we know that this is a front and application which runs on Port 80.
So let's set that port no as a service port and as the target put.
And as before, we'll copy the labels from the definition file.
So the next step would be to create the final service, which is the result service.
So let's call the file as a result of that service Dot Yamal and that's copy the voting App Service
definition file into here.
And then again, we changed the name to result and everything else is the same.
And we will update the this electrode section with the labels off the pod, the result pod.
We actually created them as internal services like the others.
Now we've created the voting app and result app service as internal services like like the others.
But they're supposed to be externally accessible.
So we must set there Type two node port.
So since we have not specified any type, it would be considered as cluster IP.
So let's do that now.
And each service.
Requires will set the type to note notochord, and each service also requires an additional port specification
for the node port.
And we will set that to thirty thousand four for the voting app.
Can now we will go and update the same on the result service.
So we will set the type to know the port.
And we will add a node port port.
Number of thirty thousand five for the result up service.
OK.
So we are done with all the all the files and we have completed the creation of the port and service
Yamal definition files, and we will now proceed with the creation of these objects and we'll then try
to access the application on the Web browser.
So we will switch to the terminal of our system and we are in the voting app directory, which is where
we created all the port and service definition files.
So now we can start creating these objects.
So first, let's check if there are any port or deployments or services running on the server.
So when we see we see that there are there is nothing except for the default community service.
There is there's nothing else running.
So let's start with the port and the service for the voting application.
Right.
So we'll start with one by one and we'll test to make sure that they're working as expected.
And then we'll proceed further.
So to create the pod, we will use the code to create command and specify the pod definition file.
And similarly, let's create the service using the service definition file for voting app.
So let us know, inspect the status of the pod and service.
So if we want to see the pod and the service in a single command, we can run the cube, could get parts
command and specify the service as SBC and separated by a comma.
And so it would list both the objects.
So we can see that the service for the wedding app is created.
And it is of type node port.
And the port is also created.
And it is in the running state.
Now, before we proceed further, let's test to see if that bit is working right.
So what we could do is simply access the Voting App Service using a new RL, which could be formed by
the IP of the mini cube node.
So if you know the IP, you could just use the port number, which is thirty thousand zero for the port
number of the service and viewed in the browser.
Or if you're not sure about the IP, you could run the command mini cube service and specify the name
of the service with the desk that you are all option.
And it'll give you the URL that you can use.
So we will copy the URL and we will try to access this in our local browser on my system.
So here I am at your local browser and I'm going to try and access this.
And as you can see, we are now able to load the voting application.
So that's that's one step which is complete.
Now, let's not try and cast any vote for now as we don't have the databases ready.
Now, let's go ahead and create the remaining objects, the parts and services.
So back to the terminal.
The next port and service that we created is the reddest part.
So we run the Cube Cuttle create command with the reddest part definition file.
And then the service file.
And that's before we run the coop to get parts and service command.
And as you can see, the red is part and service are created.
The service is now the cluster i.p because this is an internal service.
And let's create the Postgres database.
Now.
We'll create the Postgres database with the Postgrads definition file.
And as well as the service definition file for creating the service, again, let's check the status
and we can see that the post cross board is in the running state and similar to the aready service.
We can see also that the postgrads service is up as well with its name set to DBE.
Right.
So now that both are redis and postgrads parts and services are up and running, we can now create the
worker pod.
And to do this.
We will use the cubicle, create command with the work report definition file.
So let's check the status of the pod, and I can see that the worker pod is also now in there running
state.
Now, finally, let us create the pod and service for our result application.
So let's do the same thing as before.
Keep on the cuddle.
Create a result up command and let us run the create the result app service as well.
OK.
So now let's check the status of all the parts and services.
And now you can see that all of our five parts are up and running and we can see that we have to node
port services, one for our cell service and one for our wedding service.
The other two services that we created are De Redis and Atabay service, which are internal only.
So we've already accessed the voting application.
Let us also generate the euro for our result service.
So for that, I'm going to use the same commanders before the mini of service.
Wedding Service Command will give us a euro to access our voting app and let us change the name here
to get the.
There you are.
All of the result.
So we now have both the worlds.
So let's go back to our Web page.
And here we have the voting application, which is running on port.
Thirty thousand four.
Let's copy and paste the new URL.
So this is going to be thirty thousand five.
So let's try and cast a vote here.
So I'm going to click on the dogs selection.
And here you can see that there's a checkmark against the vote that we selected, which indicates that
our vote has been recorded.
Now, as it has been saved in the red, this database and you can also see that below that there is
this particular Web page is being processed by the voting app pod.
Now, if you go to the results page, you can see that the dog's application has 100 percent of votes
because in this case, we just have one vote and that was for dogs.
And I can also change that.
What if I if I won?
So.
I could go back and click on Cats and I can see that and the result has changed to cats.
So that's our demo.
We have successfully deployed a multi-tier application on a governance cluster and we have confirmed
that it's working right.
So the data actually goes through from one end all the way to the through the British database, to
the work report, to the PostgreSQL database and to the result pod.
So it's working as expected.
Well, that's it for now.
And I will see you in the next one.