No important notice.
We just used imperative approach to creation of the deployments and services, and we create deployments
and services using different CubeSat commands.
But usually that's not the way how deployments and services are created, and in most cases declarative
approach is utilized.
And in declarative approach you have to create YAML configuration files which describe all the details
for deployments and services, and afterwards apply those configuration files using CubeSat to apply
command.
And that's actually declarative approach of creation of different resources and objects in Kubernetes.
And that's what we will do right now.
Let's not delete both deployment and service, which we created before.
And for that you could utilize command, cube style, delete deployment and afterwards delete service.
But there is also short version of deletion of all resources in default namespace and it is delete all
with option.
There's dash all like that.
All the resources will be deleted.
You'll see that posts were deleted, service was deleted, and deployment was deleted as well.
Let's get both.
Both are still being terminated.
Let's check again.
Still terminating.
Let's wait a bit.
And now there are no resources found in default namespace.
All ports were terminated.
Let's get services k, get SBC.
And now there was only a single default system service, Kubernetes.
And of course, there are no deployments.
Get, get, deploy.
No resources found.
Now let's create YAML configuration file for deployment and for service trust.
We will create two separate configuration files.
Let's go to Visual Studio code.
And here let me, by the way, hide and by the terminal for the moment and let me close those all windows.
And now here, let's collapse this folder gate as web.
Hello, because this folder was dedicated to our Node.js Express Web application.
And now here in the root of the k8s folder here, let's create following files deployment.
But YAML and also let's create file service, not yaml like that.
So two files deployment, yaml and service dot yaml.
Let's first fill in deployment yaml file.
If you installed Kubernetes extension here in voice code, what I asked you to do before you could create
such configuration files very fast.
Let me show you.
So type here.
Simply deployment.
And you will see suggestion Kubernetes deployment.
Let's select it and you will see that YAML configuration file will be created automatically for you.
And you will see that all appearances of the make up will be highlighted and you could simply type the
name of the deployment which you would like to set, and let's set name to K eight as same as we did
before.
But now we are using yaml configuration file.
So K eight as well.
Hello.
Like that deployment name was set here.
Was actual name for this deployment.
Here was api version ops slash.
The one here was selector with match labeled sku.
And by this match label scheme, we specify which ports will be managed by this deployment.
And below there is nested template and this template describes actually port.
But here you don't need to specify kind of the template like that because this nested template for deployment
template is always port, therefore kind here is not needed next for the ports which belong to this
deployment here we set labels and label here is the same as label here in selector match labels.
So this label and this label match here and next in spec key, we specify which containers we want to
create in this port and there was just a single container with such name.
Image is to be filled.
We will replace this image placeholder now with real image.
And also below you could specify which ports you would like to open in specific container.
And below in the port section you could specify a list of the container ports which will be open on
the post IP address.
So let's feel now the details in this spec section image will be vista slash k8s web.
Hello.
And the ports here will be container port 3000 like that.
Also notice that via code Kubernetes extension added resources section here and in this section there
was limits key which specify memory and CPU limits for each port which will be created by this deployment.
And here we limit amount of memory and amount of CPU resources.
500 MB means half of the CPU core.
If you want, you could modify a 500 to 250, for example, one fourth of the CPU core.
Let's keep it like that.
And that's it for this specification of the deployment.