In this video, we're going to look at Ingress networking in a bit more detail.
We'll try and deploy an Ingress Controller.
We've deployed two applications. Explore the setup.
Let's check that out.
Set alias first.
Let's do a pod -A.
In the app-space, we have the video and wear applications.
Let us now deploy an Ingress Controller first.
Create a namespace called ingress-space.
This is what we are going to do.
The first step is to create this namespace called ingress-space.
We'll do this one step at a time.
Let's do that first.
I'm going to create namespace ingress-space.
Okay. That's successful.
Now, the NGINX Ingress Controller requires a ConfigMap object.
Create a ConfigMap object in the ingress-space.
We're just going to create a ConfigMap object.
We'll do a kubectl create configmap.
The name should be, it's given here, nginx-configuration,
and the namespace is ingress-space.
Okay.
That's done.
If you can see here.
We've just created these two.
Now, the NGINX Ingress Controller requires a ServiceAccount.
Create a ServiceAccount in the ingress-space name.
The name of the ServiceAccount is ingress-serviceaccount.
Create serviceaccount
in the ingress-space.
We have created the Roles and RoleBindings for the ServiceAccount.
Let's check that out.
Get roles.
We have the ingress-role and rolebindings.
We have ingress rolebinding. Let's check out
ingress-role in the ingress-space.
We see that there are a number of resources that are given access to
like the pods, secrets, namespaces.
These are the verbs, the actions that it can perform.
Let's keep going.
Let us now deploy the Ingress Controller. Create a deployment using the file given.
There's already a file given called ingress-controller.
The hard stuff is already in there.
It's going to be called ingress-controller.
The ServiceAccount name that we created is here.
The container that it uses is here.
The arguments that are passed to it is configured,
and there are some environment variables as well,
and the ports that it exposes. These are all done.
There are some issues, so let's try and create a file
from this first-- Create a deployment from this file first.
It looks like there are some issues. There's an issue on line 36.
Looks like a YAML issue,
let's edit the file and try and fix those.
Let's go to line 36. Right here.
We see that, yes, indeed there's an issue with spacing.
We'll fix that.
Let's try to create it again.
We see that namespace "ingress-" not found.
If you look here,
the namespace is not properly specified, so let's try and edit that.
And space.
Let's try and create ingress-controller now.
Let's check out the status
in the ingress-space.
It's in a continuing creating state.
Let's give it sometime.
Meanwhile, we can check the status of our work.
Yes, it's completed successfully.
We have now deployed the ingress-controller.
Now, the next step is to create a service to
make ingress available to external users.
The ingress-controller is ready.
The next step is to create a service called ingress.
What we're going to do is our goal is to expose ingress-controller.
The easiest way to do that is get deploy -n ingress-space.
It's called ingress-controller, so we're going to create a service
using the expose command. We're going to do expose.
What do we want to expose? We want to expose
the ingress-controller deployment.
We'll say deploy an ingress-controller in the ingress-space.
Also, there are some specifications given here.
The name has to be ingress. Let's pass in a name called ingress.
Let's check out the help just to get a bit more idea.
We have the expose command, and then we have the deployment,
the deployment name.
If you want a name for the service, you can use --name.
That's what we just did.
You can also specify the port, so the port and the target port.
We want to use 80 and the target port is also 80,
but the expose command does not allow us to use the node port option.
What we're going to do is we're going to create the service first,
and then we're just going to go in and edit the node port.
That's the easiest way to do that.
We'll just take these because that's what we are left with.
Clear my screen.
We're going to specify the port. The port and the target port are both 80.
We're going to do an export deploy ingress-controller in the ingress-space.
We'll name it ingress, and then we'll specify these.
We can also specify the type.
We'll say --type going to be node port.
That's what's given here.
Then we specify the port and the target port.
The node port cannot be specified, but we specify this.
The right selector,
expose should take care of using the right selector for this,
for the deployment.
Let's create that.
It's created.
Get svc in the ingress-space.
It's created. It's a node port.
If you look here, the node port that is used is 32741.
That's not what we wanted.
We'll go and edit the service in the ingress-space.
Edit service called ingress.
Here we can see the details.
The only thing we need to do is change this to 30080.
This is actually a simpler way to create a service
without having to work with the YAML files at all.
That's going to be useful in the exam.
Let's check.
That's successful.
Now, the next step is to create the ingress resource
to make the applications available at wear and watch on the ingress service.
We're going to create an ingress service.
We'll do a kubectl create ingress
in the app-space.
That's where the applications are.
Let's quickly check help.
This is what we used earlier.
We're going to do a create then give the name of the ingress rule,
and then we'll just use this rule to specify the roles.
The name of the ingress resource could just be ingress and wear and watch.
Then we'll specify the rules.
We don't need the certificate stuff, so we'll remove that.
The rules says wear
needs to go to the wear-service.
Then we have another rule.
Again, we're going to remove this, and this is for the second one.
We can have multiple rules like this,
watch, and that's going to go to the watch-service.
I'm not sure if it's called the wear and watch service.
I'm just to part this for now.
Let's check the service names in app-space.
We see that--
Okay, it's the wear-service and it's the video-service, n
ot the watch-service, and the ports are 8080.
Let's edit that.
The watch is called the video-service in port 8080,
and the wear is called the wear-service.
Let's get rid of this one.
Okay, so that's created, ingress in app-space.
We see that is created.
Let's do a describe ingress--
Let's do app-space.
We see that the wear goes to the wear-service,
and it's identified the endpoint for that.
Watch is to the video-service and it's identified the endpoints to that.
Let's test it out and see if it's working.
Let's do a wear.
Okay, so it isn't working.
Let's do a watch.
Let's go and check out the logs on these applications.
Let's do a logs. Take this out.
As you can see, the requests aren't even reaching here.
Let's check the other service.
If the requests were coming in, you'd actually see the requests coming in.
The requests aren't hitting this.
That's one thing.
Let's try and figure out why.
Let's look at the logs of the ingress controller itself.
The ingress controller, as we know, is in the ingress-space.
Let's do a logs of this ingress controller.
If you look here, there seems to be a lot of logs.
App-space.
it's definitely hitting the ingress controller,
but then you see there are three node-eights.
The three node-eights indicate a redirect.
What's happening is, every time we're going here,
as you can see, the browser here it just keeps redirecting.
It looks like it's going into a--
You can see the errors here, so it's going into too many redirects.
That is mainly because it's just trying to do a redirect on the SSL.
For HTTPS, it's trying to do a redirect on HTTPS.
What we need to do is we need to edit the ingress service.
Here's the ingress service. We need to edit it
in the app-space
to provide ingress.
Then you need add the annotations.
The annotations for the ReadWrite target,
because as we discussed earlier,
we don't want it to go to a wear and watch URL.
To prevent the SSL redirect, we have to add the SSL redirect to false.
Let's edit that.
Let's try this again.
That seems to do the trick.
It's actually working now.
Let's check our work.
We already accessed the application.
That's the end of this lab.