Now, first of all,
as always ensure that you've got your minikube up
and running with minikube status,
and if it would not be up and running
start it with minikube start and pick a driver,
and then of course,
make sure you got no ongoing deployment steer
with kube control gets deployments,
maybe also check that you got no services,
except for that default service.
And you should be good to go.
And with that let's now move this application,
these different containers onto kubernetes.
And we're going to get there step by step.
And I wanna start with just the users-api here.
I'll start with just that
because first of all,
wanna dive into a concept we already learned about
the kubernetes services.
Now to start with the users-api,
we should first of all, go to the users-app.js file
and tweak it a little bit,
because in there I am,
of course already sending requests to this off service.
And initially, if we start with just a user's-api,
this will not work.
Therefore take these lines of code
where we use access to send the request
to this off service and copy them,
then comments them out and here
In the signup post functions so to say,
replace this call to access get with a dummy string.
So simply some dummy text instead of the real response
from making that request.
Because for the moment we don't wanna make that request.
And in this login route functioned here,
we wanna do something similar.
Copy this code, where we send our access request
and comment it out and then replace the response here,
not with a string, but with an object,
an object where you should add a status field
with a code of 200, because we're checking for that here.
And you wanna add a data field
with a number nested object in there
where we have a token field where you can store some string.
These are just minor tweaks, which will reverse later,
but which i wanna use for now
to make this user's app independent
from any other containers for this moment.
So with all of that, we should be fine.
And now of course, we wanna to build our image
and move it to Docker hub
so that we can use it on a kubernetes cluster.
So as always on Docker hub,
make sure you create a new repository
and all named kub-demo users.
The name is up to you, of course, create this repository
and then we need to create an image
off that name and push it.
So therefore I will now go to my terminal here
and move into that user's-api folder
with the cd command
and then run docker build dot
and with dash t give it a name of academind slash
or in you case of course,
your Docker hub account name slash,
and then the name you picked for this repository
and then a wide space between that name and the dot.
Now with that we built this image for the user's-api
and once it was built, we of course push it by,
well, just pushing this image name,
like this, and now it's pushed to Docker hub
to this newly created repository.
Once it was pushed, we are of course,
ready to get started with Kubernetes.
And for that, I will actually create a new sub folder here,
kubernetes, which you don't have to create,
but where I wanna store all my yaml files
to have them all in one place.
And in there I'll add my users-deployment.yaml file,
which as the names suggests should set up
that deployment for the users container.
Now, as you learn,
you could merge all your Kubernetes configuration
in one big yaml file, but to keep it easier
to manage and find i will use multiple files here.
So in here as always, we need to specify an apiVersion,
which should be apps/v1
for a deployment, the kind is deployment of course.
And then we can add metadata
where we give this deployment a name,
for example, user-deployment.
with that done, we need to set up a specification
and that's the specification for the deployment,
as you learned.
And here I wanna deploy one replica.
So only one instance of a pod for a given container,
and then set up the pod template
with that template option, here for this pod template,
we wanna add metadata and give it a label.
For example, app users,
as always, the label is up to you
both the key name as well as the value here.
And with that added, we can already add a selector
and on this selector here we can use match labels
and then match this app users label.
We just add it.
This is how we set up a deployment.
And of course that's nothing new.
Next, we set up the specification for this part
and there , I wanna add my containers.
And for the moment it's just one container,
hence one dash here with a name of,
let's say, users, of course,
this name is up to you.
Using an image which is named academind/kub-demo-users
in my case.
So does image, we just pushed,
of course, make sure you use your image name there.
And that is it.
With that, I'm setting up this deployment
and now of course we can apply it,
by running kube control apply.
And now of course you wanna apply it to our cluster
with cube control apply users dash,
deployment dot yaml as a file name.
And I'm in the wrong folder.
Of course, we need to see the out of the user's-api first
and then cd into the kubernetes folder in order
to be able to run this command like this
otherwise this file wouldn't be found.
Now this deployment is created as always,
this of course means that eventually
we'll have one pod up and running
with that user's container in it.