Blend for this next step is following the rules.
We will create no GS Express Web application and we will configure our web server in such a way that
it will respond with the hostname of the server when we connect to it using a route URL and in such
a way we will be able to distinguish which bot actually answers specific request.
We will also tokenize such application using a docker file and docker build command and afterwards push
build docker image to Docker hub.
And finally we will create deployment using such custom built image, you could find all final project
files in the GitHub repository.
You will find link to it right now here, but I highly recommend to you to create such an application
yourself, even if you don't know much about no GPRS and express.
And of course I recommend to you to build your custom image and push it to your Docker hub account.
Of course you could utilize images available under my account.
They are public.
It's up to you.
So let's now open a Visual Studio code.
If you don't have it, please install it.
I'll open it up.
And here in the Visual Studio code, please open up, embed a terminal press key combination control
back like that terminal was opened and now let's create folder for our project files LCD to desktop
and here using make directory command I'll create folder k8s stands for Kubernetes as you already know.
Let's see it to k8s folder and you could open any folder using code dot command if you correctly installed
Visual Studio code.
If such a command is not available on your computer, you could press key combination command shift
P or control shift p on windows and here enter code and select shell command install code command in
path and afterwards Code Command will be available from any terminal.
So I have this command already available in the path.
That's why I'll open k8s folder in the Visual Studio.
Code Editor So code dot.
It will be opened in the new window like that.
Now this folder is completely empty and has no files.
Let me again open.
And by the terminal here it will be opened in k8s folder.
And now here let's create folder for our first project.
And this folder name will be, let's say k8s.
That's Web desk.
Hello.
Because we will build very basic web application which will simply respond hello from server and server
name.
So k8s web.
Hello.
And here in this folder we will create Node.js application.
Let's here in the terminal city to k8s web.
Hello folder.
Like that.
And here first we will initialize node g's application.
And in order to do so, you have to install NPM on your computer.
If you don't have no g's and and PM available, please go to Node.js download.
Here is a link.
Download Node.js and install Node.js on your computer.
It will be installed along with an RPM.
Of course, we will not run applications using Node.js on our computers.
We will run application inside of the container in the Kubernetes cluster instead.
But in order to initialize project locally and install dependencies, you have to use NPM.
So therefore please install node.js along with NPM afterwards and PM should become available on your
computer.
I'll hide this back pain.
And now here let me and PM in it and I'll initialize this project.
And you could add here optional dash y which will skip all answers to you during initialization of the
new Node.js project.
So in PM init that's why.
New project was initialized.
And here you should find now package the JSON file with such contents, name of the project version
and so on.
And now let's install package called express and PM install express.
It will be downloaded from the NPM registry package was installed and packaged.
The JSON file was updated here was now dependency called express.
So now let's create index the GS file in our K eight web hello folder.
By the way, notice that now there is no modules folder which contains all dependencies of our project,
but now it is safe to simply remove this folder.
We don't need it anymore because we will not run this project locally with help of Node.
So simply select this folder and delete.
All right.
Now we have only package the JSON and package log the JSON files.
Great.
Now let's create file and we will create it inside of the k8s web hello folder.
So new file and let's name it index dot m j is why?
M because we will utilize ES6 modules syntax which is available in Node.js starting from version 13.
And if you would like to use import statements instead of the required statements, you have to name
files with extension images.
So let's create file index dot GHS and here I will not type the contents of entire application.
I will simply copy them in order to save some time.
So paste here if you would like you could of course write this very tiny application yourself.
So we import Express from express package.
We also import OS from OS.
OS is built in Node.js module and afterwards we create express application here export 3000.
You could specify any other port if you would like, and that's that port where our express web server
will be running inside of the container.
Here we are adding root handler from slash URL.
It is a root URL and we simply answer to the client with text.
Hello.
From the os host name using OS package, we retrieve hostname of the server and in the response from
the server you will see simply text message hello from there and name of the server where this application
is running.
So rest sent.
We send to the client such message and also we log it to the console and finally we start express web
server object lesson.
And we started at this broad 3000 and when server starts we will look to the console message.
Web server is listening at port and here respond.
I will not dive deeper into the explanations and syntax of Node.js because it is not Node.js course.
But you get an idea.
We create very basic web server which will respond with such text message.