When listing the resources supported by the VSphereMachineTemplate, the field ipAddrs is included as a field useful to assign static ip addresses.
kubectl explain VSphereMachineTemplate.spec.template.spec.network.devices.ipAddrs
KIND: VSphereMachineTemplate
VERSION: infrastructure.cluster.x-k8s.io/v1beta1
FIELD: ipAddrs <[]string>
DESCRIPTION:
IPAddrs is a list of one or more IPv4 and/or IPv6 addresses to assign to
this device. Required when DHCP4 and DHCP6 are both false.
However, according to the vsphere cluster-api provider github code, this option is blocked for the api version v1beta1. In consequence, when the operator defines a list of static ip addresses, the following exception is returned:
Error from server (Invalid): error when creating "cluster_test.yaml": admission webhook
"validation.vspheremachinetemplate.infrastructure.x-k8s.io" denied the request:
VSphereMachineTemplate.infrastructure.cluster.x-k8s.io "dkp-cluster-vsphere-konvoy22-md-0" is invalid:
spec.template.spec.network.devices.ipAddrs: Forbidden: cannot be set in templates
There is no current workaround, as this is an upstream issue. As of now the only option to assign IP addresses is DHCP4/6.
kubectl explain VSphereMachineTemplate.spec.template.spec.network.devices.dhcp4
KIND: VSphereMachineTemplate
VERSION: infrastructure.cluster.x-k8s.io/v1beta1
FIELD: dhcp4 <boolean>
DESCRIPTION:
DHCP4 is a flag that indicates whether or not to use DHCP for IPv4 on this
device. If true then IPAddrs should not contain any IPv4 addresses.