Next up is we're going to deploy our Java image in the cluster.
We have everything ready for that so we can now create a deployment file cabinets configuration file
to do that.
It's also a common practice that usually have the community's deployment files inside the project repository
for their applications deployment.
Sometimes they also have a separate repository with all the communities configuration files there.
That's also a case, but we're going to create a YAML file for deployment in the repository of the project
itself.
So let's go and create deployment.
Yamal deployment.
So I have made the ed a little bigger, so this is going to be a very basic, simple deployment configuration
file because we don't have any external configuration for application.
It's a pretty basic one.
So this is the first part of a deployment.
We have the kind of metadata we just got to call it Java EB.
And this is the specification where we define replicas.
We can start with one, then we have the selector and here we are going to match labels.
For the parts we're going to call the Java as well, and this is the template or blueprint for the port
itself.
And here we also have the metadata, just like here.
I'm actually going to copy that.
So we have the same metadata.
We don't need the name here.
You can just use the labels metadata and spek just like here.
So here in the specification, we have the list of the containers that are going to run in the pot.
So we're going to say containers and we just have one container.
We can also call it Java, if not very creative.
But let's just have Java everywhere.
And this is where we specify the image.
Now, the image, the image URL sort to say for Java EP is actually right here.
So next to each tag, you have this command to pull the image and this is the image URL.
So let's copy that one here.
You're going to have your doctor ID the name of the repository and the tag.
That's it.
Another thing we need to configure here is ports so you can also have a list of ports in case your application
is running and listening on multiple ports.
We have exposed Port 80.
So this is the same one here.
This is where the container will listen and that will be the configuration of the deployment.
No, in order for Docker to be able to pull that image from the repository, it needs to have access
to that secret that we created.
So the Docker registry secret and the way we provide Docker, the reference to that secret inside the
deployment configuration file is using another attribute called Image Pull Secrets.
And note here that it is at the same level as containers.
So you have one for the whole port and you can use it for all the containers.
It's also a list.
We are just going to provide one here and that is going to be the name of the secret that we created.
Our secret is called Docker Registry SEKRET, and that will make it possible to pull this image from
the repository.
And the last thing we want to add here is image pool policy.
So basically, every time the port starts, we want it to pull the image in case we make some changes.
So it will force the pod to refresh the image every time it restarts.
Right.
So by default, when you have a fixed tag instead of a latest, it will check that it has that image
already pulled in a local repository.
So it won't try to refresh it from the repository, which is pretty efficient in some cases where you
always renew the tag.
But here we are just going to define image code policy.
So it always refreshes, even if that exact image version is available locally.
So let's save that.
And now we are ready to apply that deployment.
So I'm going to go back to my comment line and let's apply that file.
So it's in Java app root directory and that will be.
So the deployment got created.
So now let's check the status of our port and it's running.
We can also see the logs of the container and we should see the logs in Jason format.
And that's it.
This is what we're logging.
This is our null pointer exception.
Everything looks fine.