In this demo, we're going to take a look at services in coconut's and the previous demo.
We created a few parts by creating a deployment.
So let's check the status of that first.
So we have a deployment called my app Dash Deployment.
And it has six replicas, which is essentially six parts running in the cabinet as cluster.
So now we have an application which is created to run on this cluster.
But in order for the end user to access it on their Web browser, we have to create a service.
And to do this, let's jump back to our editor.
We have created a new directory called Service and within the service directory.
We're going to create a new file called Service Definition Dot YAML.
Not that you don't really need to follow this directory structure as I'm doing.
I'm just following it to organize the examples.
You could simply have all the files in the same location.
And just like before, the first thing that goes in is the root element.
The API version.
And for service, it should be said to be one for kind.
We're going to specify service.
So let's look that up from the list.
And we're going to add metadata with the name of the service, which you can say my app, the service.
And this and underneath that, we're going to add the peg section.
And the first property that we will create is the type of service which we will set to node port.
Now, our goal is to be able to access our application on a port, on the node, which is the mini cube
node in our case.
And then we will add the port and the default port and which Engine X listens, which is 80.
And we're also going to add our target port, which is also port 80.
So this is basically the port on the service itself.
And next, we're going to add a node port, which we can set to a value suggests.
Thirty thousand four.
So it could be any value between thirty thousand and thirty two thousand seven hundred sixty seven.
And this node port east is the port on the node, the worker node, which is the mini cube node on which
the application will be made accessible.
Next, we're going to add a selector which helps us bind our service to the port with the same label.
So quickly, let's check the deployment YAML file and you'll notice that the label for the port is app
said to my app.
So let us add the same value here under these selector section.
So once this has been completed, our service definition file is complete and we can proceed to create
these on our clusters.
And I'm going to save it here.
And Jim, back to my terminal.
And let me navigate to the new directory that we created.
And here is our service definition file.
So I'm going to create these service using the cubicle, create command with the dash F option and specify
the service definition YAML file as the input.
I run this command and the service has been created.
We can now run the cubicle, get service command.
And here you'll notice that the new service is visible and the type of the service is node port, which
because we want it to be accessible on the port, on the worker node.
And here is a cluster IP, which is also created for the service.
Now it's an address created for the service within the Internet internal cluster network.
And here is a port on the worker node that we can use to access our application.
So if you know the IP of the worker node, you can simply go to a browser and just type in the IP of
the worker node followed by the port.
No.
And you should be able to access this application.
Now, since we are running this on many KUB now, we can also run the mini tube service command, followed
by the name of the service, which is the MAI app.
That's service and use the option that as you are.
And it should print does the euro with the service.
Where the services available.
So let's try to access this on a browser so you can just copy this.
You are l go to a browser and paste that you are all in the browser and we see that the default engine
X Web page.
So that confirms that the Engine X application is up and running and we're able to access it on a web
browser.
Well, that's it for this demo, and we'll see you in the next one.