Rancher with nginx-ingress

Art Krisada
3 min readSep 28, 2020

--

I used on premise rancher kubernetes without external load balance, so I used nodeport. I want to use ingress to expose my service instead of nodeport so I tried nginx-ingress. You can apply from these tutorials, they are great materials.

I will install with helm from rancher panel following these step.

  1. Add Helm repository
  2. Install nginx ingress
  3. Add 2 example web sites
  4. Add ingress

Add Helm Catalog. URL = https://helm.nginx.com/stable

Select nginx-ingress from catalog.

You will see nginx-ingress detail page. I will deploy nginx-ingress controller with deployment. You can use daemonset if you like. It will be a bit different config from deployment.

I add 3 variable.

controller.service.type = NodePort

controller.service.httpPort.nodePort = 30080

controller.service.httpsPort.nodePort = 30443

You must use port forwarding port 30080 to 80 and 30443 to 443 and expose port 80 and 443 to the internet.

After click Launch, go to Workload page.

We will deploy 2 demo applications. We will config ingress load balance to point to these application later.

Click Deploy. We will deploy web1 and web2 from docker image “hello-app”.

First, we deploy web1. Use this address for hello-app docker image. gcr.io/google-samples/hello-app:2.0

And use Cluster IP for Port Mapping.

Then, we deploy web2.

Next, we will config Load Balance.

Select Load Balancing Tab.

Then, Add Ingress.

Select Specify a hostname to use and fill in Request Host as your URL point to your worker node machine. select path you want and select target web1 and web2. Your port for hello-app are 8080.

Open URL in your browser for web1

(Ex: http://web.example.com:30080/web1).

You will see in the page that Hostname is web1-xxxxx.

Open URL in your browser for web2

(Ex: http://web.example.com:30080/web2).

You will see Hostname is web2-xxxxx.

First time I did, ingress stuck in initialising even though the name resolves.

But second time I did, it pass to Active state. Still not sure what’s going on for my first time.

--

--

Art Krisada
Art Krisada

Written by Art Krisada

Never stop learning, because life never stop teaching.

Responses (1)