How do I configure DNS to a kubernetes ingress?

534 Views Asked by At

I have purchased 3 VPS and have IP address like

   172.168.1.146
   72.168.43.245
   98.156.56.123

I have got an ingress controller

I have installed metallb which loadbalances traffic and sends it to any of the IP address.

Now how do I provide a static IP to my kubernetes cluster endpoint?

Should I purchase a virtual IP and configure it to metallb? If so how?

or

Should I configure keepalived in all the above nodes and configure a virtual IP. In this case can I configure the same virtual IP to all the nodes? Will there not be an IP conflict? If one of the node dies will the virtual IP be automatically assigned to another node which is alive? If so what would be the usual duration of automatically assigning the IP address to another node which is alive?

2

There are 2 best solutions below

0
On

MetalLB is currently in beta. Read about the Project maturity and make sure you inform yourself by reading the official documentation thoroughly.

MetalLB can be deployed either with a simple Kubernetes manifest or with Helm. The rest of this example assumes MetalLB was deployed following the Installation instructions. MetalLB requires a pool of IP addresses in order to be able to take ownership of the ingress-nginx Service. This pool can be defined in a ConfigMap named config located in the same namespace as the MetalLB controller. This pool of IPs must be dedicated to MetalLB's use, you can't reuse the Kubernetes node IPs or IPs handed out by a DHCP server.

Given the following 3-node Kubernetes cluster (the external IP is added as an example

$ kubectl get node
NAME     STATUS   ROLES    EXTERNAL-IP
host-1   Ready    master   203.0.113.1
host-2   Ready    node     203.0.113.2
host-3   Ready    node     203.0.113.3

After creating the following ConfigMap, MetalLB takes ownership of one of the IP addresses in the pool and updates the loadBalancer IP field of the ingress-nginx Service accordingly.

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 203.0.113.10-203.0.113.15
0
On

You include the IPs in the MetalLB config file. Or really just one since that's all it needs. https://metallb.universe.tf/configuration/#layer-2-configuration

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.1.240-192.168.1.250 

That's for L2 mode which is more likely what you want, but you should confirm with your networking upstream that gratuitous ARP will 1) work and 2) not get you banned from the network. Neither of these are assured from a baseline of "random VPS you just setup".