From ed59f851533a0fd15986e9e66e3d64d2c2305c67 Mon Sep 17 00:00:00 2001 From: dlorenc Date: Tue, 27 Mar 2018 10:47:33 -0700 Subject: [PATCH] Manual changes for 1.10. localkube now has to be non-statically compiled :( --- Makefile | 6 ++-- deploy/addons/addon-manager.yaml | 4 +-- pkg/localkube/apiserver.go | 4 +-- pkg/localkube/controller-manager.go | 29 +++++++++++-------- pkg/localkube/kubelet.go | 7 ++--- pkg/localkube/localkube.go | 22 ++++++++++++++ pkg/localkube/proxy.go | 14 +++++---- pkg/localkube/scheduler.go | 2 +- pkg/minikube/bootstrapper/kubeadm/versions.go | 9 +++++- .../kubernetes/cmd/kubelet/app/server.go | 1 - 10 files changed, 66 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index 45f6f1a35f02..f5db646e4b9c 100755 --- a/Makefile +++ b/Makefile @@ -52,7 +52,7 @@ STORAGE_PROVISIONER_TAG := v1.8.1 # Set the version information for the Kubernetes servers, and build localkube statically K8S_VERSION_LDFLAGS := $(shell $(PYTHON) hack/get_k8s_version.py 2>&1) MINIKUBE_LDFLAGS := -X k8s.io/minikube/pkg/version.version=$(VERSION) -X k8s.io/minikube/pkg/version.isoVersion=$(ISO_VERSION) -X k8s.io/minikube/pkg/version.isoPath=$(ISO_BUCKET) -LOCALKUBE_LDFLAGS := "$(K8S_VERSION_LDFLAGS) $(MINIKUBE_LDFLAGS) -s -w -extldflags '-static'" +LOCALKUBE_LDFLAGS := "$(K8S_VERSION_LDFLAGS) $(MINIKUBE_LDFLAGS) -s -w" MAKEDEPEND := GOPATH=$(GOPATH) ./makedepend.sh @@ -98,14 +98,14 @@ out/minikube$(IS_EXE): out/minikube-$(GOOS)-$(GOARCH)$(IS_EXE) cp $< $@ out/localkube.d: - $(MAKEDEPEND) out/localkube $(ORG) $(LOCALKUBEFILES) $^ > $@ + GOOS=linux GOARCH=amd64 $(MAKEDEPEND) out/localkube $(ORG) $(LOCALKUBEFILES) $^ > $@ -include out/localkube.d out/localkube: ifeq ($(LOCALKUBE_BUILD_IN_DOCKER),y) $(call DOCKER,$(BUILD_IMAGE),/usr/bin/make $@) else - CGO_ENABLED=1 go build -tags static_build -ldflags=$(LOCALKUBE_LDFLAGS) -o $(BUILD_DIR)/localkube ./cmd/localkube + CGO_ENABLED=1 go build -ldflags=$(LOCALKUBE_LDFLAGS) -o $(BUILD_DIR)/localkube ./cmd/localkube endif out/minikube-windows-amd64.exe: out/minikube-windows-amd64 diff --git a/deploy/addons/addon-manager.yaml b/deploy/addons/addon-manager.yaml index ea2314c64259..0dfce2519cf0 100644 --- a/deploy/addons/addon-manager.yaml +++ b/deploy/addons/addon-manager.yaml @@ -19,13 +19,13 @@ metadata: namespace: kube-system labels: component: kube-addon-manager - version: v6.5 + version: v8.6 kubernetes.io/minikube-addons: addon-manager spec: hostNetwork: true containers: - name: kube-addon-manager - image: gcr.io/google-containers/kube-addon-manager:v6.5 + image: gcr.io/google-containers/kube-addon-manager:v8.6 env: - name: KUBECONFIG value: /var/lib/localkube/kubeconfig diff --git a/pkg/localkube/apiserver.go b/pkg/localkube/apiserver.go index 1946e1166682..6d0c84b45987 100644 --- a/pkg/localkube/apiserver.go +++ b/pkg/localkube/apiserver.go @@ -28,9 +28,9 @@ import ( apiserveroptions "k8s.io/apiserver/pkg/server/options" "k8s.io/apiserver/pkg/storage/storagebackend" + genericoptions "k8s.io/apiserver/pkg/server/options" apiserver "k8s.io/kubernetes/cmd/kube-apiserver/app" "k8s.io/kubernetes/cmd/kube-apiserver/app/options" - kubeapioptions "k8s.io/kubernetes/pkg/kubeapiserver/options" ) func (lk LocalkubeServer) NewAPIServer() Server { @@ -69,7 +69,7 @@ func StartAPIServer(lk LocalkubeServer) func() error { config.AllowPrivileged = true - config.APIEnablement = &kubeapioptions.APIEnablementOptions{ + config.APIEnablement = &genericoptions.APIEnablementOptions{ RuntimeConfig: lk.RuntimeConfig, } diff --git a/pkg/localkube/controller-manager.go b/pkg/localkube/controller-manager.go index ef642ebaf5d4..735ee1179a24 100644 --- a/pkg/localkube/controller-manager.go +++ b/pkg/localkube/controller-manager.go @@ -18,6 +18,7 @@ package localkube import ( controllerManager "k8s.io/kubernetes/cmd/kube-controller-manager/app" + "k8s.io/kubernetes/cmd/kube-controller-manager/app/config" "k8s.io/kubernetes/cmd/kube-controller-manager/app/options" "k8s.io/minikube/pkg/util" ) @@ -27,24 +28,28 @@ func (lk LocalkubeServer) NewControllerManagerServer() Server { } func StartControllerManagerServer(lk LocalkubeServer) func() error { - config := options.NewCMServer() + opts := options.NewKubeControllerManagerOptions() - config.Kubeconfig = util.DefaultKubeConfigPath + opts.Generic.Kubeconfig = util.DefaultKubeConfigPath // defaults from command - config.DeletingPodsQps = 0.1 - config.DeletingPodsBurst = 10 - config.NodeEvictionRate = 0.1 + opts.Generic.ComponentConfig.DeletingPodsQps = 0.1 + opts.Generic.ComponentConfig.DeletingPodsBurst = 10 + opts.Generic.ComponentConfig.NodeEvictionRate = 0.1 - config.EnableProfiling = true - config.VolumeConfiguration.EnableHostPathProvisioning = true - config.VolumeConfiguration.EnableDynamicProvisioning = true - config.ServiceAccountKeyFile = lk.GetPrivateKeyCertPath() - config.RootCAFile = lk.GetCAPublicKeyCertPath() + opts.Generic.ComponentConfig.EnableProfiling = true + opts.Generic.ComponentConfig.VolumeConfiguration.EnableHostPathProvisioning = true + opts.Generic.ComponentConfig.VolumeConfiguration.EnableDynamicProvisioning = true + opts.Generic.ComponentConfig.ServiceAccountKeyFile = lk.GetPrivateKeyCertPath() + opts.Generic.ComponentConfig.RootCAFile = lk.GetCAPublicKeyCertPath() - lk.SetExtraConfigForComponent("controller-manager", &config) + lk.SetExtraConfigForComponent("controller-manager", &opts) + cfg := config.Config{} + if err := opts.ApplyTo(&cfg); err != nil { + panic(err) + } return func() error { - return controllerManager.Run(config) + return controllerManager.Run(cfg.Complete()) } } diff --git a/pkg/localkube/kubelet.go b/pkg/localkube/kubelet.go index 7a7435f2564b..0c81548230b1 100644 --- a/pkg/localkube/kubelet.go +++ b/pkg/localkube/kubelet.go @@ -17,7 +17,6 @@ limitations under the License. package localkube import ( - "k8s.io/apiserver/pkg/util/flag" kubelet "k8s.io/kubernetes/cmd/kubelet/app" "k8s.io/kubernetes/cmd/kubelet/app/options" "k8s.io/minikube/pkg/util" @@ -38,14 +37,13 @@ func StartKubeletServer(lk LocalkubeServer) func() error { } // Master details - config.KubeConfig = flag.NewStringFlag(util.DefaultKubeConfigPath) - config.RequireKubeConfig = true + config.KubeConfig = util.DefaultKubeConfigPath // Set containerized based on the flag config.Containerized = lk.Containerized config.AllowPrivileged = true - config.PodManifestPath = "/etc/kubernetes/manifests" + config.StaticPodPath = "/etc/kubernetes/manifests" // Networking config.ClusterDomain = lk.DNSDomain @@ -54,6 +52,7 @@ func StartKubeletServer(lk LocalkubeServer) func() error { config.PodCIDR = "10.180.1.0/24" config.NodeIP = lk.NodeIP.String() + config.FailSwapOn = false if lk.NetworkPlugin != "" { config.NetworkPluginName = lk.NetworkPlugin diff --git a/pkg/localkube/localkube.go b/pkg/localkube/localkube.go index 3b08b90d602e..d8346d1e0410 100644 --- a/pkg/localkube/localkube.go +++ b/pkg/localkube/localkube.go @@ -26,6 +26,7 @@ import ( "net/http" "path" "strconv" + "strings" "github.com/golang/glog" "github.com/pkg/errors" @@ -179,6 +180,27 @@ func (lk LocalkubeServer) SetExtraConfigForComponent(component string, config in } } +func (lk LocalkubeServer) GetFeatureGates() (map[string]bool, error) { + fg := map[string]bool{} + if lk.FeatureGates == "" { + return fg, nil + } + gates := strings.Split(lk.FeatureGates, ",") + for _, g := range gates { + + kvp := strings.SplitN(g, "=", 2) + if len(kvp) != 2 { + return nil, fmt.Errorf("invalid feature gate specification: %s", g) + } + value, err := strconv.ParseBool(kvp[1]) + if err != nil { + return nil, fmt.Errorf("invalid feature gate specification: %s", g) + } + fg[kvp[0]] = value + } + return fg, nil +} + func (lk LocalkubeServer) loadCert(path string) (*x509.Certificate, error) { contents, err := ioutil.ReadFile(path) if err != nil { diff --git a/pkg/localkube/proxy.go b/pkg/localkube/proxy.go index e617ad79a11b..3b53f84fe087 100644 --- a/pkg/localkube/proxy.go +++ b/pkg/localkube/proxy.go @@ -43,6 +43,10 @@ func StartProxyServer(lk LocalkubeServer) func() error { } opts := kubeproxy.NewOptions() + fg, err := lk.GetFeatureGates() + if err != nil { + panic(err) + } config := &kubeproxyconfig.KubeProxyConfiguration{ OOMScoreAdj: &OOMScoreAdj, ClientConnection: kubeproxyconfig.ClientConnectionConfiguration{ @@ -58,17 +62,15 @@ func StartProxyServer(lk LocalkubeServer) func() error { }, BindAddress: bindaddress, Mode: kubeproxyconfig.ProxyModeIPTables, - FeatureGates: lk.FeatureGates, + FeatureGates: fg, // Disable the healthz check - HealthzBindAddress: "0", + HealthzBindAddress: "", } - _, err := opts.ApplyDefaults(config) - if err != nil { + if _, err := opts.ApplyDefaults(config); err != nil { panic(err) } - opts.SetConfig(config) - lk.SetExtraConfigForComponent("proxy", &config) + opts.SetConfig(config) return func() error { return opts.Run() diff --git a/pkg/localkube/scheduler.go b/pkg/localkube/scheduler.go index 6fda922593d6..59616dfc55fb 100644 --- a/pkg/localkube/scheduler.go +++ b/pkg/localkube/scheduler.go @@ -17,8 +17,8 @@ limitations under the License. package localkube import ( + scheduler "k8s.io/kubernetes/cmd/kube-scheduler/app" "k8s.io/kubernetes/pkg/apis/componentconfig" - scheduler "k8s.io/kubernetes/plugin/cmd/kube-scheduler/app" "k8s.io/minikube/pkg/util" ) diff --git a/pkg/minikube/bootstrapper/kubeadm/versions.go b/pkg/minikube/bootstrapper/kubeadm/versions.go index c54700724085..df5583ba81fe 100644 --- a/pkg/minikube/bootstrapper/kubeadm/versions.go +++ b/pkg/minikube/bootstrapper/kubeadm/versions.go @@ -173,7 +173,14 @@ var versionSpecificOpts = []VersionedExtraOption{ // Kubeconfig args NewUnversionedOption(Kubelet, "kubeconfig", "/etc/kubernetes/kubelet.conf"), NewUnversionedOption(Kubelet, "bootstrap-kubeconfig", "/etc/kubernetes/bootstrap-kubelet.conf"), - NewUnversionedOption(Kubelet, "require-kubeconfig", "true"), + { + Option: util.ExtraOption{ + Component: Apiserver, + Key: "require-kubeconfig", + Value: "true", + }, + LessThanOrEqual: semver.MustParse("1.9.10"), + }, NewUnversionedOption(Kubelet, "hostname-override", "minikube"), // System pods args diff --git a/vendor/k8s.io/kubernetes/cmd/kubelet/app/server.go b/vendor/k8s.io/kubernetes/cmd/kubelet/app/server.go index ebdd31d040a6..b0329fa03e78 100644 --- a/vendor/k8s.io/kubernetes/cmd/kubelet/app/server.go +++ b/vendor/k8s.io/kubernetes/cmd/kubelet/app/server.go @@ -413,7 +413,6 @@ func initConfigz(kc *kubeletconfiginternal.KubeletConfiguration) error { } if err := setConfigz(cz, kc); err != nil { glog.Errorf("unable to register config: %s", err) - return err } return nil }