Skip to content

Commit 6f40a32

Browse files
feat: Update minikube cluster schema with memory and CPU type improvements
1 parent adb77cb commit 6f40a32

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

minikube/generator/schema_builder.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ var schemaOverrides map[string]SchemaOverride = map[string]SchemaOverride{
6060
Default: "4g",
6161
Description: "Amount of RAM to allocate to Kubernetes (format: <number>[<unit>], where unit = b, k, m or g). Use \\\"max\\\" to use the maximum amount of memory. Use \\\"no-limit\\\" to not specify a limit (Docker/Podman only))",
6262
Type: String,
63+
StateFunc: "state_utils.MemoryConverter()",
64+
ValidateDiagFunc: "state_utils.MemoryValidator()",
6365
},
6466
"disk_size": {
6567
Default: "20000mb",

minikube/generator/schema_builder_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ func TestOverride(t *testing.T) {
366366
ForceNew: true,
367367
368368
Default: "4g",
369+
StateFunc: state_utils.MemoryConverter(),
370+
ValidateDiagFunc: state_utils.MemoryValidator(),
369371
},
370372
371373
}

minikube/resource_cluster.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func initialiseMinikubeClient(d *schema.ResourceData, m interface{}) (lib.Cluste
271271
}
272272

273273
memoryStr := d.Get("memory").(string)
274-
memoryMb, err := state_utils.GetMemory(memoryStr);
274+
memoryMb, err := state_utils.GetMemory(memoryStr)
275275
if err != nil {
276276
return nil, err
277277
}
@@ -371,16 +371,16 @@ func initialiseMinikubeClient(d *schema.ResourceData, m interface{}) (lib.Cluste
371371
vc = lib.ResolveSpecialWaitOptions(vc)
372372

373373
cc := config.ClusterConfig{
374-
Addons: addonConfig,
375-
APIServerPort: d.Get("apiserver_port").(int),
376-
Name: d.Get("cluster_name").(string),
377-
KeepContext: d.Get("keep_context").(bool),
378-
EmbedCerts: d.Get("embed_certs").(bool),
379-
MinikubeISO: state_utils.ReadSliceState(defaultIsos)[0],
380-
KicBaseImage: d.Get("base_image").(string),
381-
Network: d.Get("network").(string),
382-
Memory: memoryMb,
383-
CPUs: func() int {
374+
Addons: addonConfig,
375+
APIServerPort: d.Get("apiserver_port").(int),
376+
Name: d.Get("cluster_name").(string),
377+
KeepContext: d.Get("keep_context").(bool),
378+
EmbedCerts: d.Get("embed_certs").(bool),
379+
MinikubeISO: state_utils.ReadSliceState(defaultIsos)[0],
380+
KicBaseImage: d.Get("base_image").(string),
381+
Network: d.Get("network").(string),
382+
Memory: memoryMb,
383+
CPUs: func() int {
384384
cpus, err := state_utils.GetCPUs(d.Get("cpus").(string))
385385
if err != nil {
386386
return 2 // Default to 2 CPUs if there's an error

minikube/schema_cluster.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ var (
137137
Optional: true,
138138
ForceNew: true,
139139

140-
Default: "gcr.io/k8s-minikube/kicbase:v0.0.45@sha256:81df288595202a317b1a4dc2506ca2e4ed5f22373c19a441b88cfbf4b9867c85",
140+
Default: "gcr.io/k8s-minikube/kicbase:v0.0.46@sha256:fd2d445ddcc33ebc5c6b68a17e6219ea207ce63c005095ea1525296da2d1a279",
141141
},
142142

143143
"binary_mirror": {
@@ -191,13 +191,13 @@ var (
191191
},
192192

193193
"cpus": {
194-
Type: schema.TypeInt,
194+
Type: schema.TypeString,
195195
Description: "Number of CPUs allocated to Kubernetes. Use \"max\" to use the maximum number of CPUs. Use \"no-limit\" to not specify a limit (Docker/Podman only)",
196196

197197
Optional: true,
198198
ForceNew: true,
199199

200-
Default: 2,
200+
Default: "2",
201201
},
202202

203203
"cri_socket": {
@@ -413,7 +413,7 @@ var (
413413

414414
"gpus": {
415415
Type: schema.TypeString,
416-
Description: "Allow pods to use your NVIDIA GPUs. Options include: [all,nvidia] (Docker driver with Docker container-runtime only)",
416+
Description: "Allow pods to use your GPUs. Options include: [all,nvidia,amd] (Docker driver with Docker container-runtime only)",
417417

418418
Optional: true,
419419
ForceNew: true,
@@ -598,7 +598,7 @@ var (
598598

599599
"kubernetes_version": {
600600
Type: schema.TypeString,
601-
Description: "The Kubernetes version that the minikube VM will use (ex: v1.2.3, 'stable' for v1.31.0, 'latest' for v1.31.0). Defaults to 'stable'.",
601+
Description: "The Kubernetes version that the minikube VM will use (ex: v1.2.3, 'stable' for v1.32.0, 'latest' for v1.32.0). Defaults to 'stable'.",
602602

603603
Optional: true,
604604
ForceNew: true,
@@ -674,6 +674,8 @@ var (
674674
ForceNew: true,
675675

676676
Default: "4g",
677+
StateFunc: state_utils.MemoryConverter(),
678+
ValidateDiagFunc: state_utils.MemoryValidator(),
677679
},
678680

679681
"mount": {

0 commit comments

Comments
 (0)