From baf4842774190a4611869daf16d6f7281420c12d Mon Sep 17 00:00:00 2001 From: kyrie <139965836+KubeKyrie@users.noreply.github.com> Date: Mon, 25 Mar 2024 17:24:57 +0800 Subject: [PATCH] make kube-vip LeaderElection variables configurable (#11021) Signed-off-by: KubeKyrie --- docs/kube-vip.md | 8 ++++++++ roles/kubernetes/node/defaults/main.yml | 5 ++++- .../node/templates/manifests/kube-vip.manifest.j2 | 6 +++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/docs/kube-vip.md b/docs/kube-vip.md index d5878ab6a..4ac3fbcfd 100644 --- a/docs/kube-vip.md +++ b/docs/kube-vip.md @@ -76,3 +76,11 @@ In addition, [load-balancing method](https://kube-vip.io/docs/installation/flags ```yaml kube_vip_lb_fwdmethod: masquerade ``` + +If you want to adjust the parameters of [kube-vip LeaderElection](https://kube-vip.io/docs/installation/flags/#environment-variables): + +```yaml +kube_vip_leaseduration: 30 +kube_vip_renewdeadline: 20 +kube_vip_retryperiod: 4 +``` diff --git a/roles/kubernetes/node/defaults/main.yml b/roles/kubernetes/node/defaults/main.yml index b3f8fbf10..7366b263f 100644 --- a/roles/kubernetes/node/defaults/main.yml +++ b/roles/kubernetes/node/defaults/main.yml @@ -87,6 +87,9 @@ kube_vip_address: kube_vip_enableServicesElection: false kube_vip_lb_enable: false kube_vip_lb_fwdmethod: local +kube_vip_leaseduration: 5 +kube_vip_renewdeadline: 3 +kube_vip_retryperiod: 1 # Requests for load balancer app loadbalancer_apiserver_memory_requests: 32M @@ -258,4 +261,4 @@ conntrack_modules: ## Enable distributed tracing for kubelet kubelet_tracing: false kubelet_tracing_endpoint: 0.0.0.0:4317 -kubelet_tracing_sampling_rate_per_million: 100 \ No newline at end of file +kubelet_tracing_sampling_rate_per_million: 100 diff --git a/roles/kubernetes/node/templates/manifests/kube-vip.manifest.j2 b/roles/kubernetes/node/templates/manifests/kube-vip.manifest.j2 index 936ad44d2..ead73495d 100644 --- a/roles/kubernetes/node/templates/manifests/kube-vip.manifest.j2 +++ b/roles/kubernetes/node/templates/manifests/kube-vip.manifest.j2 @@ -48,11 +48,11 @@ spec: - name: vip_leaderelection value: "true" - name: vip_leaseduration - value: "5" + value: {{ kube_vip_leaseduration | string | to_json }} - name: vip_renewdeadline - value: "3" + value: {{ kube_vip_renewdeadline | string | to_json }} - name: vip_retryperiod - value: "1" + value: {{ kube_vip_retryperiod | string | to_json }} {% endif %} {% if kube_vip_bgp_enabled %} - name: bgp_enable