diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go index 7646827c83..a20cce60ba 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm.go @@ -302,23 +302,6 @@ sudo systemctl start kubelet return nil } -func parseFeatureGates(featureGates string) (map[string]string, error) { - if featureGates == "" { - return nil, nil - } - fgMap := map[string]string{} - fg := strings.Split(featureGates, ",") - for _, f := range fg { - kv := strings.SplitN(f, "=", 2) - if len(kv) != 2 { - return nil, fmt.Errorf("Invalid feature gate format: %s", f) - } - fgMap[kv[0]] = kv[1] - } - - return fgMap, nil -} - func generateConfig(k8s bootstrapper.KubernetesConfig) (string, error) { version, err := ParseKubernetesVersion(k8s.KubernetesVersion) if err != nil { diff --git a/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go b/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go index 574ebe7266..5d598ba02a 100644 --- a/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go +++ b/pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go @@ -17,7 +17,6 @@ limitations under the License. package kubeadm import ( - "reflect" "testing" "k8s.io/minikube/pkg/minikube/bootstrapper" @@ -233,54 +232,3 @@ schedulerExtraArgs: }) } } - -func TestParseFeatureGates(t *testing.T) { - tests := []struct { - description string - fg string - expected map[string]string - shouldErr bool - }{ - { - description: "no feature gates", - }, - { - description: "one feature gate", - fg: "AppArmor=true", - expected: map[string]string{ - "AppArmor": "true", - }, - }, - { - description: "two feature gates", - fg: "AppArmor=true,HugePages=true", - expected: map[string]string{ - "AppArmor": "true", - "HugePages": "true", - }, - }, - { - description: "missing value pair", - fg: "AppArmor=true,HugePages", - shouldErr: true, - }, - } - - for _, test := range tests { - t.Run(test.description, func(t *testing.T) { - actual, err := parseFeatureGates(test.fg) - t.Logf("%+v", actual) - if err == nil && test.shouldErr { - t.Errorf("Expected error but got none: fg: %v", actual) - return - } - if err != nil && !test.shouldErr { - t.Errorf("Unexpected error: %s", err) - return - } - if !reflect.DeepEqual(actual, test.expected) { - t.Errorf("Actual not equal expected: Actual: %v Expected: %v", actual, test.expected) - } - }) - } -} diff --git a/pkg/minikube/bootstrapper/kubeadm/templates.go b/pkg/minikube/bootstrapper/kubeadm/templates.go index 3e7a16f27e..6dbd445b0e 100644 --- a/pkg/minikube/bootstrapper/kubeadm/templates.go +++ b/pkg/minikube/bootstrapper/kubeadm/templates.go @@ -40,31 +40,15 @@ nodeName: {{.NodeName}} {{$val}}{{end}} {{end}}`)) -var kubeletSystemdTemplate = template.Must(template.New("kubeletSystemdTemplate").Funcs(template.FuncMap{ - "installWants": installWants, -}).Parse(` +var kubeletSystemdTemplate = template.Must(template.New("kubeletSystemdTemplate").Parse(` [Service] ExecStart= ExecStart=/usr/bin/kubelet {{.ExtraOptions}} {{if .FeatureGates}}--feature-gates={{.FeatureGates}}{{end}} [Install] -{{installWants .ContainerRuntime}} +{{if or (eq .ContainerRuntime "cri-o") (eq .ContainerRuntime "cri")}}Wants=crio.service{{else}}Wants=docker.socket{{end}} `)) -func installWants(containerRuntime string) string { - var wants string - switch containerRuntime { - case "": - wants = "docker.socket" - case "cri-o", "cri": - wants = "crio.service" - } - if wants != "" { - return fmt.Sprintf("Wants=%s", wants) - } - return "" -} - const kubeletService = ` [Unit] Description=kubelet: The Kubernetes Node Agent