Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8329aea
Skip Kubernetes preloads and binary downloads when --no-kubernetes is…
divysinghvi Jul 25, 2025
c4b385f
Merge branch 'kubernetes:master' into no-kubernetes-skip-downloads
divysinghvi Jul 26, 2025
2338a97
Merge branch 'kubernetes:master' into no-kubernetes-skip-downloads
divysinghvi Aug 8, 2025
97f8852
Merge branch 'kubernetes:master' into no-kubernetes-skip-downloads
divysinghvi Aug 9, 2025
801ea3b
Added VerifyNoK8sDownloadCache test for check the v0.0.0 cache
divysinghvi Aug 10, 2025
57dfa41
Merge branch 'kubernetes:master' into no-kubernetes-skip-downloads
divysinghvi Aug 10, 2025
81a1198
Merge branch 'kubernetes:master' into no-kubernetes-skip-downloads
divysinghvi Aug 11, 2025
ac7ef42
Removed extra minikube instance by reusing the validateStartNoK8S ins…
divysinghvi Aug 11, 2025
99bf5f7
Fixed the path issue
divysinghvi Sep 17, 2025
de520ae
Merge branch 'master' into no-kubernetes-skip-downloads
divysinghvi Sep 17, 2025
85dc9bf
Added one more check in cache.go fixing the binary building issue, No…
divysinghvi Sep 25, 2025
f4817ca
Deleted Old test Directory
divysinghvi Sep 26, 2025
389ec44
Cleared Cache insde the VerifyNoK8sDownloadCache test and restarted w…
divysinghvi Sep 26, 2025
a0b3b30
Did not refresh the instance and logged the cache files to understand…
divysinghvi Sep 28, 2025
860101a
Updated VerifyNoK8sDownloadCache test
divysinghvi Oct 2, 2025
cbd40f5
ix Linux-specific cache directory creation in --no-kubernetes mode
divysinghvi Oct 2, 2025
acfd8b7
Added No-kubernetes flag check in TransferBinaries Function and also …
divysinghvi Oct 9, 2025
dd59be3
Merge branch 'kubernetes:master' into no-kubernetes-skip-downloads
divysinghvi Nov 6, 2025
9d0cf67
Merge branch 'kubernetes:master' into no-kubernetes-skip-downloads
divysinghvi Nov 9, 2025
c4345f2
Updated test to not fail when directory is present
divysinghvi Nov 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/minikube/download/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/blang/semver/v4"
"github.com/pkg/errors"
"github.com/spf13/viper"
"k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/localpath"
)
Expand Down Expand Up @@ -53,6 +54,11 @@ func binaryWithChecksumURL(binaryName, version, osName, archName, binaryURL stri

// Binary will download a binary onto the host
func Binary(binary, version, osName, archName, binaryURL string) (string, error) {
// Prevent Kubernetes binary downloads in --no-kubernetes mode
if viper.GetBool("no-kubernetes") {
klog.Infof("Skipping Kubernetes binary download due to --no-kubernetes flag")
return "", nil
}
targetDir := localpath.MakeMiniPath("cache", osName, archName, version)
targetFilepath := path.Join(targetDir, binary)
targetLock := targetFilepath + ".lock"
Expand Down
5 changes: 5 additions & 0 deletions pkg/minikube/download/preload.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ var checkRemotePreloadExists = func(k8sVersion, containerRuntime string) bool {

// PreloadExists returns true if there is a preloaded tarball that can be used
func PreloadExists(k8sVersion, containerRuntime, driverName string, forcePreload ...bool) bool {
// Prevent preload logic in --no-kubernetes mode
if viper.GetBool("no-kubernetes") {
klog.Infof("Skipping preload logic due to --no-kubernetes flag")
return false
}
// TODO (#8166): Get rid of the need for this and viper at all
force := false
if len(forcePreload) > 0 {
Expand Down
20 changes: 15 additions & 5 deletions pkg/minikube/node/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ const (

// BeginCacheKubernetesImages caches images required for Kubernetes version in the background
func beginCacheKubernetesImages(g *errgroup.Group, imageRepository string, k8sVersion string, cRuntime string, driverName string) {
// Skip all caching operations in --no-kubernetes mode
if viper.GetBool("no-kubernetes") {
klog.Infof("Skipping Kubernetes image caching due to --no-kubernetes flag")
return
}

// TODO: remove imageRepository check once #7695 is fixed
if imageRepository == "" && download.PreloadExists(k8sVersion, cRuntime, driverName) {
klog.Info("Caching tarball of preloaded images")
Expand Down Expand Up @@ -81,11 +87,15 @@ func handleDownloadOnly(cacheGroup, kicGroup *errgroup.Group, k8sVersion, contai
}

binariesURL := viper.GetString("binary-mirror")
if err := doCacheBinaries(k8sVersion, containerRuntime, driverName, binariesURL); err != nil {
exit.Error(reason.InetCacheBinaries, "Failed to cache binaries", err)
}
if _, err := CacheKubectlBinary(k8sVersion, binariesURL); err != nil {
exit.Error(reason.InetCacheKubectl, "Failed to cache kubectl", err)

// Skip binary downloads in --no-kubernetes mode
if !viper.GetBool("no-kubernetes") {
if err := doCacheBinaries(k8sVersion, containerRuntime, driverName, binariesURL); err != nil {
exit.Error(reason.InetCacheBinaries, "Failed to cache binaries", err)
}
if _, err := CacheKubectlBinary(k8sVersion, binariesURL); err != nil {
exit.Error(reason.InetCacheKubectl, "Failed to cache kubectl", err)
}
}
waitCacheRequiredImages(cacheGroup)
if driver.IsKIC(driverName) {
Expand Down
31 changes: 31 additions & 0 deletions test/integration/no_kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"

"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/localpath"
)

// TestNoKubernetes tests starting minikube without Kubernetes,
Expand All @@ -52,6 +56,7 @@ func TestNoKubernetes(t *testing.T) {
{"StartWithK8s", validateStartWithK8S},
{"StartWithStopK8s", validateStartWithStopK8s},
{"Start", validateStartNoK8S},
{"VerifyNok8sNoK8sDownloads", VerifyNoK8sDownloadCache},
{"VerifyK8sNotRunning", validateK8SNotRunning},
{"ProfileList", validateProfileListNoK8S},
{"Stop", validateStopNoK8S},
Expand All @@ -76,6 +81,32 @@ func TestNoKubernetes(t *testing.T) {
})
}

// VerifyNoK8sDownloadCache verifies that starting minikube with --no-kubernetes does not create a download cache.
func VerifyNoK8sDownloadCache(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)

cachePath := filepath.Join(localpath.MiniPath(), "cache", "linux", runtime.GOARCH, "v0.0.0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question is why Other tests generated any folder with "v0.0.0" ?
how about instead of this, When it fails we can list the minikube home and check why it is there in first place.

Before minikube test starts, we purge and have we have separte minikube home for the test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would be way better approach i had some issue with it so i was experimenting with thing i will look more into it thanks , yes the other tests should also not generate the folder with "v0.0.0" i was just experimenting with things if that fixes it and also one more issue i am facing is the tests are passing on my system since my last 3 commit
WhatsApp Image 2025-09-26 at 14 58 12

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be tested only on linux !
the reason it is passing on your machine it is beecause it checks to see if linux doesnt exist

you can use goos to get os

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks medhya i have now used GOOS to get current os, and yes it passes on my system now also
=== RUN TestNoKubernetes/serial/VerifyNok8sNoK8sDownloads no_kubernetes_test.go:91: Checking cache directory: /Users/divysinghvi/.minikube/cache/darwin/arm64/v0.0.0 no_kubernetes_test.go:104: No cache directory found (as expected)
also found a function in binary.go TransferBinaries this maybe creating directories so testing it now


// Check if the cache directory exists at all
t.Logf("Checking cache directory: %s", cachePath)
if _, err := os.Stat(cachePath); err == nil {
// Directory exists - let's see what's in it for debugging
if files, err := filepath.Glob(filepath.Join(cachePath, "*")); err == nil && len(files) > 0 {
t.Logf("Files found in cache directory:")
for _, file := range files {
t.Logf(" - %s", file)
}
} else {
t.Logf("Cache directory exists but is empty")
}
t.Errorf("Cache directory %s should not exist when using --no-kubernetes", cachePath)
} else if os.IsNotExist(err) {
t.Logf("No cache directory found (as expected)")
} else {
t.Errorf("Error checking cache directory %s: %v", cachePath, err)
}
}

// validateStartNoK8sWithVersion expect an error when starting a minikube cluster without kubernetes and with a kubernetes version.
func validateStartNoK8sWithVersion(ctx context.Context, t *testing.T, profile string) {
defer PostMortemLogs(t, profile)
Expand Down