-
Notifications
You must be signed in to change notification settings - Fork 5k
Add --no-kubernetes flag to start minikube without kubernetes #12848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+188
โ15
Merged
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
79f1b8c
add --no-kubernetes flag to start minikube without kubernetes
medyagh c827bf8
better name
medyagh 3d0f486
add integration test for --no-kubernetes
medyagh bfdc3cf
address review comments
medyagh cd9d263
address review comments
medyagh 5bcdba0
add more constants
medyagh d3ec072
Update test/integration/no_kubernetes.go
medyagh 47307d7
Update test/integration/no_kubernetes.go
medyagh 51e612f
Update test/integration/no_kubernetes.go
medyagh 1200c8e
Update test/integration/no_kubernetes.go
medyagh f54f95d
Update test/integration/no_kubernetes.go
medyagh e15065a
Update test/integration/no_kubernetes.go
medyagh 0ef4fc5
Update test/integration/no_kubernetes.go
medyagh 6806e69
fix integration test file name
medyagh 630e02d
Update cmd/minikube/cmd/start.go
medyagh a108c71
remove comment
medyagh 92cf41d
do not set global viper config
medyagh 75e6ba6
better translate
medyagh f2c743d
skip test on none
medyagh f405565
spell
medyagh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
//go:build integration | ||
// +build integration | ||
|
||
/* | ||
Copyright 2021 The Kubernetes Authors All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package integration | ||
|
||
import ( | ||
"context" | ||
"os/exec" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
// TestNoKubernetes tests starting minikube without Kubernetes, | ||
// for usecases where user only needs to use the container runtime (docker,containerd,crio) inside minikube | ||
medyagh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
func TestNoKubernetes(t *testing.T) { | ||
MaybeParallel(t) | ||
|
||
type validateFunc func(context.Context, *testing.T, string) | ||
profile := UniqueProfileName("NoKubernetes") | ||
ctx, cancel := context.WithTimeout(context.Background(), Minutes(5)) | ||
defer Cleanup(t, profile, cancel) | ||
|
||
// Serial tests | ||
t.Run("serial", func(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
validator validateFunc | ||
}{ | ||
{"Start", validateStartNoK8S}, | ||
{"VerifyK8sNotRunning", validateK8SNotRunning}, | ||
{"ProfileList", validateProfileListNoK8S}, | ||
{"Stop", validateStopNoK8S}, | ||
{"StartNoArgs", validateStartNorArgs}, | ||
medyagh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{"VerifyK8sNotRunningSecond", validateK8SNotRunning}, | ||
} | ||
|
||
for _, tc := range tests { | ||
tc := tc | ||
|
||
if ctx.Err() == context.DeadlineExceeded { | ||
t.Fatalf("Unable to run more tests (deadline exceeded)") | ||
} | ||
|
||
t.Run(tc.name, func(t *testing.T) { | ||
tc.validator(ctx, t, profile) | ||
if t.Failed() && *postMortemLogs { | ||
PostMortemLogs(t, profile) | ||
} | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
// validateStartNoK8S starts a minikube cluster without kuberentes started/configured | ||
medyagh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
func validateStartNoK8S(ctx context.Context, t *testing.T, profile string) { | ||
defer PostMortemLogs(t, profile) | ||
|
||
args := append([]string{"start", "-p", profile, "--no-kubernetes"}, StartArgs()...) | ||
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) | ||
if err != nil { | ||
t.Fatalf("failed to start minikube with args: %q : %v", rr.Command(), err) | ||
} | ||
} | ||
|
||
// validateK8SNotRunning validates that there is no kubernetes running inside minikube | ||
func validateK8SNotRunning(ctx context.Context, t *testing.T, profile string) { | ||
defer PostMortemLogs(t, profile) | ||
|
||
args := []string{"ssh", "-p", profile, "sudo systemctl is-active --quiet service kubelet"} | ||
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) | ||
if err == nil { | ||
t.Fatalf("Expected Kubelet not to be running and but it is running : %q : %v", rr.Command(), err) | ||
} | ||
} | ||
|
||
// validateStopNoK8S validates that minikube is stopped after a --no-kubernetes start | ||
func validateStopNoK8S(ctx context.Context, t *testing.T, profile string) { | ||
defer PostMortemLogs(t, profile) | ||
|
||
args := []string{"stop", "-p", profile} | ||
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) | ||
if err != nil { | ||
t.Fatalf("Failed to stop minikbue %q : %v", rr.Command(), err) | ||
medyagh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
// validateProfileListNoK8S validates that profile list works with --no-kubernetes | ||
func validateProfileListNoK8S(ctx context.Context, t *testing.T, profile string) { | ||
defer PostMortemLogs(t, profile) | ||
|
||
args := []string{"profile", "list"} | ||
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) | ||
if err != nil { | ||
t.Fatalf("Profile list failed : %q : %v", rr.Command(), err) | ||
} | ||
|
||
if !strings.Contains(rr.Output(), "N/A") { | ||
t.Fatalf("expected N/A in the profile list for kubernets version but got : %q : %v", rr.Command(), rr.Output()) | ||
medyagh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
args = []string{"profile", "list", "--output=json"} | ||
rr, err = Run(t, exec.CommandContext(ctx, Target(), args...)) | ||
if err != nil { | ||
t.Fatalf("Profile list --output=json failed : %q : %v", rr.Command(), err) | ||
} | ||
|
||
} | ||
|
||
// validateStartNorArgs valides that minikube start with no args works | ||
medyagh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
func validateStartNorArgs(ctx context.Context, t *testing.T, profile string) { | ||
medyagh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
defer PostMortemLogs(t, profile) | ||
|
||
args := append([]string{"start", "-p", profile, "--no-kubernetes"}, StartArgs()...) | ||
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) | ||
if err != nil { | ||
t.Fatalf("failed to start minikube with args: %q : %v", rr.Command(), err) | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.