Skip to content

Commit f9d7042

Browse files
committed
fix: allow 1 CPU with --no-kubernetes flag
Skip the minimum CPU validation (requires 2 CPUs) when --no kubernetes is set, since Kubernetes is not being run. Also adds --cpus=1 to existing integration test to verify this behavior. Fixes #22152
1 parent 21d5a9e commit f9d7042

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cmd/minikube/cmd/start.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,8 @@ func validateCPUCount(drvName string) {
12381238
availableCPUs = ci
12391239
}
12401240

1241-
if availableCPUs < 2 {
1241+
// Skip Kubernetes-specific CPU availability check when --no-kubernetes is set
1242+
if availableCPUs < 2 && !viper.GetBool(noKubernetes) {
12421243
if drvName == oci.Docker && runtime.GOOS == "darwin" {
12431244
exitIfNotForced(reason.RsrcInsufficientDarwinDockerCores, "Docker Desktop has less than 2 CPUs configured, but Kubernetes requires at least 2 to be available")
12441245
} else if drvName == oci.Docker && runtime.GOOS == "windows" {
@@ -1253,7 +1254,8 @@ func validateCPUCount(drvName string) {
12531254
return
12541255
}
12551256

1256-
if cpuCount < minimumCPUS {
1257+
// Skip minimum CPU check when --no-kubernetes is set since Kubernetes is not being run
1258+
if cpuCount < minimumCPUS && !viper.GetBool(noKubernetes) {
12571259
exitIfNotForced(reason.RsrcInsufficientCores, "Requested cpu count {{.requested_cpus}} is less than the minimum allowed of {{.minimum_cpus}}", out.V{"requested_cpus": cpuCount, "minimum_cpus": minimumCPUS})
12581260
}
12591261

test/integration/no_kubernetes_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ func validateStartNoK8S(ctx context.Context, t *testing.T, profile string) {
157157
defer PostMortemLogs(t, profile)
158158

159159
// docs: start minikube with no Kubernetes.
160-
args := append([]string{"start", "-p", profile, "--no-kubernetes", "--memory=3072", "--alsologtostderr", "-v=5"}, StartArgs()...)
160+
// Use --cpus=1 to verify that the 2 CPU minimum is not enforced when --no-kubernetes is set.
161+
args := append([]string{"start", "-p", profile, "--no-kubernetes", "--cpus=1", "--memory=3072", "--alsologtostderr", "-v=5"}, StartArgs()...)
161162
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
162163
if err != nil {
163164
t.Fatalf("failed to start minikube with args: %q : %v", rr.Command(), err)

0 commit comments

Comments
 (0)