Skip to content

Commit e3d715d

Browse files
committed
feat: VM staticIP: add network-mapping ConfigMap parsing and IP translation for VM static-IP DR
Background / Motivation ----------------------- This work is part of the VM static-IP DR solution for UDN/CUDN-based networking and is intended to support the KubeVirt design: "Requesting a Specific IP for a VM in UDN via Third-Party Integration" When a VM fails over or fails back between clusters, statically assigned IPs may need translation to equivalent addresses on the peer cluster. The translation framework introduced in this PR is generic, but its primary motivating use case is VM static IPs provisioned through UDN/CUDN integrations. Translation scope is NAD-based ------------------------------ The implementation scopes translation rules using: networkRef: nadNamespace: nadName: rather than by IP alone. This is intentional because: - the same IP/subnet may legitimately exist in multiple UDNs - translation must be network-scoped - UDNs and CUDNs ultimately materialise as NADs consumed by VMs The implementation therefore works for: - NADs created directly by users - NADs generated from UDNs - NADs generated from CUDNs without introducing separate schema concepts for each network type. Supported translation mechanisms -------------------------------- Three translation models are supported. 1. explicitMappings explicitMappings: - dr1: 192.168.100.51 dr2: 192.168.110.58 Use case: one-to-one VM IP remapping Priority: highest Lookup: O(1) via pre-built forward/reverse maps. 2. cidr cidr: dr1: 192.168.100.0/24 dr2: 192.168.110.0/24 Use case: subnet-preserving host translation Example: 192.168.100.25 → 192.168.110.25 Requirements: - same address family - same prefix length - source and destination networks must differ 3. regexMappings regexMappings: dr1-to-dr2: ... dr2-to-dr1: ... Use case: arbitrary/non-symmetric translations Direction is explicit because regex transformations are not inherently reversible. Deterministic direction model ----------------------------- Direction is not inferred from the IP address. Instead: TranslateIP(srcIP, sourceCluster, ...) uses the caller-supplied source cluster name. Benefits: - avoids ambiguity with overlapping subnets - avoids ambiguity with regex mappings - keeps failover/failback behaviour deterministic Evaluation order ---------------- Translation is applied in the following order: explicitMappings ↓ cidr ↓ regexMappings This ensures: - specific VM overrides win - subnet translations act as defaults - regex rules act as a fallback Validation guarantees --------------------- The parser performs strict validation before rules become active. CIDR Validates: - cluster keys present - valid CIDR syntax - equal prefix lengths - source network != destination network explicitMappings Validates: - IPv4-only - cluster keys present - no duplicate source IPs - no duplicate destination IPs - no cross-column ambiguity - source IP != destination IP regexMappings Validates: - both directions present - valid regex syntax - non-empty pattern/replacement Operational behaviour --------------------- Configuration errors do not block DR workflows. If: - ConfigMap missing - ConfigMap invalid - Translation fails then: ConditionNetworkMappingLoaded=False is reported and: translateSourceIP() returns the original IP unchanged. This preserves DR orchestration while surfacing configuration problems. Non-goals of this PR -------------------- Not included: - ConfigMap watch/reload - DRPolicy integration for ConfigMap reference - Discovery of VM static IPs - Cloud-Init parsing - UDN/CUDN network discovery This PR is intentionally limited to: - ConfigMap parsing - Validation - Translation engine - Runtime translation APIs Design rationale ---------------- The most important design decision is: Translation is scoped by network identity (NAD) rather than by IP address. This avoids ambiguity in environments where: - multiple UDNs use overlapping subnets - the same IP may exist on different networks - CUDN/UDN-generated NADs coexist with user-created NADs Assisted by: IBM Bob v2.0.2 Signed-off-by: pruthvitd <prd@redhat.com>
1 parent b64f18b commit e3d715d

6 files changed

Lines changed: 2799 additions & 44 deletions

File tree

api/v1alpha1/drplacementcontrol_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ const (
8080
// GlobalActionConsensus condition indicates whether all DRPCs sharing the same global VGR label
8181
// agree on the DR action and target cluster.
8282
ConditionGlobalAction = "GlobalAction"
83+
84+
// NetworkMappingLoaded condition indicates whether the network-mapping ConfigMap referenced
85+
// by the drplacementcontrol.ramendr.openshift.io/network-mapping annotation was successfully
86+
// loaded. False means IP translation is disabled for this DRPC; DR orchestration continues.
87+
ConditionNetworkMappingLoaded = "NetworkMappingLoaded"
8388
)
8489

8590
const (

0 commit comments

Comments
 (0)