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

Update NewestKubernetesVersion to 1.18.0-beta.2 #6988

Merged
merged 3 commits into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ func validateDriver(ds registry.DriverState, existing *config.ClusterConfig) {
exit.WithCodeT(exit.Config, "Exiting.")
}

func selectImageRepository(mirrorCountry string) (bool, string, error) {
func selectImageRepository(mirrorCountry string, v semver.Version) (bool, string, error) {
var tryCountries []string
var fallback string
glog.Infof("selecting image repository for country %s ...", mirrorCountry)
Expand Down Expand Up @@ -577,7 +577,7 @@ func selectImageRepository(mirrorCountry string) (bool, string, error) {
}

checkRepository := func(repo string) error {
pauseImage := images.Pause(repo)
pauseImage := images.Pause(v, repo)
ref, err := name.ParseReference(pauseImage, name.WeakValidation)
if err != nil {
return err
Expand Down Expand Up @@ -796,7 +796,7 @@ func generateCfgFromFlags(cmd *cobra.Command, k8sVersion string, drvName string)
repository := viper.GetString(imageRepository)
mirrorCountry := strings.ToLower(viper.GetString(imageMirrorCountry))
if strings.ToLower(repository) == "auto" || mirrorCountry != "" {
found, autoSelectedRepository, err := selectImageRepository(mirrorCountry)
found, autoSelectedRepository, err := selectImageRepository(mirrorCountry, semver.MustParse(k8sVersion))
if err != nil {
exit.WithError("Failed to check main repository and mirrors for images for images", err)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/minikube/bootstrapper/bsutil/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/cruntime"
"k8s.io/minikube/pkg/minikube/vmpath"
"k8s.io/minikube/pkg/util"
)

// Container runtimes
Expand All @@ -38,7 +39,7 @@ const remoteContainerRuntime = "remote"
// GenerateKubeadmYAML generates the kubeadm.yaml file
func GenerateKubeadmYAML(mc config.ClusterConfig, r cruntime.Manager, n config.Node) ([]byte, error) {
k8s := mc.KubernetesConfig
version, err := ParseKubernetesVersion(k8s.KubernetesVersion)
version, err := util.ParseKubernetesVersion(k8s.KubernetesVersion)
if err != nil {
return nil, errors.Wrap(err, "parsing kubernetes version")
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/minikube/bootstrapper/bsutil/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ import (
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/cruntime"
"k8s.io/minikube/pkg/util"
)

func extraKubeletOpts(mc config.ClusterConfig, nc config.Node, r cruntime.Manager) (map[string]string, error) {
k8s := mc.KubernetesConfig
version, err := ParseKubernetesVersion(k8s.KubernetesVersion)
version, err := util.ParseKubernetesVersion(k8s.KubernetesVersion)
if err != nil {
return nil, errors.Wrap(err, "parsing kubernetes version")
}
Expand Down Expand Up @@ -62,7 +63,7 @@ func extraKubeletOpts(mc config.ClusterConfig, nc config.Node, r cruntime.Manage
extraOpts["hostname-override"] = nc.Name
}

pauseImage := images.Pause(k8s.ImageRepository)
pauseImage := images.Pause(version, k8s.ImageRepository)
if _, ok := extraOpts["pod-infra-container-image"]; !ok && k8s.ImageRepository != "" && pauseImage != "" && k8s.ContainerRuntime != remoteContainerRuntime {
extraOpts["pod-infra-container-image"] = pauseImage
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/bootstrapper/bsutil/kubelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Wants=crio.service

[Service]
ExecStart=
ExecStart=/var/lib/minikube/binaries/v1.17.3/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-domain=cluster.local --config=/var/lib/kubelet/config.yaml --container-runtime=remote --container-runtime-endpoint=/var/run/crio/crio.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=/var/run/crio/crio.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m
ExecStart=/var/lib/minikube/binaries/v1.18.0-beta.2/kubelet --authorization-mode=Webhook --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --cgroup-driver=cgroupfs --client-ca-file=/var/lib/minikube/certs/ca.crt --cluster-domain=cluster.local --config=/var/lib/kubelet/config.yaml --container-runtime=remote --container-runtime-endpoint=/var/run/crio/crio.sock --fail-swap-on=false --hostname-override=minikube --image-service-endpoint=/var/run/crio/crio.sock --kubeconfig=/etc/kubernetes/kubelet.conf --node-ip=192.168.1.100 --pod-manifest-path=/etc/kubernetes/manifests --runtime-request-timeout=15m

[Install]
`,
Expand Down
12 changes: 0 additions & 12 deletions pkg/minikube/bootstrapper/bsutil/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,11 @@ import (
"strings"

"github.com/blang/semver"
"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/vmpath"
"k8s.io/minikube/pkg/util"
)

// ParseKubernetesVersion parses the kubernetes version
func ParseKubernetesVersion(version string) (semver.Version, error) {
// Strip leading 'v' prefix from version for semver parsing
v, err := semver.Make(version[1:])
if err != nil {
return semver.Version{}, errors.Wrap(err, "invalid version, must begin with 'v'")
}

return v, nil
}

// versionIsBetween checks if a version is between (or including) two given versions
func versionIsBetween(version, gte, lte semver.Version) bool {
if gte.NE(semver.Version{}) && !version.GTE(gte) {
Expand Down
10 changes: 0 additions & 10 deletions pkg/minikube/bootstrapper/bsutil/versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,3 @@ func TestVersionIsBetween(t *testing.T) {
})
}
}

func TestParseKubernetesVersion(t *testing.T) {
version, err := ParseKubernetesVersion("v1.8.0-alpha.5")
if err != nil {
t.Fatalf("Error parsing version: %v", err)
}
if version.NE(semver.MustParse("1.8.0-alpha.5")) {
t.Errorf("Expected: %s, Actual:%s", "1.8.0-alpha.5", version)
}
}
16 changes: 11 additions & 5 deletions pkg/minikube/bootstrapper/images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ import (
"github.com/blang/semver"
)

// Pause returns the image name to pull for the pause image
func Pause(mirror string) string {
// Pause returns the image name to pull for a given Kubernetes version
func Pause(v semver.Version, mirror string) string {
// Should match `PauseVersion` in:
// https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants.go
return path.Join(kubernetesRepo(mirror), "pause"+archTag(false)+"3.1")
pv := "3.2"
if semver.MustParseRange("<1.18.0-alpha.0")(v) {
pv = "3.1"
}
return path.Join(kubernetesRepo(mirror), "pause"+archTag(false)+pv)
}

// essentials returns images needed too bootstrap a kubenretes
Expand All @@ -41,7 +45,7 @@ func essentials(mirror string, v semver.Version) []string {
componentImage("kube-apiserver", v, mirror),
coreDNS(v, mirror),
etcd(v, mirror),
Pause(mirror),
Pause(v, mirror),
}
return imgs
}
Expand All @@ -61,8 +65,10 @@ func componentImage(name string, v semver.Version, mirror string) string {
func coreDNS(v semver.Version, mirror string) string {
// Should match `CoreDNSVersion` in
// https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants.go
cv := "1.6.5"
cv := "1.6.7"
switch v.Minor {
case 17:
cv = "1.6.5"
case 16:
cv = "1.6.2"
case 15, 14:
Expand Down
7 changes: 4 additions & 3 deletions pkg/minikube/bootstrapper/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import (
"k8s.io/minikube/pkg/minikube/machine"
"k8s.io/minikube/pkg/minikube/out"
"k8s.io/minikube/pkg/minikube/vmpath"
"k8s.io/minikube/pkg/util"
"k8s.io/minikube/pkg/version"
)

Expand Down Expand Up @@ -164,7 +165,7 @@ func (k *Bootstrapper) StartCluster(cfg config.ClusterConfig) error {
glog.Infof("StartCluster complete in %s", time.Since(start))
}()

version, err := bsutil.ParseKubernetesVersion(cfg.KubernetesConfig.KubernetesVersion)
version, err := util.ParseKubernetesVersion(cfg.KubernetesConfig.KubernetesVersion)
if err != nil {
return errors.Wrap(err, "parsing kubernetes version")
}
Expand Down Expand Up @@ -293,7 +294,7 @@ func (k *Bootstrapper) restartCluster(cfg config.ClusterConfig) error {
glog.Infof("restartCluster took %s", time.Since(start))
}()

version, err := bsutil.ParseKubernetesVersion(cfg.KubernetesConfig.KubernetesVersion)
version, err := util.ParseKubernetesVersion(cfg.KubernetesConfig.KubernetesVersion)
if err != nil {
return errors.Wrap(err, "parsing kubernetes version")
}
Expand Down Expand Up @@ -363,7 +364,7 @@ func (k *Bootstrapper) restartCluster(cfg config.ClusterConfig) error {

// DeleteCluster removes the components that were started earlier
func (k *Bootstrapper) DeleteCluster(k8s config.KubernetesConfig) error {
version, err := bsutil.ParseKubernetesVersion(k8s.KubernetesVersion)
version, err := util.ParseKubernetesVersion(k8s.KubernetesVersion)
if err != nil {
return errors.Wrap(err, "parsing kubernetes version")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
// DefaultKubernetesVersion is the default kubernetes version
DefaultKubernetesVersion = "v1.17.3"
// NewestKubernetesVersion is the newest Kubernetes version to test against
NewestKubernetesVersion = "v1.17.3"
NewestKubernetesVersion = "v1.18.0-beta.2"
// OldestKubernetesVersion is the oldest Kubernetes version to test against
OldestKubernetesVersion = "v1.11.10"
// DefaultClusterName is the default nane for the k8s cluster
Expand Down
9 changes: 5 additions & 4 deletions pkg/minikube/cruntime/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"strings"
"text/template"

"github.com/blang/semver"
"github.com/golang/glog"
"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
Expand Down Expand Up @@ -112,7 +113,7 @@ type Containerd struct {
Socket string
Runner CommandRunner
ImageRepository string
KubernetesVersion string
KubernetesVersion semver.Version
}

// Name is a human readable name for containerd
Expand Down Expand Up @@ -170,13 +171,13 @@ func (r *Containerd) Available() error {
}

// generateContainerdConfig sets up /etc/containerd/config.toml
func generateContainerdConfig(cr CommandRunner, imageRepository string) error {
func generateContainerdConfig(cr CommandRunner, imageRepository string, kv semver.Version) error {
cPath := containerdConfigFile
t, err := template.New("containerd.config.toml").Parse(containerdConfigTemplate)
if err != nil {
return err
}
pauseImage := images.Pause(imageRepository)
pauseImage := images.Pause(kv, imageRepository)
opts := struct{ PodInfraContainerImage string }{PodInfraContainerImage: pauseImage}
var b bytes.Buffer
if err := t.Execute(&b, opts); err != nil {
Expand All @@ -199,7 +200,7 @@ func (r *Containerd) Enable(disOthers bool) error {
if err := populateCRIConfig(r.Runner, r.SocketPath()); err != nil {
return err
}
if err := generateContainerdConfig(r.Runner, r.ImageRepository); err != nil {
if err := generateContainerdConfig(r.Runner, r.ImageRepository, r.KubernetesVersion); err != nil {
return err
}
if err := enableIPForwarding(r.Runner); err != nil {
Expand Down
9 changes: 5 additions & 4 deletions pkg/minikube/cruntime/crio.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os/exec"
"strings"

"github.com/blang/semver"
"github.com/golang/glog"
"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
Expand All @@ -37,13 +38,13 @@ type CRIO struct {
Socket string
Runner CommandRunner
ImageRepository string
KubernetesVersion string
KubernetesVersion semver.Version
}

// generateCRIOConfig sets up /etc/crio/crio.conf
func generateCRIOConfig(cr CommandRunner, imageRepository string) error {
func generateCRIOConfig(cr CommandRunner, imageRepository string, kv semver.Version) error {
cPath := crioConfigFile
pauseImage := images.Pause(imageRepository)
pauseImage := images.Pause(kv, imageRepository)

c := exec.Command("/bin/bash", "-c", fmt.Sprintf("sudo sed -e 's|^pause_image = .*$|pause_image = \"%s\"|' -i %s", pauseImage, cPath))
if _, err := cr.RunCmd(c); err != nil {
Expand Down Expand Up @@ -116,7 +117,7 @@ func (r *CRIO) Enable(disOthers bool) error {
if err := populateCRIConfig(r.Runner, r.SocketPath()); err != nil {
return err
}
if err := generateCRIOConfig(r.Runner, r.ImageRepository); err != nil {
if err := generateCRIOConfig(r.Runner, r.ImageRepository, r.KubernetesVersion); err != nil {
return err
}
if err := enableIPForwarding(r.Runner); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/minikube/cruntime/cruntime.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"os/exec"

"github.com/blang/semver"
"github.com/golang/glog"
"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/assets"
Expand Down Expand Up @@ -114,7 +115,7 @@ type Config struct {
// ImageRepository image repository to download image from
ImageRepository string
// KubernetesVersion Kubernetes version
KubernetesVersion string
KubernetesVersion semver.Version
}

// ListOptions are the options to use for listing containers
Expand Down
1 change: 1 addition & 0 deletions pkg/minikube/machine/cache_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func LoadImages(cc *config.ClusterConfig, runner command.Runner, images []string
}()

var g errgroup.Group

cr, err := cruntime.New(cruntime.Config{Type: cc.KubernetesConfig.ContainerRuntime, Runner: runner})
if err != nil {
return errors.Wrap(err, "runtime")
Expand Down
11 changes: 8 additions & 3 deletions pkg/minikube/node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"strconv"
"strings"

"github.com/blang/semver"
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/host"
"github.com/golang/glog"
Expand Down Expand Up @@ -55,9 +56,13 @@ var (
)

// configureRuntimes does what needs to happen to get a runtime going.
func configureRuntimes(runner cruntime.CommandRunner, drvName string, k8s config.KubernetesConfig) cruntime.Manager {
config := cruntime.Config{Type: viper.GetString(containerRuntime), Runner: runner, ImageRepository: k8s.ImageRepository, KubernetesVersion: k8s.KubernetesVersion}
cr, err := cruntime.New(config)
func configureRuntimes(runner cruntime.CommandRunner, drvName string, k8s config.KubernetesConfig, kv semver.Version) cruntime.Manager {
co := cruntime.Config{
Type: viper.GetString(containerRuntime),
Runner: runner, ImageRepository: k8s.ImageRepository,
KubernetesVersion: kv,
}
cr, err := cruntime.New(co)
if err != nil {
exit.WithError("Failed runtime", err)
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ func Start(mc config.ClusterConfig, n config.Node, primary bool, existingAddons
// wait for preloaded tarball to finish downloading before configuring runtimes
waitCacheRequiredImages(&cacheGroup)

sv, err := util.ParseKubernetesVersion(mc.KubernetesConfig.KubernetesVersion)
if err != nil {
return nil, err
}

// configure the runtime (docker, containerd, crio)
cr := configureRuntimes(mRunner, driverName, mc.KubernetesConfig)
cr := configureRuntimes(mRunner, driverName, mc.KubernetesConfig, sv)
showVersionInfo(k8sVersion, cr)

//TODO(sharifelgamal): Part out the cluster-wide operations, perhaps using the "primary" param
Expand Down
8 changes: 7 additions & 1 deletion pkg/util/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import (
"path/filepath"
"strconv"

units "github.com/docker/go-units"
"github.com/blang/semver"
"github.com/docker/go-units"
"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/out"
Expand Down Expand Up @@ -89,3 +90,8 @@ func MaybeChownDirRecursiveToMinikubeUser(dir string) error {
}
return nil
}

// ParseKubernetesVersion parses the kubernetes version
func ParseKubernetesVersion(version string) (semver.Version, error) {
return semver.Make(version[1:])
}
12 changes: 12 additions & 0 deletions pkg/util/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package util

import (
"testing"

"github.com/blang/semver"
)

func TestGetBinaryDownloadURL(t *testing.T) {
Expand Down Expand Up @@ -58,3 +60,13 @@ func TestCalculateSizeInMB(t *testing.T) {
}
}
}

func TestParseKubernetesVersion(t *testing.T) {
version, err := ParseKubernetesVersion("v1.8.0-alpha.5")
if err != nil {
t.Fatalf("Error parsing version: %v", err)
}
if version.NE(semver.MustParse("1.8.0-alpha.5")) {
t.Errorf("Expected: %s, Actual:%s", "1.8.0-alpha.5", version)
}
}