Skip to content

Commit 7a9be3f

Browse files
committed
KCP: use new registry with Kubernetes >= v1.22
Signed-off-by: Stefan Büringer [email protected]
1 parent bb0ac56 commit 7a9be3f

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

controlplane/kubeadm/internal/workload_cluster.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var (
8787

8888
// minKubernetesVersionImageRegistryMigration is first kubernetes version where
8989
// the default image registry is registry.k8s.io instead of k8s.gcr.io.
90-
minKubernetesVersionImageRegistryMigration = semver.MustParse("1.25.0")
90+
minKubernetesVersionImageRegistryMigration = semver.MustParse("1.22.0")
9191

9292
// nextKubernetesVersionImageRegistryMigration is the next minor version after
9393
// the default image registry changed to registry.k8s.io.
@@ -624,10 +624,10 @@ func yamlToUnstructured(rawYAML []byte) (*unstructured.Unstructured, error) {
624624

625625
// ImageRepositoryFromClusterConfig returns the image repository to use. It returns:
626626
// * clusterConfig.ImageRepository if set.
627-
// * "registry.k8s.io" if v1.25 <= version < v1.26 to migrate to the new registry
627+
// * "registry.k8s.io" if v1.22 <= version < v1.26 to migrate to the new registry
628628
// * "" otherwise.
629-
// Beginning with kubernetes v1.25, the default registry for kubernetes is registry.k8s.io
630-
// instead of k8s.gcr.io which is why references should get migrated when upgrading to v1.25.
629+
// Beginning with kubernetes v1.22, the default registry for kubernetes is registry.k8s.io
630+
// instead of k8s.gcr.io which is why references should get migrated when upgrading to v1.22.
631631
// The migration follows the behavior of `kubeadm upgrade`.
632632
func ImageRepositoryFromClusterConfig(clusterConfig *bootstrapv1.ClusterConfiguration, kubernetesVersion semver.Version) string {
633633
// If ImageRepository is explicitly specified, return early.
@@ -636,7 +636,7 @@ func ImageRepositoryFromClusterConfig(clusterConfig *bootstrapv1.ClusterConfigur
636636
return clusterConfig.ImageRepository
637637
}
638638

639-
// If v1.25 <= version < v1.26 return the default Kubernetes image repository to
639+
// If v1.22 <= version < v1.26 return the default Kubernetes image repository to
640640
// migrate to the new location and not cause changes else.
641641
if kubernetesVersion.GTE(minKubernetesVersionImageRegistryMigration) &&
642642
kubernetesVersion.LT(nextKubernetesVersionImageRegistryMigration) {

controlplane/kubeadm/internal/workload_cluster_coredns_test.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ func TestGetCoreDNSInfo(t *testing.T) {
12131213
},
12141214
},
12151215
{
1216-
name: "rename to coredns/coredns when upgrading to coredns=1.8.0 and kubernetesVersion=1.24.0",
1216+
name: "rename to coredns/coredns when upgrading to coredns=1.8.0 and kubernetesVersion=1.21.0",
12171217
objs: []client.Object{newCoreDNSInfoDeploymentWithimage(image162), cm},
12181218
clusterConfig: &bootstrapv1.ClusterConfiguration{
12191219
DNS: bootstrapv1.DNS{
@@ -1222,7 +1222,7 @@ func TestGetCoreDNSInfo(t *testing.T) {
12221222
},
12231223
},
12241224
},
1225-
kubernetesVersion: semver.MustParse("1.24.0"),
1225+
kubernetesVersion: semver.MustParse("1.21.0"),
12261226
expectedInfo: coreDNSInfo{
12271227
CurrentMajorMinorPatch: "1.6.2",
12281228
FromImageTag: "1.6.2",
@@ -1252,6 +1252,26 @@ func TestGetCoreDNSInfo(t *testing.T) {
12521252
ToImageTag: "1.8.0",
12531253
},
12541254
},
1255+
{
1256+
name: "patches ImageRepository to registry.k8s.io if it's set on neither global nor DNS-level and kubernetesVersion >= v1.22 and rename to coredns/coredns",
1257+
objs: []client.Object{newCoreDNSInfoDeploymentWithimage(image162), cm},
1258+
clusterConfig: &bootstrapv1.ClusterConfiguration{
1259+
DNS: bootstrapv1.DNS{
1260+
ImageMeta: bootstrapv1.ImageMeta{
1261+
ImageTag: "1.8.0",
1262+
},
1263+
},
1264+
},
1265+
kubernetesVersion: semver.MustParse("1.22.0"),
1266+
expectedInfo: coreDNSInfo{
1267+
CurrentMajorMinorPatch: "1.6.2",
1268+
FromImageTag: "1.6.2",
1269+
TargetMajorMinorPatch: "1.8.0",
1270+
FromImage: image162,
1271+
ToImage: "registry.k8s.io/coredns/coredns:1.8.0",
1272+
ToImageTag: "1.8.0",
1273+
},
1274+
},
12551275
{
12561276
name: "patches ImageRepository to registry.k8s.io if it's set on neither global nor DNS-level and kubernetesVersion >= v1.25 and rename to coredns/coredns",
12571277
objs: []client.Object{newCoreDNSInfoDeploymentWithimage(image162), cm},

test/framework/daemonset_helpers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ func WaitForKubeProxyUpgrade(ctx context.Context, input WaitForKubeProxyUpgradeI
4242
parsedVersion, err := semver.ParseTolerant(input.KubernetesVersion)
4343
Expect(err).ToNot(HaveOccurred())
4444

45-
// Beginning with kubernetes v1.25, kubernetes images including kube-proxy get published to registry.k8s.io instead of k8s.gcr.io.
46-
// This ensures that the imageRepository setting gets patched to registry.k8s.io when upgrading from v1.24 or lower,
47-
// but only if there was no imageRespository explicitly set at the KubeadmControlPlanes ClusterConfiguration.
45+
// Beginning with kubernetes v1.22, kubernetes images including kube-proxy get published to registry.k8s.io.
46+
// This ensures that the imageRepository setting gets patched to registry.k8s.io when upgrading from v1.21 or lower,
47+
// but only if there was no imageRepository explicitly set at the KubeadmControlPlanes ClusterConfiguration.
4848
// This follows the behavior of `kubeadm upgrade`.
4949
wantKubeProxyRegistry := "registry.k8s.io"
50-
if parsedVersion.LT(semver.Version{Major: 1, Minor: 25, Patch: 0, Pre: []semver.PRVersion{{VersionStr: "alpha"}}}) {
50+
if parsedVersion.LT(semver.Version{Major: 1, Minor: 22, Patch: 0, Pre: []semver.PRVersion{{VersionStr: "alpha"}}}) {
5151
wantKubeProxyRegistry = "k8s.gcr.io"
5252
}
5353
wantKubeProxyImage := wantKubeProxyRegistry + "/kube-proxy:" + containerutil.SemverToOCIImageTag(input.KubernetesVersion)

0 commit comments

Comments
 (0)