diff --git a/api/v1alpha5/virtualmachine_network_types.go b/api/v1alpha5/virtualmachine_network_types.go index 87aa3911b..f5f330a60 100644 --- a/api/v1alpha5/virtualmachine_network_types.go +++ b/api/v1alpha5/virtualmachine_network_types.go @@ -62,11 +62,11 @@ type VirtualMachineNetworkInterfaceSpec struct { // MACAddr is the optional MAC address of this interface. // - // If no MAC address is provided, one will be generated by either the network - // provider or vCenter. + // If no MAC address is provided, one will be generated by either the + // network provider or vCenter. // - // Please note this field is only supported when the Network API Group is - // crd.nsx.vmware.com. + // Please note, this field is only supported for workloads using VPC + // networking. // MACAddr string `json:"macAddr,omitempty"` diff --git a/config/crd/bases/vmoperator.vmware.com_virtualmachinereplicasets.yaml b/config/crd/bases/vmoperator.vmware.com_virtualmachinereplicasets.yaml index 0691ba5fa..e2fd34b8d 100644 --- a/config/crd/bases/vmoperator.vmware.com_virtualmachinereplicasets.yaml +++ b/config/crd/bases/vmoperator.vmware.com_virtualmachinereplicasets.yaml @@ -2321,11 +2321,11 @@ spec: description: |- MACAddr is the optional MAC address of this interface. - If no MAC address is provided, one will be generated by either the network - provider or vCenter. + If no MAC address is provided, one will be generated by either the + network provider or vCenter. - Please note this field is only supported when the Network API Group is - crd.nsx.vmware.com. + Please note, this field is only supported for workloads using VPC + networking. pattern: ^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$ type: string mtu: diff --git a/config/crd/bases/vmoperator.vmware.com_virtualmachines.yaml b/config/crd/bases/vmoperator.vmware.com_virtualmachines.yaml index be9573132..f09af246d 100644 --- a/config/crd/bases/vmoperator.vmware.com_virtualmachines.yaml +++ b/config/crd/bases/vmoperator.vmware.com_virtualmachines.yaml @@ -11566,11 +11566,11 @@ spec: description: |- MACAddr is the optional MAC address of this interface. - If no MAC address is provided, one will be generated by either the network - provider or vCenter. + If no MAC address is provided, one will be generated by either the + network provider or vCenter. - Please note this field is only supported when the Network API Group is - crd.nsx.vmware.com. + Please note, this field is only supported for workloads using VPC + networking. pattern: ^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$ type: string mtu: diff --git a/docs/concepts/workloads/vm.md b/docs/concepts/workloads/vm.md index 7c15ffa44..a66f67bac 100644 --- a/docs/concepts/workloads/vm.md +++ b/docs/concepts/workloads/vm.md @@ -484,6 +484,7 @@ spec: network: interfaces: - name: eth0 + macAddr: "00:11:22:33:44:55" - name: eth1 ``` @@ -547,6 +548,40 @@ The first two network interfaces in the VM are configured using the VM class. Th | `eth1` | `VirtualVmxnet2` | | `eth2` | `VirtualVmxnet3` | +#### MAC Address Configuration + +!!! note "VPC Networking Requirement" + + The `macAddr` field is only supported when using VPC networking. For other network providers, the MAC address will be automatically generated by the underlying infrastructure. + +The `spec.network.interfaces[].macAddr` field allows you to specify a custom MAC address for a network interface. This field is optional and supports the following features: + +- **Format**: Must be a valid MAC address in the format `XX:XX:XX:XX:XX:XX` where X is a hexadecimal digit. +- **Auto-generation**: If no MAC address is provided, one will be automatically generated by either the network provider or vCenter. +- **Network Provider Support**: Setting the MAC address is only supported for workloads connected to VPC networking. +- **Immutability**: Once set, the MAC address cannot be changed for an existing interface + +Example usage: + +```yaml +apiVersion: vmoperator.vmware.com/v1alpha5 +kind: VirtualMachine +metadata: + name: my-vm + namespace: my-namespace +spec: + className: my-vm-class + imageName: vmi-0a0044d7c690bcbea + storageClass: my-storage-class + network: + interfaces: + - name: eth0 + macAddr: "00:11:22:33:44:55" + - name: eth1 + # No MAC address specified - will be auto-generated +``` + + #### Per-Interface Guest Network Configuration There are several options which may be used to influence the guest's per-interface networking configuration. Support for these fields depends on the bootstrap provider. @@ -554,6 +589,7 @@ There are several options which may be used to influence the guest's per-interfa | Field | Description | Cloud-Init | LinuxPrep | Sysprep | |-------|-------------|:----------:|:---------:|:-------:| | `spec.network.interfaces[].guestDeviceName` | The name of the interface in the guest | ✓ | | | +| `spec.network.interfaces[].macAddr` | The MAC address of the interface | ✓ | ✓ | ✓ | | `spec.network.interfaces[].addresses` | The IP4 and IP6 addresses (with prefix length) for the interface | ✓ | ✓ | ✓ | | `spec.network.interfaces[].dhcp4` | Enables DHCP4 | ✓ | ✓ | ✓ | | `spec.network.interfaces[].dhcp6` | Enables DHCP6 | ✓ | ✓ | ✓ |