Search code examples
kuberneteskeepalived

Configure keepalived for services (NodePort) on kubernates


I have a k8s cluster which contains 2 nodes. And in the cluster I deployed 2 pods for the same application. Due to some reason I have to deploy a service (NodePort IP) for each pod, so totally I have 2 services the application, for example the service NodePort IP is 192.142.1.11 and 192.142.1.12. And use these 2 ips I can access the application from any node.

Now I am going to use keepalived to set up HA for the application. So:

  1. What's the best practice to install the keepalived service? On each k8s node or deploy it as pod?
  2. How to configure the interface in the keepalived.conf file? You know the NodePort ips are configured on kube-ipvs0 interface created by k8s and its status is down. Seems it cannot be used as the interface in keepalived.conf. Should I use the Node external interface if I start keepalived service on each node?

Thanks for your help.


Solution

  • If your final goal is masters HA / users service load balancing in on-prem environment, then you can take a look on this two project:

    Kubevip: can do both (HA masters + LoadBalancer type for user workload).

    Metallb: user workload LoadBalancer