Skip to content

Commit

Permalink
Manual changes for 1.10.
Browse files Browse the repository at this point in the history
localkube now has to be non-statically compiled :(
  • Loading branch information
dlorenc authored and dlorenc committed Mar 28, 2018
1 parent 6ff1639 commit dcb5c2c
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 42 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions deploy/addons/addon-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/localkube/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -69,7 +69,7 @@ func StartAPIServer(lk LocalkubeServer) func() error {

config.AllowPrivileged = true

config.APIEnablement = &kubeapioptions.APIEnablementOptions{
config.APIEnablement = &genericoptions.APIEnablementOptions{
RuntimeConfig: lk.RuntimeConfig,
}

Expand Down
29 changes: 17 additions & 12 deletions pkg/localkube/controller-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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())
}
}
7 changes: 3 additions & 4 deletions pkg/localkube/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand Down
22 changes: 22 additions & 0 deletions pkg/localkube/localkube.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"net/http"
"path"
"strconv"
"strings"

"github.com/golang/glog"
"github.com/pkg/errors"
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 8 additions & 6 deletions pkg/localkube/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion pkg/localkube/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
26 changes: 16 additions & 10 deletions pkg/minikube/bootstrapper/kubeadm/kubeadm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,30 @@ func TestGenerateConfig(t *testing.T) {
description: "no extra args",
cfg: config.KubernetesConfig{
NodeIP: "192.168.1.100",
KubernetesVersion: "v1.8.0",
KubernetesVersion: "v1.10.0",
NodeName: "minikube",
},
expectedCfg: `apiVersion: kubeadm.k8s.io/v1alpha1
kind: MasterConfiguration
api:
advertiseAddress: 192.168.1.100
bindPort: 8443
kubernetesVersion: v1.8.0
kubernetesVersion: v1.10.0
certificatesDir: /var/lib/localkube/certs/
networking:
serviceSubnet: 10.96.0.0/12
etcd:
dataDir: /data
nodeName: minikube
apiServerExtraArgs:
admission-control: "Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
`,
},
{
description: "extra args all components",
cfg: config.KubernetesConfig{
NodeIP: "192.168.1.101",
KubernetesVersion: "v1.8.0-alpha.0",
KubernetesVersion: "v1.10.0-alpha.0",
NodeName: "extra-args-minikube",
ExtraOptions: util.ExtraOptionSlice{
util.ExtraOption{
Expand All @@ -80,14 +82,15 @@ kind: MasterConfiguration
api:
advertiseAddress: 192.168.1.101
bindPort: 8443
kubernetesVersion: v1.8.0-alpha.0
kubernetesVersion: v1.10.0-alpha.0
certificatesDir: /var/lib/localkube/certs/
networking:
serviceSubnet: 10.96.0.0/12
etcd:
dataDir: /data
nodeName: extra-args-minikube
apiServerExtraArgs:
admission-control: "Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
fail-no-swap: "true"
controllerManagerExtraArgs:
kube-api-burst: "32"
Expand All @@ -99,7 +102,7 @@ schedulerExtraArgs:
description: "two extra args for one component",
cfg: config.KubernetesConfig{
NodeIP: "192.168.1.101",
KubernetesVersion: "v1.8.0-alpha.0",
KubernetesVersion: "v1.10.0-alpha.0",
NodeName: "extra-args-minikube",
ExtraOptions: util.ExtraOptionSlice{
util.ExtraOption{
Expand All @@ -119,14 +122,15 @@ kind: MasterConfiguration
api:
advertiseAddress: 192.168.1.101
bindPort: 8443
kubernetesVersion: v1.8.0-alpha.0
kubernetesVersion: v1.10.0-alpha.0
certificatesDir: /var/lib/localkube/certs/
networking:
serviceSubnet: 10.96.0.0/12
etcd:
dataDir: /data
nodeName: extra-args-minikube
apiServerExtraArgs:
admission-control: "Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
fail-no-swap: "true"
kube-api-burst: "32"
`,
Expand All @@ -135,7 +139,7 @@ apiServerExtraArgs:
description: "enable feature gates",
cfg: config.KubernetesConfig{
NodeIP: "192.168.1.101",
KubernetesVersion: "v1.8.0-alpha.0",
KubernetesVersion: "v1.10.0-alpha.0",
NodeName: "extra-args-minikube",
FeatureGates: "HugePages=true,OtherFeature=false",
},
Expand All @@ -144,14 +148,15 @@ kind: MasterConfiguration
api:
advertiseAddress: 192.168.1.101
bindPort: 8443
kubernetesVersion: v1.8.0-alpha.0
kubernetesVersion: v1.10.0-alpha.0
certificatesDir: /var/lib/localkube/certs/
networking:
serviceSubnet: 10.96.0.0/12
etcd:
dataDir: /data
nodeName: extra-args-minikube
apiServerExtraArgs:
admission-control: "Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
feature-gates: "HugePages=true,OtherFeature=false"
controllerManagerExtraArgs:
feature-gates: "HugePages=true,OtherFeature=false"
Expand All @@ -163,7 +168,7 @@ schedulerExtraArgs:
description: "enable feature gates and extra config",
cfg: config.KubernetesConfig{
NodeIP: "192.168.1.101",
KubernetesVersion: "v1.8.0-alpha.0",
KubernetesVersion: "v1.10.0-alpha.0",
NodeName: "extra-args-minikube",
FeatureGates: "HugePages=true,OtherFeature=false",
ExtraOptions: util.ExtraOptionSlice{
Expand All @@ -179,14 +184,15 @@ kind: MasterConfiguration
api:
advertiseAddress: 192.168.1.101
bindPort: 8443
kubernetesVersion: v1.8.0-alpha.0
kubernetesVersion: v1.10.0-alpha.0
certificatesDir: /var/lib/localkube/certs/
networking:
serviceSubnet: 10.96.0.0/12
etcd:
dataDir: /data
nodeName: extra-args-minikube
apiServerExtraArgs:
admission-control: "Initializers,NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota"
fail-no-swap: "true"
feature-gates: "HugePages=true,OtherFeature=false"
controllerManagerExtraArgs:
Expand Down
9 changes: 8 additions & 1 deletion pkg/minikube/bootstrapper/kubeadm/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion vendor/k8s.io/kubernetes/cmd/kubelet/app/server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dcb5c2c

Please sign in to comment.