Skip to content

Commit

Permalink
Merge pull request #12237 from sharifelgamal/cs-start-stop
Browse files Browse the repository at this point in the history
Fix minikube restart on Cloud Shell
  • Loading branch information
sharifelgamal authored Aug 23, 2021
2 parents 6354151 + 8470a95 commit 1af4ec8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
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

0 comments on commit 1af4ec8

Please sign in to comment.