When using the DKP 2.2 VSphere provider to deploy Kubernetes clusters, the node resources (CPU, Disk and memory) can be specified by modifying the control plane/worker VSphereMachineTemplate. By default, the values for these parameters (numCPUs, memoryMiB and diskGiB) are set to the value in the template from which the virtual machine is cloned.
While CPU and memory can be modified independent of the clone mode used, by specifying the following parameters:
VSphereMachineTemplate.spec.template.spec.numCPUs
VSphereMachineTemplate.spec.template.spec.memoryMiB
specifying a disk size different to the value in the VM template from which the virtual machine is cloned is only allowed when the VM is fully cloned. Disk size can be specified with the following parameter:
VSphereMachineTemplate.spec.template.spec.diskGiB
When using clone mode equal to LinkedMode, although it is faster than FullMode, will prevent the expansion of the VM disk beyond the size of the source template.
The clone mode method can be specified by setting the following parameter in the VSphereMachineTemplate to “FullClone”:
VSphereMachineTemplate.spec.template.spec.cloneMode
Example:
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: VSphereMachineTemplate
metadata:
name: <cluster-name>-control-plane
namespace: default
spec:
template:
spec:
cloneMode: FullClone
datacenter: <dc-name>
datastore: <datastore-name>
diskGiB: <disk-size>
folder: konvoy-capi-vsphere
memoryMiB: <memory>
network:
devices:
- dhcp4: true
networkName: <network-name>
numCPUs: 4
resourcePool: <resourcepool-name>
server: <ip address>
template: <vm-template-name>
thumbprint: C4:93:CC:E5:AA:80:57:38:54:05:3F:1C:7C:CE:44:46:58:E3:56:1F
---
Please note that shrinking a disk is not possible, therefore the machine creation will fail, and the following event will be encountered in the events for the machine object:
Message: error getting disk spec for "infrastructure.cluster.x-k8s.io/v1beta1,
Kind=VSphereVM default/sortega-dkp240-rhel84-vsphere-airgap-fips-c1-control-planef8ptm":
Error getting disk config spec for primary disk: can't resize template disk down,
initial capacity is larger: 104857600KiB > 83886080KiB
The solution is to specify a disk size equal or larger than the disk size in the template.
Reference:
https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/43dc9ab1e663f50f42798144cdeb0b5cedc70026/apis/v1beta1/types.go#L66