Kube-vip - LoadBalancer
First of all we need to tell the systemd-networkd that kube-vip will manage all interfaces starting with vip-. Create a file named /etc/systemd/network/10-vip.network
with the following content:
[Match]
Name=vip-*
[Link]
Unmanaged=yes
And reload the networkd daemon with networkctl reload
.
Then we can use the kube-vip binary to generate a manifest to install it on the cluster. Issue this command:
kube-vip manifest daemonset \
--arp \
--enableLoadBalancer \
--inCluster \
--serviceInterface eth0 \
--services \
--servicesElection
Now generate a config map for its configuration (this will be used by the cloud controller to auto assign 0.0.0.0 to LoadBalancers).
apiVersion: v1
kind: ConfigMap
metadata:
name: kubevip
namespace: kube-system
data:
cidr-global: 0.0.0.0/32
And finally we would need to install the kube-vip-cloud-controller, apply the following kustomization:
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://raw.githubusercontent.com/kube-vip/kube-vip-cloud-provider/v0.0.3/manifest/kube-vip-cloud-controller.yaml
patchesJson6902:
- target:
kind: StatefulSet
name: kube-vip-cloud-provider
patch: |-
- op: add
path: /spec/template/spec/containers/0/env
value:
- name: KUBEVIP_CONFIG_MAP
value: kubevip
- name: KUBEVIP_NAMESPACE
value: kube-system
Then create a service of type LoadBalancer normally, the cloud-controller will populate the field loadBalancerIP with 0.0.0.0 triggering the kube-vip DHCP workflow and getting an ip from the network of eth0 interface specified in the manifest generation.