Support static IP assignment via VM annotations#157
Open
starbops wants to merge 4 commits into
Open
Conversation
Parse static-ip.harvesterhci.io/<nic> annotations after VM NIC configs are resolved and set NetworkConfig.IPAddress for matching IPv4 values. Sort generated network configs by NIC name to keep vmnetcfg specs deterministic. Signed-off-by: Zespre Chang <[email protected]>
Mark existing allocations stale when an explicit desired IP changes, while leaving dynamic configs untouched when the annotation is removed. Keep Allocate from recovering an old status or cache IP when a desired IP is present. Signed-off-by: Zespre Chang <[email protected]>
Reject desired IPs outside the pool, reserved or excluded addresses, duplicates, and addresses allocated to another MAC. Validate updates only when desired IP entries are new or changed so unchanged and removed configs do not require NAD/IPPool lookups. Signed-off-by: Zespre Chang <[email protected]>
Describe annotation format, update and removal semantics, MAC prerequisites, and validation failure surfaces. Also fix the vmnetcfg example field name to networkConfigs. Signed-off-by: Zespre Chang <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IMPORTANT: Please do not create a Pull Request without creating an issue first.
Problem:
Harvester users need a way to request stable DHCP IP addresses for VM NICs through VM-level configuration. The vm-dhcp-controller already supports static lease behavior through
VirtualMachineNetworkConfig.spec.networkConfigs[].ipAddress, but Harvester-created VMs did not have a controller path that populated this field from VM annotations.Without this, users cannot reliably pin a desired IP per VM interface through the Harvester VM workflow, and changes to a desired IP for an existing MAC are not reconciled cleanly.
Solution:
Add support for
static-ip.harvesterhci.io/<nic-name>annotations onVirtualMachineobjects.The VM controller now reads static IP annotations, matches them to VM interface names, validates basic IPv4 syntax, and writes the desired address into the generated
VirtualMachineNetworkConfig.The vmnetcfg controller now treats desired IP changes for an existing MAC as stale allocation state, so the old IP can be released and the new requested IP can be allocated during reconciliation.
The vmnetcfg webhook now validates requested static IPs on create and relevant updates. It rejects invalid requests such as non-IPv4 addresses, IPs outside the subnet or pool range, network or broadcast addresses, excluded/reserved IPs, duplicate desired IPs on the same network, and IPs already allocated to another MAC.
Related Issue:
harvester/harvester#5052
Test plan: