Skip to content

support k8s host vm vip type #5148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 17, 2025
Merged

support k8s host vm vip type #5148

merged 3 commits into from
Apr 17, 2025

Conversation

zbb88888
Copy link
Collaborator

@zbb88888 zbb88888 commented Apr 12, 2025

Pull Request

What type of this PR

Examples of user facing changes:

  • Features

  • support host network pod run VM use kube-ovn VIP

  • provide a simple way to run a VM with kube-ovn

image

test case:

image
image

image

image

image

image

image

performance test:

image

image

image

image

qemu + linux tap ~ 75% Linux veth-pair in ns

latency

image

783a2ae8852a65e82cddf55c29f92f9

qemu + linux tap 15us vs 5us Linux veth-pair in ns

Which issue(s) this PR fixes

Fixes #(issue-number)

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 12, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @zbb88888, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request introduces support for a new type of Virtual IP (VIP) called KubeHostVMVip. This new VIP type is intended for use with Kubernetes host network pods running VMs, allowing these VMs to utilize Kube-OVN's VIP functionality. The changes primarily involve modifying the controller to handle this new VIP type, specifically in IP address acquisition and LSP (Logical Switch Port) creation and deletion. The garbage collection logic is also updated to avoid deleting LSPs associated with these new VIPs.

Highlights

  • New VIP Type: Introduces a new KubeHostVMVip type to support VMs running on Kubernetes host network pods.
  • IP Address Acquisition: Modifies the acquireStaticIPAddress function to accept a macPointer to allow specifying a MAC address when acquiring a static IP for the VIP.
  • LSP Management: Updates the VIP controller to create and delete LSPs for KubeHostVMVip types, ensuring proper network connectivity for the VMs.
  • Garbage Collection: Modifies the garbage collection logic to prevent deletion of LSPs associated with KubeHostVMVip resources.

Changelog

Click here to see the changelog
  • pkg/controller/gc.go
    • Adds logic to prevent garbage collection of LSPs associated with VIPs, specifically those of type KubeHostVMVip.
    • Introduces a vipsMap to track VIP-related LSPs.
  • pkg/controller/ip.go
    • Modifies acquireStaticIPAddress to accept a macPointer argument.
  • pkg/controller/ovn_eip.go
    • Updates calls to acquireStaticIPAddress to pass nil for the macPointer.
  • pkg/controller/subnet.go
    • Updates calls to acquireStaticIPAddress to pass nil for the macPointer.
  • pkg/controller/vip.go
    • Modifies handleAddVirtualIP to handle the KubeHostVMVip type, including creating LSPs for the VM's NIC IP.
    • Adds logic to use the VIP's MAC address when acquiring a static IP, if provided.
    • Updates handleDelVirtualIP to delete LSPs associated with any VIP type, not just SwitchLBRuleVip.
    • Adds a check in handleUpdateVirtualParents to return early for KubeHostVMVip types.
  • pkg/util/const.go
    • Adds a new constant, KubeHostVMVip, to represent the new VIP type.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A virtual IP's gentle grace,
For VMs in a host's embrace,
Connectivity's art,
A brand new start,
In Kubernetes' digital space.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot bot added the feature New network feature label Apr 12, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces support for K8s host network VM VIPs, allowing VMs to use Kube-OVN VIPs. The changes involve modifications to gc.go, ip.go, ovn_eip.go, subnet.go, vip.go, and const.go. Overall, the code seems well-structured and addresses the intended functionality. However, there are a few areas that could benefit from closer examination and potential improvement.

Summary of Findings

  • Missing MAC Address Handling in acquireStaticIPAddress: The acquireStaticIPAddress function in pkg/controller/ip.go is modified to accept a macPointer, but the logic to actually use this pointer is missing. This could lead to incorrect MAC address assignments for static IPs.
  • Inconsistent use of subnet.Spec.Provider: In pkg/controller/vip.go, the subnet.Spec.Provider is used to determine the port name. It's important to ensure that this value is consistent and reliable across all VIP types, especially the new KubeHostVMVip.
  • TODO comment: The TODO comment in pkg/controller/vip.go regarding cleaning VIPs in the parent port AAP list should be addressed to ensure proper resource management.

Merge Readiness

The pull request introduces significant functionality and requires careful review to ensure correctness and stability. The missing MAC address handling in acquireStaticIPAddress is a high-severity issue that must be addressed before merging. The inconsistent use of subnet.Spec.Provider and the TODO comment should also be addressed. I am unable to approve this pull request, and recommend that it not be merged until these issues are resolved, and that others review and approve this code before merging.

Comment on lines 92 to 94
if ipStr != "" && vip.Spec.MacAddress != "" {
macPointer = &vip.Spec.MacAddress
v4ip, v6ip, mac, err = c.acquireStaticIPAddress(subnet.Name, vip.Name, portName, ipStr, macPointer)

Choose a reason for hiding this comment

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

medium

This condition checks if both ipStr and vip.Spec.MacAddress are not empty before assigning the macPointer. It might be more appropriate to check if vip.Spec.MacAddress is provided regardless of ipStr and pass the macPointer accordingly. This would allow specifying a MAC address even when an IP is dynamically assigned.

@coveralls
Copy link

coveralls commented Apr 12, 2025

Pull Request Test Coverage Report for Build 14505800466

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 42 (0.0%) changed or added relevant lines in 5 files are covered.
  • 4 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.02%) to 21.739%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/controller/ovn_eip.go 0 1 0.0%
pkg/controller/subnet.go 0 1 0.0%
pkg/controller/ip.go 0 2 0.0%
pkg/controller/gc.go 0 13 0.0%
pkg/controller/vip.go 0 25 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/controller/gc.go 1 0.68%
pkg/controller/vip.go 1 0.0%
pkg/ovs/ovn-nb-logical_router_route.go 2 74.93%
Totals Coverage Status
Change from base Build 14488797001: -0.02%
Covered Lines: 10261
Relevant Lines: 47201

💛 - Coveralls

@zbb88888 zbb88888 requested a review from zhangzujian April 15, 2025 01:12
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 16, 2025
zbb88888 and others added 3 commits April 17, 2025 09:07
@zbb88888 zbb88888 merged commit 91f264e into kubeovn:master Apr 17, 2025
9 of 11 checks passed
@zbb88888 zbb88888 deleted the vm-vip branch April 17, 2025 01:07
zbb88888 added a commit that referenced this pull request Apr 17, 2025
---------

Signed-off-by: zbb88888 <[email protected]>
Co-authored-by: 张祖建 <[email protected]>
Signed-off-by: zhangbingbing2 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New network feature lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants