MetalLB External IP to Internet

7/18/2019

I can't access to public IP assigned by MetalLB load Balancer

I created a Kubernetes cluster in Contabo. Its 1 master and 2 workers. Each one has its own public IP.

I did it with kubeadm + flannel. Later I did install MetalLB to use Load Balancing.

I used this manifest for installing nginx:

apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1
        ports:
        - name: http
          containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx
spec:
  ports:
  - name: http
    port: 8080
    protocol: TCP
    targetPort: 80
  selector:
    app: nginx
  type: LoadBalancer

It works, pods are running. I see the external IP adress after:

kubectl get services

enter image description here From each node/host I can curl to that ip and port and I can get nginx's:

<h1>Welcome to nginx!</h1>

So far, so good. BUT:

What I still miss is to access to that service (nginx) from my computer. I can try to access to each node (master + 2 slaves) by their IP:PORT and nothing happens. The final goal is to have a domain that access to that service but I can't guess witch IP should I use.

What I'm missing?

Should MetalLB just expose my 3 possible IPs? Should I add something else on each server as a reverse proxy?

I'm asking this here because all articles/tutorials on baremetal/VPS (non aws,GKE, etc...) do this on a kube on localhost and miss this basic issue.

Thanks.

-- xfoguet
bare-metal-server
kubeadm
kubernetes
metallb

1 Answer

7/19/2019

What you are missing is a routing policy

Your external IP addresses must belong to the same network as your nodes or instead of that you can add a route to your external address at your default gateway level and use a static NAT for each address

-- Amine Bouzid
Source: StackOverflow