Skip to content
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

Fix minikube restart on Cloud Shell #12237

Merged
merged 9 commits into from
Aug 23, 2021
12 changes: 12 additions & 0 deletions cmd/minikube/cmd/start_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/cruntime"
"k8s.io/minikube/pkg/minikube/detect"
"k8s.io/minikube/pkg/minikube/download"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/exit"
Expand Down Expand Up @@ -480,6 +481,17 @@ func generateNewConfigFromFlags(cmd *cobra.Command, k8sVersion string, drvName s
cc.ContainerVolumeMounts = []string{viper.GetString(mountString)}
}

if detect.IsCloudShell() {
err := cc.KubernetesConfig.ExtraOptions.Set("kubelet.cgroups-per-qos=false")
if err != nil {
exit.Error(reason.InternalConfigSet, "failed to set cloud shell kubelet config options", err)
}
err = cc.KubernetesConfig.ExtraOptions.Set("kubelet.enforce-node-allocatable=\"\"")
if err != nil {
exit.Error(reason.InternalConfigSet, "failed to set cloud shell kubelet config options", err)
}
}

return cc
}

Expand Down
2 changes: 1 addition & 1 deletion hack/jenkins/cloud_shell_functional_tests_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ gcloud cloud-shell ssh --authorize-session << EOF
DRIVER="docker"
JOB_NAME="Docker_Cloud_Shell"
CONTAINER_RUNTIME="docker"
EXTRA_TEST_ARGS="-test.run (TestFunctional|TestAddons)"
EXTRA_TEST_ARGS="-test.run (TestFunctional|TestAddons|TestStartStop)"

# Need to set these in cloud-shell or will not be present in common.sh
MINIKUBE_LOCATION=$MINIKUBE_LOCATION
Expand Down
11 changes: 11 additions & 0 deletions test/integration/start_stop_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/google/go-cmp/cmp"
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/detect"
)

// TestStartStop tests starting, stopping and restarting a minikube clusters with various Kubernetes versions and configurations
Expand Down Expand Up @@ -76,6 +77,16 @@ func TestStartStop(t *testing.T) {
}},
}

if detect.IsCloudShell() {
tests = []struct {
name string
version string
args []string
}{
{"cloud-shell", constants.DefaultKubernetesVersion, []string{}},
}
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
Expand Down