diff --git a/charts/internal/machineclass/templates/machineclass.yaml b/charts/internal/machineclass/templates/machineclass.yaml index f593de98..bff589fe 100644 --- a/charts/internal/machineclass/templates/machineclass.yaml +++ b/charts/internal/machineclass/templates/machineclass.yaml @@ -35,6 +35,7 @@ providerSpec: floatingPoolID: {{ $machineClass.floatingPoolID }} {{- end }} {{- if $machineClass.extraConfig }} + volumeSize: {{ $machineClass.volumeSize }} extraConfig: {{ toYaml $machineClass.extraConfig | indent 4 }} {{- end }} diff --git a/pkg/controller/worker/machines.go b/pkg/controller/worker/machines.go index a0d2b718..ae6dbf49 100644 --- a/pkg/controller/worker/machines.go +++ b/pkg/controller/worker/machines.go @@ -165,8 +165,8 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error { "datacenterID": infraStatus.DatacenterID, "cluster": w.worker.Namespace, "zone": zone, - "cores": values.cores, - "memory": values.memoryInMB, + "cores": values.Cores, + "memory": values.MemoryInMB, "imageID": imageID, "sshKey": string(w.worker.Spec.SSHPublicKey), "networkIDs": infraStatus.NetworkIDs, @@ -187,6 +187,17 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error { } } + if nil != pool.Volume && "" != pool.Volume.Size { + volumeSize, err := worker.DiskSize(pool.Volume.Size) + if err != nil { + return err + } + + if volumeSize > 0 { + machineClassSpec["volumeSize"] = volumeSize + } + } + deploymentName := fmt.Sprintf("%s-%s-%s", w.worker.Namespace, pool.Name, zone) className := fmt.Sprintf("%s-%s", deploymentName, workerPoolHash) @@ -217,8 +228,8 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error { } type machineValues struct { - cores int - memoryInMB int + Cores int + MemoryInMB int MachineTypeOptions *apis.MachineTypeOptions } @@ -241,17 +252,17 @@ func (w *workerDelegate) extractMachineValues(machineTypeName string) (*machineV values := &machineValues{} if n, ok := machineType.CPU.AsInt64(); ok { - values.cores = int(n) + values.Cores = int(n) } - if values.cores <= 0 { + if values.Cores <= 0 { err := fmt.Errorf("machine type %s has invalid CPU value %s", machineTypeName, machineType.CPU.String()) return nil, err } if n, ok := machineType.Memory.AsInt64(); ok { - values.memoryInMB = int(n) / (1024 * 1024) + values.MemoryInMB = int(n) / (1024 * 1024) } - if values.memoryInMB <= 0 { + if values.MemoryInMB <= 0 { err := fmt.Errorf("machine type %s has invalid Memory value %s", machineTypeName, machineType.Memory.String()) return nil, err }