skip to Main Content

So, here is my current setup
My experience is mostly on openshift, but I’m trying to get familiar with kubernetes… and I’m a bit noob in KS8 🙂

kubernets + callico + external storage(nfs) + metallb + ingress-nginx

 kubectl get nodes -o wide
NAME        STATUS   ROLES           AGE     VERSION   INTERNAL-IP      EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION      CONTAINER-RUNTIME
master01    Ready    control-plane   3d14h   v1.26.2   192.168.50.15    <none>        Ubuntu 22.04.2 LTS   5.15.0-67-generic   cri-o://1.24.4
master02    Ready    control-plane   2d15h   v1.26.2   192.168.50.16    <none>        Ubuntu 22.04.2 LTS   5.15.0-67-generic   cri-o://1.24.4
worker-01   Ready    worker          2d14h   v1.26.2   192.168.50.105   <none>        Ubuntu 22.04.2 LTS   5.15.0-67-generic   cri-o://1.24.4
worker-02   Ready    worker          2d13h   v1.26.2   192.168.50.106   <none>        Ubuntu 22.04.2 LTS   5.15.0-67-generic   cri-o://1.24.4

kubectl get pods -n metallb-system -o wide

NAME                         READY   STATUS    RESTARTS   AGE   IP               NODE        NOMINATED NODE   READINESS GATES
controller-79d5899cb-hg4lv   1/1     Running   0          23m   10.30.0.27       worker-02   <none>           <none>
speaker-lvpbn                1/1     Running   0          21m   192.168.50.106   worker-02   <none>           <none>
speaker-rxcvb                1/1     Running   0          21m   192.168.50.105   worker-01   <none>           <none>

metallb has been config with this ippool

apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  namespace: metallb-system
  name: lb-pool
spec:
  addresses:
    - 192.168.50.115-192.168.50.118

kubectl get all -n ingress-nginx

NAME                                           READY   STATUS    RESTARTS   AGE
pod/ingress-nginx-controller-c69664497-z84b8   1/1     Running   0          12h

NAME                                         TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)                                     AGE
service/ingress-nginx-controller             LoadBalancer   10.108.69.42    192.168.50.115   80:32481/TCP,443:32137/TCP,8443:30940/TCP   83m
service/ingress-nginx-controller-admission   ClusterIP      10.97.240.138   <none>           443/TCP                                     12h

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

NAME                                                 DESIRED   CURRENT   READY   AGE
replicaset.apps/ingress-nginx-controller-c69664497   1         1         1       12h


kubectl create deployment  httpd24 --image=docker.io/library/httpd:2.4.55
kubectl expose deployment/httpd24 --port 80

create ingress::

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: httpd24-ingress
  namespace: default
spec:
  ingressClassName: nginx
  rules:
  - host: http24-kube.docker-containers.local
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: httpd24
            port:
              number: 80

kubectl get ingress
NAME              CLASS   HOSTS                                 ADDRESS          PORTS   AGE
httpd24-ingress   nginx   http24-kube.docker-containers.local   192.168.50.115   80      58m

So, from inside cluster I can execute w/o errors curl -s http://http24-kube.docker-containers.local

However, from outside cluster ping to 192.158.50.115 or ping to http24-kube.docker-containers.local got timeout.

Computer from where I try to connect to http24-kube.docker-containers.local has access to subnet 192.168.50.0/25

I think it may be related to nginx-ingress…but have zero experience with ….

========

C:UsersAZ_fjonnas>nslookup http24-kube.docker-containers.local
Name:    http24-kube.docker-containers.local
Address:  192.168.50.115

Now, from the one of the masternodes

root@master01:~# curl -s 'http://http24-kube.docker-containers.local'
<html><body><h1>It works!</h1></body></html>
root@master01:~#

So, cluster master nodes resolve the name, moreover can access the httpd24 pod with ingress IP

But, windows machine can’t access at all ingress IP(192.168.50.111) port 80

That’s why I think is something related to how nginx-ingress works… 🙁

ALL nodes belong to same subnet: 192.168.50.0/25

2

Answers


  1. Chosen as BEST ANSWER

    Damn,

    Solved :)

    ---
    apiVersion: metallb.io/v1beta1
    kind: L2Advertisement
    metadata:
      name: lb-pool
      namespace: metallb-system
    spec:
      ipAddressPools:
      - lb-pool
    

    Seems that L2Advertisement was missing according to : https://github.com/kubernetes/ingress-nginx/blob/main/docs/deploy/baremetal.md


  2. In your machine, it does not know how to resolve http24-kube.docker-containers.local DNS name to an IP address unless you have specified it in /etc/hosts as a record (since it’s a name chosen by you that has no records in public DNS servers). If you add it like the below:

    192.168.50.115  http24-kube.docker-containers.local
    

    Then you can do the following:

    curl -s http://http24-kube.docker-containers.local
    

    OR

    You need to specify the host header when invoking the ingress while directly giving the IP of the ingress like below:

    curl -s http://192.168.50.115 -H "Host: http24-kube.docker-containers.local"
    

    Note

    Also, The command you tried within a pod should not work since CoreDNS (with the default bootstrap configuration – Corefile) does not know what to resolve for this http24-kube.docker-containers.local DNS name.

    curl -s http://http24-kube.docker-containers.local
    

    Using service name and namespace combination should work:

    curl -s http://http24.default
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search