skip to Main Content

i try to deploy nginx-ingress-controller on bare metal , I have

4 Node

  1. 10.0.76.201 – Node 1
  2. 10.0.76.202 – Node 2
  3. 10.0.76.203 – Node 3
  4. 10.0.76.204 – Node 4

4 Worker

  1. 10.0.76.205 – Worker 1
  2. 10.0.76.206 – Worker 2
  3. 10.0.76.207 – Worker 3
  4. 10.0.76.214 – Worker 4

2 LB

  1. 10.0.76.208 – LB 1

  2. 10.0.76.209 – Virtual IP (keepalave)

  3. 10.0.76.210 – LB 10

Everything is on BareMetal , Load balancer located outside Cluster .

This is simple haproxy config , just check 80 port ( Worker ip )

frontend kubernetes-frontends
  bind *:80
  mode tcp
  option tcplog
  default_backend kube



backend kube
        mode http
        balance roundrobin
        cookie lsn insert indirect nocache
        option http-server-close
        option forwardfor
        server node-1 10.0.76.205:80 maxconn 1000 check
        server node-2 10.0.76.206:80 maxconn 1000 check
        server node-3 10.0.76.207:80 maxconn 1000 check
        server node-4 10.0.76.214:80 maxconn 1000 check

I Install nginx-ingress-controller using Helm and everything work fine

NAME                                            READY   STATUS      RESTARTS   AGE
pod/ingress-nginx-admission-create-xb5rw        0/1     Completed   0          18m
pod/ingress-nginx-admission-patch-skt7t         0/1     Completed   2          18m
pod/ingress-nginx-controller-6dc865cd86-htrhs   1/1     Running     0          18m

NAME                                         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
service/ingress-nginx-controller             NodePort    10.106.233.186   <none>        80:30659/TCP,443:32160/TCP   18m
service/ingress-nginx-controller-admission   ClusterIP   10.102.132.131   <none>        443/TCP                      18m

NAME                                       READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/ingress-nginx-controller   1/1     1            1           18m

NAME                                                  DESIRED   CURRENT   READY   AGE
replicaset.apps/ingress-nginx-controller-6dc865cd86   1         1         1       18m

NAME                                       COMPLETIONS   DURATION   AGE
job.batch/ingress-nginx-admission-create   1/1           24s        18m
job.batch/ingress-nginx-admission-patch    1/1           34s        18m

Deploy nginx simple way and works fine

kubectl create deploy nginx --image=nginx:1.18
kubectl scale deploy/nginx --replicas=6
kubectl expose deploy/nginx --type=NodePort --port=80

after , i decided to create ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: tektutor-ingress 
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: "tektutor.training.org"
    http:
      paths:
      - pathType: Prefix
        path: "/nginx"
        backend:
          service:
            name: nginx 
            port:
              number: 80

works fine

kubectl describe ingress tektutor-ingress

Name:             tektutor-ingress
Labels:           <none>
Namespace:        default
Address:          10.0.76.214
Ingress Class:    <none>
Default backend:  <default>
Rules:
  Host                   Path  Backends
  ----                   ----  --------
  tektutor.training.org
                         /nginx   nginx:80 (192.168.133.241:80,192.168.226.104:80,192.168.226.105:80 + 3 more...)
Annotations:             kubernetes.io/ingress.class: nginx
                         nginx.ingress.kubernetes.io/rewrite-target: /
Events:
  Type    Reason          Age                From                      Message
  ----    ------          ----               ----                      -------
  Normal  AddedOrUpdated  18m                nginx-ingress-controller  Configuration for default/tektutor-ingress was added or updated
  Normal  Sync            18m (x2 over 18m)  nginx-ingress-controller  Scheduled for sync

everything work fine , when i try curl any ip works curl (192.168.133.241:80,192.168.226.104:80,192.168.226.105:80 + 3 more...)

now i try to add hosts

10.0.76.201 tektutor.training.org

This is my master ip , is it correct to add here master ip ? when i try curl tektutor.training.org not working

Can you please explain what I am having problem with this last step?
I set the IP wrong? or what ? Thanks !

I hope I have written everything exhaustively

I used to this tutor Medium Install nginx Ingress Controller

2

Answers


  1. Chosen as BEST ANSWER

    A funny story that took 2 days :) In Ingress i have used the path /nginx but not hitting it while

    Something like : http://tektutor.training.org/nginx

    THanks @Dawid Kruk who try to helm me :) !


  2. TL;DR

    Put in your haproxy backend config values shown below instead of the ones you’ve provided:

    • 30659 instead of 80
    • 32160 instead of 443 (if needed)

    More explanation:

    NodePort works on certain set of ports (default: 3000032767) and in this scenario it allocated:

    • 30659 for your ingress-nginx-controller port 80.
    • 32160 for your ingress-nginx-controller port 443.

    This means that every request trying to hit your cluster from outside will need to contact this ports (30…).

    You can read more about it by following official documentation:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search