- [Instructor] In the last section,
we set up all the requirements that we needed
to run Kubernetes locally.
Namely, we installed Docker, kubectl, and minikube.
In this current section, we'll actually go ahead
and start up minikube, go to our exercise file directory,
and then run our very
first Kubernetes Hello World application.
So let's get started.
To start up minikube,
you can type the command minikube start.
The very first time this runs, you'll notice
that this might take a little while to actually go ahead
and get all of the different pre-loaded images,
et cetera for Kubernetes
and that's expected.
Once this completes, we get a quick note saying
that it's done and kubectl is now configured
to use minikube.
So let's actually take a look to see
whether this is up and running.
I can do this by running the command kubectl get nodes.
So I'm going to clear my screen and do a kubectl get nodes
and in this case, we see we have nodes,
it's called minikube in the ready status
with roles of master, 30 seconds old
because they're just created.
And this is version 1.18,
which is also the Kubernetes version.
Next up, we're actually going to run a quick Hello World
to make sure everything's up and running as we expect.
To do this, you'll want to make sure that you have
your exercise files downloaded to your local computer.
You can find the exercise files by going
to the Exercise Files tab and downloading the contents
onto your local directory.
So in this case, I took the exercise files
and I put them in a folder called
kgaekwad/documents/Kubernetes/03_04,
which is also the current chapter.
If I look to see what's in here, I can do an ls minus al.
And we notice that we have a couple files,
read.me and then helloworld.yaml.
We're actually going to run helloworld.yaml
because that's going to have our simple Hello World application
that we want to run.
But first up, let's look to see
what's in our cluster right now.
We just created this, so there shouldn't anything in there.
To figure out what's in your cluster,
you can run the command kubectl
get all, returns all resources.
And like I said before, not a whole lot
just to service Kubernetes with the cluster-IP.
It's been online for about 15 minutes or so.
Alright, let's go ahead and deploy our application.
In order to do that,
I'm going to run the command kubectl create
because I'm going to create a resource minus f,
meaning file and then helloworld.
And we get a deployment helloWorld was created.
Once again, if I run kubectl get all,
I should hopefully see more resources here.
And I do, I see the service that was there before,
but now we have a pod of helloworld
with a grid passed after that.
A deployment of helloworld
and also a replica set associated with that.
The other things to kind of look forward to over here are
their ready states.
So we noticed that the pod is ready to go,
one of one, deployment is ready to go one on one as well.
All of these seem to have an age of 11 seconds.
So in all accounts,
it looks like the deployment is ready to go.
But how do we actually access this, right?
'Cause this has a little web page that we want to access.
How do we go about that?
So in order to do that,
we need to create the service construct for Kubernetes.
And I can expose this deployment as a service.
So in order to do that, let's clear my screen.
I can run the command kubectl expose.
And then I'm going to expose the deployment.
I need to pass the name, so we call this helloworld earlier
and I'm going to expose this as a type of node port.
And we'll notice here that it says,
service/helloworld was exposed.
So if I take a look at the cluster again,
get all, we notice that we now have two services,
the Kubernetes one like we had before, but now helloworld.
It's of type NodePort, which is what we declared it as,
been online for nine seconds and should be accessible
on this specific port.
One of the nice things about minikube is
I can run the minicube service helloWorld command.
And by service helloworld,
it should reference the helloworld service we just created.
Once I run this, it actually takes me to the web browser
on this specific IP and port.
And it brings up our little deployment exposes service,
which is our little UI, you can reload this,
we see the counter that keeps reloading
and one of the neat things I've done here is
I can actually copy the container ID,
bring this back to the terminal.
And if I search for the container ID will notice
that it references the pod that we just have,
which is great.
The other thing I want to call out to attention to,
we kind of scrolled up a little bit too fast,
but when you run minikube service helloworld,
we notice we get this little table.
It says, the namespace default, the application name,
and the URL.
So 192.168.64.2:32124, which is essentially
what we saw over there.
So there we have it.
We have a deployment up and running.
It's exposed as a service.
So our simple Hello World app is up and running.