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

Initial support for Kubernetes 1.12+ #3180

Merged
merged 4 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pkg/minikube/bootstrapper/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,17 @@ func (k *KubeadmBootstrapper) StartCluster(k8s config.KubernetesConfig) error {
KubeadmConfigFile string
SkipPreflightChecks bool
Preflights []string
DNSAddon string
tstromberg marked this conversation as resolved.
Show resolved Hide resolved
}{
KubeadmConfigFile: constants.KubeadmConfigFile,
SkipPreflightChecks: !VersionIsBetween(version,
semver.MustParse("1.9.0-alpha.0"),
semver.Version{}),
Preflights: constants.Preflights,
DNSAddon: "kube-dns",
}
if version.GTE(semver.MustParse("1.12.0")) {
templateContext.DNSAddon = "coredns"
}
if err := kubeadmInitTemplate.Execute(&b, templateContext); err != nil {
return err
Expand Down Expand Up @@ -380,14 +385,18 @@ func generateConfig(k8s config.KubernetesConfig) (string, error) {
NodeName: k8s.NodeName,
ExtraArgs: extraComponentConfig,
FeatureArgs: kubeadmFeatureArgs,
NoTaintMaster: false,
NoTaintMaster: false, // That does not work with k8s 1.12+
}

if version.GTE(semver.MustParse("1.10.0-alpha.0")) {
opts.NoTaintMaster = true
}

b := bytes.Buffer{}
kubeadmConfigTemplate := kubeadmConfigTemplateV1Alpha1
if version.GTE(semver.MustParse("1.12.0")) {
kubeadmConfigTemplate = kubeadmConfigTemplateV1Alpha3
}
if err := kubeadmConfigTemplate.Execute(&b, opts); err != nil {
return "", err
}
Expand Down
43 changes: 41 additions & 2 deletions pkg/minikube/bootstrapper/kubeadm/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"text/template"
)

var kubeadmConfigTemplate = template.Must(template.New("kubeadmConfigTemplate").Funcs(template.FuncMap{
var kubeadmConfigTemplateV1Alpha1 = template.Must(template.New("kubeadmConfigTemplate-v1alpha1").Funcs(template.FuncMap{
"printMapInOrder": printMapInOrder,
}).Parse(`apiVersion: kubeadm.k8s.io/v1alpha1
kind: MasterConfiguration
Expand All @@ -44,6 +44,45 @@ nodeName: {{.NodeName}}
{{$i}}: {{$val}}{{end}}
{{end}}`))

var kubeadmConfigTemplateV1Alpha3 = template.Must(template.New("kubeadmConfigTemplate-v1alpha3").Funcs(template.FuncMap{
"printMapInOrder": printMapInOrder,
}).Parse(`apiEndpoint:
advertiseAddress: {{.AdvertiseAddress}}
bindPort: {{.APIServerPort}}
apiVersion: kubeadm.k8s.io/v1alpha3
bootstrapTokens:
- groups:
- system:bootstrappers:kubeadm:default-node-token
token: 599s02.8i3w2yyyay8t0onm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How was this value arrived at?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used kubeadm config upgrade, cleared all the default values, just by accident left this one. I will remove it.

ttl: 24h0m0s
usages:
- signing
- authentication
kind: InitConfiguration
nodeRegistration:
criSocket: /var/run/dockershim.sock
name: {{.NodeName}}
taints: []
---
{{range .ExtraArgs}}{{.Component}}:{{range $i, $val := printMapInOrder .Options ": " }}
{{$val}}{{end}}
{{end}}{{if .FeatureArgs}}featureGates: {{range $i, $val := .FeatureArgs}}
{{$i}}: {{$val}}{{end}}
{{end}}
apiVersion: kubeadm.k8s.io/v1alpha3
certificatesDir: {{.CertDir}}
clusterName: kubernetes
controlPlaneEndpoint: localhost:{{.APIServerPort}}
etcd:
local:
dataDir: {{.EtcdDataDir}}
kind: ClusterConfiguration
kubernetesVersion: {{.KubernetesVersion}}
networking:
dnsDomain: cluster.local
podSubnet: ""
serviceSubnet: {{.ServiceCIDR}}`))

var kubeletSystemdTemplate = template.Must(template.New("kubeletSystemdTemplate").Parse(`
[Unit]
{{if or (eq .ContainerRuntime "cri-o") (eq .ContainerRuntime "cri")}}Wants=crio.service{{else}}Wants=docker.socket{{end}}
Expand Down Expand Up @@ -79,7 +118,7 @@ sudo /usr/bin/kubeadm alpha phase etcd local --config {{.KubeadmConfigFile}}

var kubeadmInitTemplate = template.Must(template.New("kubeadmInitTemplate").Parse(`
sudo /usr/bin/kubeadm init --config {{.KubeadmConfigFile}} {{if .SkipPreflightChecks}}--skip-preflight-checks{{else}}{{range .Preflights}}--ignore-preflight-errors={{.}} {{end}}{{end}} &&
sudo /usr/bin/kubeadm alpha phase addon kube-dns
sudo /usr/bin/kubeadm alpha phase addon {{ .DNSAddon }}
`))

// printMapInOrder sorts the keys and prints the map in order, combining key
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 @@ -241,7 +241,6 @@ var versionSpecificOpts = []VersionedExtraOption{
NewUnversionedOption(Kubelet, "client-ca-file", path.Join(util.DefaultCertPath, "ca.crt")),

// Cgroup args
NewUnversionedOption(Kubelet, "cadvisor-port", "0"),
NewUnversionedOption(Kubelet, "cgroup-driver", "cgroupfs"),
{
Option: util.ExtraOption{
Expand All @@ -260,6 +259,14 @@ var versionSpecificOpts = []VersionedExtraOption{
},
GreaterThanOrEqual: semver.MustParse("1.11.0-alpha.0"),
},
{
Option: util.ExtraOption{
tstromberg marked this conversation as resolved.
Show resolved Hide resolved
Component: Kubelet,
Key: "cadvisor-port",
Value: "0",
},
LessThanOrEqual: semver.MustParse("1.11.1000"),
},
}

func VersionIsBetween(version, gte, lte semver.Version) bool {
Expand Down