The DefaultKubernetesRepo changed for 1.25.0
Moving the old images for the old releases would mean having to redo old preloads and old caches, as well...pull/14768/head
parent
3d3214275a
commit
6f7c585ad7
|
@ -51,10 +51,10 @@ func Pause(v semver.Version, mirror string) string {
|
||||||
if pVersion, ok := constants.KubeadmImages[majorMinorVersion][imageName]; ok {
|
if pVersion, ok := constants.KubeadmImages[majorMinorVersion][imageName]; ok {
|
||||||
pv = pVersion
|
pv = pVersion
|
||||||
} else {
|
} else {
|
||||||
pv = findLatestTagFromRepository(fmt.Sprintf(tagURLTemplate, kubernetesRepo(mirror), imageName), pv)
|
pv = findLatestTagFromRepository(fmt.Sprintf(tagURLTemplate, kubernetesRepo(mirror, v), imageName), pv)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%s:%s", path.Join(kubernetesRepo(mirror), imageName), pv)
|
return fmt.Sprintf("%s:%s", path.Join(kubernetesRepo(mirror, v), imageName), pv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// essentials returns images needed too bootstrap a Kubernetes
|
// essentials returns images needed too bootstrap a Kubernetes
|
||||||
|
@ -74,7 +74,7 @@ func essentials(mirror string, v semver.Version) []string {
|
||||||
|
|
||||||
// componentImage returns a Kubernetes component image to pull
|
// componentImage returns a Kubernetes component image to pull
|
||||||
func componentImage(name string, v semver.Version, mirror string) string {
|
func componentImage(name string, v semver.Version, mirror string) string {
|
||||||
return fmt.Sprintf("%s:v%s", path.Join(kubernetesRepo(mirror), name), v)
|
return fmt.Sprintf("%s:v%s", path.Join(kubernetesRepo(mirror, v), name), v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fixes 13136 by getting the latest image version from the k8s.gcr.io repository instead of hardcoded
|
// fixes 13136 by getting the latest image version from the k8s.gcr.io repository instead of hardcoded
|
||||||
|
@ -127,14 +127,14 @@ func coreDNS(v semver.Version, mirror string) string {
|
||||||
if cVersion, ok := constants.KubeadmImages[majorMinorVersion][imageName]; ok {
|
if cVersion, ok := constants.KubeadmImages[majorMinorVersion][imageName]; ok {
|
||||||
cv = cVersion
|
cv = cVersion
|
||||||
} else {
|
} else {
|
||||||
cv = findLatestTagFromRepository(fmt.Sprintf(tagURLTemplate, kubernetesRepo(mirror), imageName), cv)
|
cv = findLatestTagFromRepository(fmt.Sprintf(tagURLTemplate, kubernetesRepo(mirror, v), imageName), cv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if mirror == constants.AliyunMirror {
|
if mirror == constants.AliyunMirror {
|
||||||
imageName = "coredns"
|
imageName = "coredns"
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%s:%s", path.Join(kubernetesRepo(mirror), imageName), cv)
|
return fmt.Sprintf("%s:%s", path.Join(kubernetesRepo(mirror, v), imageName), cv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// etcd returns the image used for etcd
|
// etcd returns the image used for etcd
|
||||||
|
@ -148,10 +148,10 @@ func etcd(v semver.Version, mirror string) string {
|
||||||
if eVersion, ok := constants.KubeadmImages[majorMinorVersion][imageName]; ok {
|
if eVersion, ok := constants.KubeadmImages[majorMinorVersion][imageName]; ok {
|
||||||
ev = eVersion
|
ev = eVersion
|
||||||
} else {
|
} else {
|
||||||
ev = findLatestTagFromRepository(fmt.Sprintf(tagURLTemplate, kubernetesRepo(mirror), imageName), ev)
|
ev = findLatestTagFromRepository(fmt.Sprintf(tagURLTemplate, kubernetesRepo(mirror, v), imageName), ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%s:%s", path.Join(kubernetesRepo(mirror), imageName), ev)
|
return fmt.Sprintf("%s:%s", path.Join(kubernetesRepo(mirror, v), imageName), ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
// auxiliary returns images that are helpful for running minikube
|
// auxiliary returns images that are helpful for running minikube
|
||||||
|
|
|
@ -34,6 +34,26 @@ func TestKubeadmImages(t *testing.T) {
|
||||||
{"invalid", "", true, nil},
|
{"invalid", "", true, nil},
|
||||||
{"v0.0.1", "", true, nil}, // too old
|
{"v0.0.1", "", true, nil}, // too old
|
||||||
{"v2.0.0", "", true, nil}, // too new
|
{"v2.0.0", "", true, nil}, // too new
|
||||||
|
{"v1.25.0", "", false, []string{
|
||||||
|
"registry.k8s.io/kube-apiserver:v1.25.0",
|
||||||
|
"registry.k8s.io/kube-controller-manager:v1.25.0",
|
||||||
|
"registry.k8s.io/kube-scheduler:v1.25.0",
|
||||||
|
"registry.k8s.io/kube-proxy:v1.25.0",
|
||||||
|
"registry.k8s.io/coredns/coredns:v1.9.3",
|
||||||
|
"registry.k8s.io/etcd:3.5.4-0",
|
||||||
|
"registry.k8s.io/pause:3.8",
|
||||||
|
"gcr.io/k8s-minikube/storage-provisioner:" + version.GetStorageProvisionerVersion(),
|
||||||
|
}},
|
||||||
|
{"v1.24.0", "", false, []string{
|
||||||
|
"k8s.gcr.io/kube-apiserver:v1.24.0",
|
||||||
|
"k8s.gcr.io/kube-controller-manager:v1.24.0",
|
||||||
|
"k8s.gcr.io/kube-scheduler:v1.24.0",
|
||||||
|
"k8s.gcr.io/kube-proxy:v1.24.0",
|
||||||
|
"k8s.gcr.io/coredns/coredns:v1.8.6",
|
||||||
|
"k8s.gcr.io/etcd:3.5.3-0",
|
||||||
|
"k8s.gcr.io/pause:3.7",
|
||||||
|
"gcr.io/k8s-minikube/storage-provisioner:" + version.GetStorageProvisionerVersion(),
|
||||||
|
}},
|
||||||
{"v1.17.0", "", false, []string{
|
{"v1.17.0", "", false, []string{
|
||||||
"k8s.gcr.io/kube-proxy:v1.17.0",
|
"k8s.gcr.io/kube-proxy:v1.17.0",
|
||||||
"k8s.gcr.io/kube-scheduler:v1.17.0",
|
"k8s.gcr.io/kube-scheduler:v1.17.0",
|
||||||
|
|
|
@ -16,13 +16,28 @@ limitations under the License.
|
||||||
|
|
||||||
package images
|
package images
|
||||||
|
|
||||||
// DefaultKubernetesRepo is the default Kubernetes repository
|
import (
|
||||||
const DefaultKubernetesRepo = "k8s.gcr.io"
|
"github.com/blang/semver/v4"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OldDefaultKubernetesRepo is the old default Kubernetes repository
|
||||||
|
const OldDefaultKubernetesRepo = "k8s.gcr.io"
|
||||||
|
|
||||||
|
// NewDefaultKubernetesRepo is the new default Kubernetes repository
|
||||||
|
const NewDefaultKubernetesRepo = "registry.k8s.io"
|
||||||
|
|
||||||
// kubernetesRepo returns the official Kubernetes repository, or an alternate
|
// kubernetesRepo returns the official Kubernetes repository, or an alternate
|
||||||
func kubernetesRepo(mirror string) string {
|
func kubernetesRepo(mirror string, v semver.Version) string {
|
||||||
if mirror != "" {
|
if mirror != "" {
|
||||||
return mirror
|
return mirror
|
||||||
}
|
}
|
||||||
return DefaultKubernetesRepo
|
return DefaultKubernetesRepo(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func DefaultKubernetesRepo(kv semver.Version) string {
|
||||||
|
// these (-1.24) should probably be moved too
|
||||||
|
if kv.LT(semver.MustParse("1.25.0-alpha.1")) {
|
||||||
|
return OldDefaultKubernetesRepo
|
||||||
|
}
|
||||||
|
return NewDefaultKubernetesRepo
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,25 +19,40 @@ package images
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/blang/semver/v4"
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_kubernetesRepo(t *testing.T) {
|
func Test_kubernetesRepo(t *testing.T) {
|
||||||
|
kv := semver.MustParse("1.23.0")
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
mirror string
|
mirror string
|
||||||
want string
|
version semver.Version
|
||||||
|
want string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"",
|
"",
|
||||||
DefaultKubernetesRepo,
|
kv,
|
||||||
|
DefaultKubernetesRepo(kv),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"mirror.k8s.io",
|
"mirror.k8s.io",
|
||||||
|
kv,
|
||||||
"mirror.k8s.io",
|
"mirror.k8s.io",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"",
|
||||||
|
semver.MustParse("1.24.0"),
|
||||||
|
OldDefaultKubernetesRepo,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"",
|
||||||
|
semver.MustParse("1.25.0"),
|
||||||
|
NewDefaultKubernetesRepo,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
got := kubernetesRepo(tc.mirror)
|
got := kubernetesRepo(tc.mirror, tc.version)
|
||||||
if !cmp.Equal(got, tc.want) {
|
if !cmp.Equal(got, tc.want) {
|
||||||
t.Errorf("mirror miss match, want: %s, got: %s", tc.want, got)
|
t.Errorf("mirror miss match, want: %s, got: %s", tc.want, got)
|
||||||
}
|
}
|
||||||
|
|
|
@ -556,7 +556,7 @@ func startMachine(cfg *config.ClusterConfig, node *config.Node, delOnFail bool)
|
||||||
return runner, preExists, m, host, errors.Wrap(err, "Failed to get command runner")
|
return runner, preExists, m, host, errors.Wrap(err, "Failed to get command runner")
|
||||||
}
|
}
|
||||||
|
|
||||||
ip, err := validateNetwork(host, runner, cfg.KubernetesConfig.ImageRepository)
|
ip, err := validateNetwork(host, runner, cfg.KubernetesConfig.ImageRepository, cfg.KubernetesConfig.KubernetesVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return runner, preExists, m, host, errors.Wrap(err, "Failed to validate network")
|
return runner, preExists, m, host, errors.Wrap(err, "Failed to validate network")
|
||||||
}
|
}
|
||||||
|
@ -639,7 +639,7 @@ func startHostInternal(api libmachine.API, cc *config.ClusterConfig, n *config.N
|
||||||
}
|
}
|
||||||
|
|
||||||
// validateNetwork tries to catch network problems as soon as possible
|
// validateNetwork tries to catch network problems as soon as possible
|
||||||
func validateNetwork(h *host.Host, r command.Runner, imageRepository string) (string, error) {
|
func validateNetwork(h *host.Host, r command.Runner, imageRepository string, kubernetesVersion string) (string, error) {
|
||||||
ip, err := h.Driver.GetIP()
|
ip, err := h.Driver.GetIP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ip, err
|
return ip, err
|
||||||
|
@ -671,7 +671,7 @@ func validateNetwork(h *host.Host, r command.Runner, imageRepository string) (st
|
||||||
}
|
}
|
||||||
|
|
||||||
// Non-blocking
|
// Non-blocking
|
||||||
go tryRegistry(r, h.Driver.DriverName(), imageRepository)
|
go tryRegistry(r, h.Driver.DriverName(), imageRepository, kubernetesVersion)
|
||||||
return ip, nil
|
return ip, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,7 +716,7 @@ func trySSH(h *host.Host, ip string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// tryRegistry tries to connect to the image repository
|
// tryRegistry tries to connect to the image repository
|
||||||
func tryRegistry(r command.Runner, driverName string, imageRepository string) {
|
func tryRegistry(r command.Runner, driverName string, imageRepository string, kubernetesVersion string) {
|
||||||
// 2 second timeout. For best results, call tryRegistry in a non-blocking manner.
|
// 2 second timeout. For best results, call tryRegistry in a non-blocking manner.
|
||||||
opts := []string{"-sS", "-m", "2"}
|
opts := []string{"-sS", "-m", "2"}
|
||||||
|
|
||||||
|
@ -726,7 +726,8 @@ func tryRegistry(r command.Runner, driverName string, imageRepository string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if imageRepository == "" {
|
if imageRepository == "" {
|
||||||
imageRepository = images.DefaultKubernetesRepo
|
v, _ := util.ParseKubernetesVersion(kubernetesVersion)
|
||||||
|
imageRepository = images.DefaultKubernetesRepo(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
opts = append(opts, fmt.Sprintf("https://%s/", imageRepository))
|
opts = append(opts, fmt.Sprintf("https://%s/", imageRepository))
|
||||||
|
|
Loading…
Reference in New Issue