Skip to content

fix: allow disabling kube-vip Service VIP management via svc_enable - #3196

Merged
kubesphere-prow[bot] merged 3 commits into
kubesphere:mainfrom
pujitha24:auto/issue-3170
Aug 18, 2026
Merged

fix: allow disabling kube-vip Service VIP management via svc_enable#3196
kubesphere-prow[bot] merged 3 commits into
kubesphere:mainfrom
pujitha24:auto/issue-3170

Conversation

@pujitha24

Copy link
Copy Markdown
Contributor

Now I have the full diff details to fill the template accurately.


What type of PR is this?

/kind bug

What does this PR do

Allow disabling kube-vip Service (type LoadBalancer) VIP management via a new svc_enable config field.

Background / Motivation

The generated kube-vip static pod manifest hardcoded the svc_enable env var to "true" with no way to override it. This forces kube-vip to also manage Service (type LoadBalancer) VIPs, which conflicts with setups that run a separate Service VIP manager (e.g. MetalLB) alongside kube-vip for the apiserver VIP: kube-vip and MetalLB end up racing to manage the same VIP.

Implementation

Added a kubernetes.control_plane_endpoint.kube_vip.svc_enable config field (default true, preserving current behavior) and templated it into the svc_enable env var in both the ARP and BGP kube-vip manifests instead of hardcoding "true". Documented the new field in docs/en and docs/zh config references, which mirror this defaults block.

Key Changes

File What changed
builtin/core/roles/defaults/defaults/main/03-kubernetes.yaml Added kubernetes.control_plane_endpoint.kube_vip.svc_enable: true default field
builtin/core/roles/kubernetes/pre-kubernetes/templates/kubevip/kubevip.ARP Templated svc_enable env var from hardcoded "true" to "{{ .kubernetes.control_plane_endpoint.kube_vip.svc_enable }}"
builtin/core/roles/kubernetes/pre-kubernetes/templates/kubevip/kubevip.BGP Templated svc_enable env var from hardcoded "true" to "{{ .kubernetes.control_plane_endpoint.kube_vip.svc_enable }}"
docs/en/reference/config.md Documented new svc_enable field in example config and reference table
docs/zh/reference/config.md Documented new svc_enable field in example config and reference table (Chinese)

Impact

  • Affected modules: kube-vip static pod manifest generation (builtin/core/roles/kubernetes/pre-kubernetes), defaults config
  • API changes: N/A
  • Database / state changes: N/A
  • Config changes: New field kubernetes.control_plane_endpoint.kube_vip.svc_enable (default true)
  • Dependency changes: N/A

Breaking Changes

None

Which issue(s) this PR fixes:

Fixes #3170

Testing

Verification performed

  • Unit tests pass (go build ./... and go build -tags builtin ./...)
  • Integration / E2E tests pass (<command>)
  • Manual verification

Steps to verify

  1. Set kubernetes.control_plane_endpoint.kube_vip.svc_enable: false in the cluster config.
  2. Render/generate the kube-vip static pod manifest (ARP or BGP mode) for a node.
  3. Confirm the rendered manifest's svc_enable env var value is "false" instead of the previously hardcoded "true".

Test coverage

A temporary test was added in pkg/converter/tmpl (removed before this commit, not part of the diff) that rendered both kubevip.ARP and kubevip.BGP through the real tmpl.Parse engine with svc_enable set to both true and false, asserted the output is valid YAML, and asserted the rendered svc_enable env var line matches "true"/"false" respectively. Both templates passed for both values. This repo has no existing automated test coverage for builtin YAML/template content and no live-cluster/e2e harness available in this environment; no user-facing runtime behavior changes for existing configs since the new field defaults to true.

Rollback

Plain revert. No data or config migration is needed since the new field defaults to true, preserving prior hardcoded behavior.

Does this PR introduce a user-facing change?

Added a new config field `kubernetes.control_plane_endpoint.kube_vip.svc_enable` (default `true`) to allow disabling kube-vip's management of Service (type LoadBalancer) VIPs, useful when running a separate Service VIP manager such as MetalLB alongside kube-vip.

Checklist

  • Code self-reviewed, no debug code or commented-out dead code
  • No secrets, tokens, or .env files committed
  • Commit message follows Conventional Commits
  • All commits have DCO sign-off (Signed-off-by)
  • All commits are GPG-signed (GitHub shows Verified)
  • Tests added or updated
  • Docs / CHANGELOG updated (if needed)
  • Local lint and build pass (make build)
  • Breaking changes marked above

Additional documentation, usage docs, etc.:

- [Usage]: docs/en/reference/config.md
- [Usage]: docs/zh/reference/config.md

Notes for Reviewer

The new field's default (true) preserves existing behavior for all current configs, so this should be a non-breaking, opt-in change. No automated test was added to the permanent test suite because this repo has no existing test coverage for builtin YAML/template content; happy to add one if reviewers want template-rendering coverage established.


AI assistance: this change was drafted with Claude Code.

Motivation:
The generated kube-vip static pod manifest hardcoded the svc_enable
env var to "true" with no way to override it. This forces kube-vip to
also manage Service (type LoadBalancer) VIPs, which conflicts with
setups that run a separate Service VIP manager (e.g. MetalLB)
alongside kube-vip for the apiserver VIP: kube-vip and MetalLB end up
racing to manage the same VIP.

Approach:
Add a kubernetes.control_plane_endpoint.kube_vip.svc_enable config
field (default true, preserving current behavior) and template it
into the svc_enable env var in both the ARP and BGP kube-vip
manifests instead of hardcoding "true". Documented the new field in
docs/en and docs/zh config references, which mirror this defaults
block.

Validation:
- go build ./... and go build -tags builtin ./... both pass.
- Added a temporary test in pkg/converter/tmpl (removed before this
  commit, not part of the diff) that rendered both
  builtin/core/roles/kubernetes/pre-kubernetes/templates/kubevip/kubevip.ARP
  and .../kubevip.BGP through the real tmpl.Parse engine with
  svc_enable set to both true and false, asserted the output is valid
  YAML, and asserted the rendered svc_enable env var line matches
  "true"/"false" respectively. Both templates passed for both values,
  reproducing the reported hardcoded-true behavior before the fix and
  confirming the config knob works after it.
- This repo has no existing automated test coverage for builtin
  YAML/template content and no live-cluster/e2e harness available in
  this environment; no user-facing runtime behavior changes for
  existing configs since the new field defaults to true.

Report: kubesphere#3170
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@kubesphere-prow kubesphere-prow Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 17, 2026
@redscholar

Copy link
Copy Markdown
Contributor

@pujitha24 I think we could extract the env parameters so more configuration options become available. Add the following to builtin/core/roles/defaults/defaults/main/03-kubernetes.yaml like:

kubernetes:
  control_plane_endpoint:
    kube_vip:
      env:
        svc_enable: "false"
        ...

In the template builtin/core/roles/kubernetes/pre-kubernetes/templates/kubevip/kubevip.ARP and builtin/core/roles/kubernetes/pre-kubernetes/templates/kubevip/kubevip.BGP, keep only the minimal env that kube_vip actually needs across the different modes.

Per review feedback, generalize the single svc_enable field into
kubernetes.control_plane_endpoint.kube_vip.env, mirroring the existing
etcd.env pattern, so more kube-vip env vars can be overridden. The ARP
and BGP manifest templates now reference env.<key> for each value they
need instead of hardcoding it; host-loop-computed values (vip_interface,
bgp_routerid, bgp_peers) and address are unchanged. Adds a template
rendering test for both manifests.

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@kubesphere-prow

Copy link
Copy Markdown

This PR has multiple commits, and the default merge method is: squash.
You can request commits to be merged using the label: tide/merge-method-merge

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubesphere-prow kubesphere-prow Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 18, 2026
Comment on lines +120 to +126
bgp_enable: "true"
bgp_as: "65000"
bgp_peeraddress: ""
bgp_peerpass: ""
bgp_peeras: "65000"
lb_fwdmethod: local
prometheus_server: ":2112"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep in kubevip.BGP

value: "{{ .kubernetes.control_plane_endpoint.kube_vip.env.port }}"
- name: vip_interface
value: {{ .kube_vip_interface }}
- name: vip_cidr

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use template to add env like:

{{ range $k,$v := .kubernetes.control_plane_endpoint.kube_vip.env }}
  - name: {{ $k }}
     value: {{ $v }}
{{ end }}

… templates

Per review: the ARP/BGP-only env vars (vip_leaderelection group for ARP;
bgp_*/lb_fwdmethod/prometheus_server for BGP) are removed from the shared
kube_vip.env defaults and hardcoded back into their respective template,
matching pre-PR behavior. Both templates now render the remaining shared
vars via a range loop over kube_vip.env instead of listing each key
individually, mirroring the range pattern already used in kubelet.env.

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

@redscholar redscholar added lgtm Indicates that a PR is ready to be merged. and removed lgtm Indicates that a PR is ready to be merged. labels Aug 18, 2026
@redscholar

Copy link
Copy Markdown
Contributor

/lgtm

@kubesphere-prow kubesphere-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 18, 2026
@kubesphere-prow

Copy link
Copy Markdown

LGTM label has been added.

DetailsGit tree hash: ef2239cad6c41f55e3d04ff5dae55fc9e13c3e96

@redscholar redscholar added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 18, 2026
@kubesphere-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: pujitha24

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubesphere-prow
kubesphere-prow Bot merged commit 4b18e8f into kubesphere:main Aug 18, 2026
7 checks passed
redscholar pushed a commit to redscholar/kubekey that referenced this pull request Aug 19, 2026
…ubesphere#3196)

* fix: allow disabling kube-vip Service VIP management via svc_enable

Motivation:
The generated kube-vip static pod manifest hardcoded the svc_enable
env var to "true" with no way to override it. This forces kube-vip to
also manage Service (type LoadBalancer) VIPs, which conflicts with
setups that run a separate Service VIP manager (e.g. MetalLB)
alongside kube-vip for the apiserver VIP: kube-vip and MetalLB end up
racing to manage the same VIP.

Approach:
Add a kubernetes.control_plane_endpoint.kube_vip.svc_enable config
field (default true, preserving current behavior) and template it
into the svc_enable env var in both the ARP and BGP kube-vip
manifests instead of hardcoding "true". Documented the new field in
docs/en and docs/zh config references, which mirror this defaults
block.

Validation:
- go build ./... and go build -tags builtin ./... both pass.
- Added a temporary test in pkg/converter/tmpl (removed before this
  commit, not part of the diff) that rendered both
  builtin/core/roles/kubernetes/pre-kubernetes/templates/kubevip/kubevip.ARP
  and .../kubevip.BGP through the real tmpl.Parse engine with
  svc_enable set to both true and false, asserted the output is valid
  YAML, and asserted the rendered svc_enable env var line matches
  "true"/"false" respectively. Both templates passed for both values,
  reproducing the reported hardcoded-true behavior before the fix and
  confirming the config knob works after it.
- This repo has no existing automated test coverage for builtin
  YAML/template content and no live-cluster/e2e harness available in
  this environment; no user-facing runtime behavior changes for
  existing configs since the new field defaults to true.

Report: kubesphere#3170
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>

* refactor: extract kube-vip env vars into a configurable env map

Per review feedback, generalize the single svc_enable field into
kubernetes.control_plane_endpoint.kube_vip.env, mirroring the existing
etcd.env pattern, so more kube-vip env vars can be overridden. The ARP
and BGP manifest templates now reference env.<key> for each value they
need instead of hardcoding it; host-loop-computed values (vip_interface,
bgp_routerid, bgp_peers) and address are unchanged. Adds a template
rendering test for both manifests.

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>

* refactor: trim kube-vip env map to shared vars, keep mode-specific in templates

Per review: the ARP/BGP-only env vars (vip_leaderelection group for ARP;
bgp_*/lb_fwdmethod/prometheus_server for BGP) are removed from the shared
kube_vip.env defaults and hardcoded back into their respective template,
matching pre-PR behavior. Both templates now render the remaining shared
vars via a range loop over kube_vip.env instead of listing each key
individually, mirroring the range pattern already used in kubelet.env.

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>

---------

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Co-authored-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kube-vip 模式安装集群时 svc_enable 被硬编码为 true 无法关闭,导致与 MetalLB 的 Service VIP 管理冲突

2 participants