diff --git a/README.md b/README.md index 2ce7409..7c26d5e 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,11 @@ rke2_kubevip_image: ghcr.io/kube-vip/kube-vip:v0.6.4 # Specify which image is used for kube-vip cloud provider container rke2_kubevip_cloud_provider_image: ghcr.io/kube-vip/kube-vip-cloud-provider:v0.0.4 +# Enable kube-vip IPVS load balancer for control plane +rke2_kubevip_ipvs_lb_enable: false +# Enable layer 4 load balancing for control plane using IPVS kernel module +# Must use kube-vip version 0.4.0 or later + # (Optional) A list of kube-vip flags # All flags can be found here https://kube-vip.io/docs/installation/flags/ # rke2_kubevip_args: [] diff --git a/defaults/main.yml b/defaults/main.yml index f9c93ea..0675905 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -46,6 +46,12 @@ rke2_kubevip_image: ghcr.io/kube-vip/kube-vip:v0.6.4 # Specify which image is used for kube-vip cloud provider container rke2_kubevip_cloud_provider_image: ghcr.io/kube-vip/kube-vip-cloud-provider:v0.0.4 +# Enable kube-vip IPVS load balancer for control plane +rke2_kubevip_ipvs_lb_enable: false +# Enable layer 4 load balancing for control plane using IPVS kernel module +# Must use kube-vip version 0.4.0 or later + + # (Optional) A list of kube-vip flags # All flags can be found here https://kube-vip.io/docs/installation/flags/ # rke2_kubevip_args: [] diff --git a/tasks/main.yml b/tasks/main.yml index a4bdfc1..eb2f023 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -21,6 +21,19 @@ when: - rke2_ha_mode | bool +- name: Enable IPVS kernel module + community.general.modprobe: + name: ip_vs + state: present + persistent: present + when: + - rke2_kubevip_ipvs_lb_enable | bool + - inventory_hostname in groups[rke2_servers_group_name] + - rke2_ha_mode | bool + - rke2_ha_mode_kubevip | bool + - not rke2_ha_mode_keepalived | bool + + - name: Copy kube-vip manifests to the masternode ansible.builtin.include_tasks: kubevip.yml when: diff --git a/templates/kube-vip/kube-vip.yml.j2 b/templates/kube-vip/kube-vip.yml.j2 index 98ce4a1..7b1df67 100644 --- a/templates/kube-vip/kube-vip.yml.j2 +++ b/templates/kube-vip/kube-vip.yml.j2 @@ -62,6 +62,8 @@ spec: value: "{{ rke2_api_ip }}" - name: prometheus_server value: :2112 + - name: lb_enable + value: "{{ rke2_kubevip_ipvs_lb_enable }}" {% if rke2_kubevip_args is defined %} {% for item in rke2_kubevip_args %} - name: {{ item.param }}