Skip to content

Commit 505a08e

Browse files
authored
Merge pull request #6917 from chrischdi/pr-v1-25-fix-registry
🐛 kcp: patch ImageRepository in ClusterConfiguration if it is not set for v1.25
2 parents 1f1b09c + a959caf commit 505a08e

20 files changed

+316
-187
lines changed

bootstrap/kubeadm/api/v1alpha4/kubeadm_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ type ClusterConfiguration struct {
113113
CertificatesDir string `json:"certificatesDir,omitempty"`
114114

115115
// ImageRepository sets the container registry to pull images from.
116-
// If empty, `k8s.gcr.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/` or `ci-cross/`)
117-
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `k8s.gcr.io`
116+
// If empty, `registry.k8s.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/` or `ci-cross/`)
117+
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `registry.k8s.io`
118118
// will be used for all the other images.
119119
// +optional
120120
ImageRepository string `json:"imageRepository,omitempty"`

bootstrap/kubeadm/api/v1beta1/kubeadm_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ type ClusterConfiguration struct {
124124
CertificatesDir string `json:"certificatesDir,omitempty"`
125125

126126
// ImageRepository sets the container registry to pull images from.
127-
// If empty, `k8s.gcr.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/` or `ci-cross/`)
128-
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `k8s.gcr.io`
127+
// If empty, `registry.k8s.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/` or `ci-cross/`)
128+
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `registry.k8s.io`
129129
// will be used for all the other images.
130130
// +optional
131131
ImageRepository string `json:"imageRepository,omitempty"`

bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,12 +1256,12 @@ spec:
12561256
type: object
12571257
imageRepository:
12581258
description: ImageRepository sets the container registry to pull
1259-
images from. If empty, `k8s.gcr.io` will be used by default;
1259+
images from. If empty, `registry.k8s.io` will be used by default;
12601260
in case of kubernetes version is a CI build (kubernetes version
12611261
starts with `ci/` or `ci-cross/`) `gcr.io/k8s-staging-ci-images`
12621262
will be used as a default for control plane components and for
1263-
kube-proxy, while `k8s.gcr.io` will be used for all the other
1264-
images.
1263+
kube-proxy, while `registry.k8s.io` will be used for all the
1264+
other images.
12651265
type: string
12661266
kind:
12671267
description: 'Kind is a string value representing the REST resource
@@ -2244,12 +2244,12 @@ spec:
22442244
type: object
22452245
imageRepository:
22462246
description: ImageRepository sets the container registry to pull
2247-
images from. If empty, `k8s.gcr.io` will be used by default;
2247+
images from. If empty, `registry.k8s.io` will be used by default;
22482248
in case of kubernetes version is a CI build (kubernetes version
22492249
starts with `ci/` or `ci-cross/`) `gcr.io/k8s-staging-ci-images`
22502250
will be used as a default for control plane components and for
2251-
kube-proxy, while `k8s.gcr.io` will be used for all the other
2252-
images.
2251+
kube-proxy, while `registry.k8s.io` will be used for all the
2252+
other images.
22532253
type: string
22542254
kind:
22552255
description: 'Kind is a string value representing the REST resource

bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,12 +1265,13 @@ spec:
12651265
type: object
12661266
imageRepository:
12671267
description: ImageRepository sets the container registry
1268-
to pull images from. If empty, `k8s.gcr.io` will be
1269-
used by default; in case of kubernetes version is a
1270-
CI build (kubernetes version starts with `ci/` or `ci-cross/`)
1271-
`gcr.io/k8s-staging-ci-images` will be used as a default
1272-
for control plane components and for kube-proxy, while
1273-
`k8s.gcr.io` will be used for all the other images.
1268+
to pull images from. If empty, `registry.k8s.io` will
1269+
be used by default; in case of kubernetes version is
1270+
a CI build (kubernetes version starts with `ci/` or
1271+
`ci-cross/`) `gcr.io/k8s-staging-ci-images` will be
1272+
used as a default for control plane components and for
1273+
kube-proxy, while `registry.k8s.io` will be used for
1274+
all the other images.
12741275
type: string
12751276
kind:
12761277
description: 'Kind is a string value representing the
@@ -2246,12 +2247,13 @@ spec:
22462247
type: object
22472248
imageRepository:
22482249
description: ImageRepository sets the container registry
2249-
to pull images from. If empty, `k8s.gcr.io` will be
2250-
used by default; in case of kubernetes version is a
2251-
CI build (kubernetes version starts with `ci/` or `ci-cross/`)
2252-
`gcr.io/k8s-staging-ci-images` will be used as a default
2253-
for control plane components and for kube-proxy, while
2254-
`k8s.gcr.io` will be used for all the other images.
2250+
to pull images from. If empty, `registry.k8s.io` will
2251+
be used by default; in case of kubernetes version is
2252+
a CI build (kubernetes version starts with `ci/` or
2253+
`ci-cross/`) `gcr.io/k8s-staging-ci-images` will be
2254+
used as a default for control plane components and for
2255+
kube-proxy, while `registry.k8s.io` will be used for
2256+
all the other images.
22552257
type: string
22562258
kind:
22572259
description: 'Kind is a string value representing the

bootstrap/kubeadm/types/upstreamv1beta2/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ type ClusterConfiguration struct {
116116
CertificatesDir string `json:"certificatesDir,omitempty"`
117117

118118
// ImageRepository sets the container registry to pull images from.
119-
// If empty, `k8s.gcr.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/` or `ci-cross/`)
120-
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `k8s.gcr.io`
119+
// If empty, `registry.k8s.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/`)
120+
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `registry.k8s.io`
121121
// will be used for all the other images.
122122
// +optional
123123
ImageRepository string `json:"imageRepository,omitempty"`

bootstrap/kubeadm/types/upstreamv1beta3/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ type ClusterConfiguration struct {
120120
CertificatesDir string `json:"certificatesDir,omitempty"`
121121

122122
// ImageRepository sets the container registry to pull images from.
123-
// If empty, `k8s.gcr.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/` or `ci-cross/`)
124-
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `k8s.gcr.io`
123+
// If empty, `registry.k8s.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/` or `ci-cross/`)
124+
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `registry.k8s.io`
125125
// will be used for all the other images.
126126
// +optional
127127
ImageRepository string `json:"imageRepository,omitempty"`

controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,12 +1482,12 @@ spec:
14821482
type: object
14831483
imageRepository:
14841484
description: ImageRepository sets the container registry to
1485-
pull images from. If empty, `k8s.gcr.io` will be used by
1486-
default; in case of kubernetes version is a CI build (kubernetes
1487-
version starts with `ci/` or `ci-cross/`) `gcr.io/k8s-staging-ci-images`
1485+
pull images from. If empty, `registry.k8s.io` will be used
1486+
by default; in case of kubernetes version is a CI build
1487+
(kubernetes version starts with `ci/` or `ci-cross/`) `gcr.io/k8s-staging-ci-images`
14881488
will be used as a default for control plane components and
1489-
for kube-proxy, while `k8s.gcr.io` will be used for all
1490-
the other images.
1489+
for kube-proxy, while `registry.k8s.io` will be used for
1490+
all the other images.
14911491
type: string
14921492
kind:
14931493
description: 'Kind is a string value representing the REST
@@ -2702,12 +2702,12 @@ spec:
27022702
type: object
27032703
imageRepository:
27042704
description: ImageRepository sets the container registry to
2705-
pull images from. If empty, `k8s.gcr.io` will be used by
2706-
default; in case of kubernetes version is a CI build (kubernetes
2707-
version starts with `ci/` or `ci-cross/`) `gcr.io/k8s-staging-ci-images`
2705+
pull images from. If empty, `registry.k8s.io` will be used
2706+
by default; in case of kubernetes version is a CI build
2707+
(kubernetes version starts with `ci/` or `ci-cross/`) `gcr.io/k8s-staging-ci-images`
27082708
will be used as a default for control plane components and
2709-
for kube-proxy, while `k8s.gcr.io` will be used for all
2710-
the other images.
2709+
for kube-proxy, while `registry.k8s.io` will be used for
2710+
all the other images.
27112711
type: string
27122712
kind:
27132713
description: 'Kind is a string value representing the REST

controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,13 @@ spec:
304304
type: object
305305
imageRepository:
306306
description: ImageRepository sets the container registry
307-
to pull images from. If empty, `k8s.gcr.io` will
308-
be used by default; in case of kubernetes version
307+
to pull images from. If empty, `registry.k8s.io`
308+
will be used by default; in case of kubernetes version
309309
is a CI build (kubernetes version starts with `ci/`
310310
or `ci-cross/`) `gcr.io/k8s-staging-ci-images` will
311311
be used as a default for control plane components
312-
and for kube-proxy, while `k8s.gcr.io` will be used
313-
for all the other images.
312+
and for kube-proxy, while `registry.k8s.io` will
313+
be used for all the other images.
314314
type: string
315315
kind:
316316
description: 'Kind is a string value representing
@@ -1467,13 +1467,13 @@ spec:
14671467
type: object
14681468
imageRepository:
14691469
description: ImageRepository sets the container registry
1470-
to pull images from. If empty, `k8s.gcr.io` will
1471-
be used by default; in case of kubernetes version
1470+
to pull images from. If empty, `registry.k8s.io`
1471+
will be used by default; in case of kubernetes version
14721472
is a CI build (kubernetes version starts with `ci/`
14731473
or `ci-cross/`) `gcr.io/k8s-staging-ci-images` will
14741474
be used as a default for control plane components
1475-
and for kube-proxy, while `k8s.gcr.io` will be used
1476-
for all the other images.
1475+
and for kube-proxy, while `registry.k8s.io` will
1476+
be used for all the other images.
14771477
type: string
14781478
kind:
14791479
description: 'Kind is a string value representing

controlplane/kubeadm/internal/controllers/controller.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -382,20 +382,20 @@ func (r *KubeadmControlPlaneReconciler) reconcile(ctx context.Context, cluster *
382382
return ctrl.Result{}, errors.Wrap(err, "failed to set role and role binding for kubeadm")
383383
}
384384

385-
// Update kube-proxy daemonset.
386-
if err := workloadCluster.UpdateKubeProxyImageInfo(ctx, kcp); err != nil {
387-
log.Error(err, "failed to update kube-proxy daemonset")
388-
return ctrl.Result{}, err
389-
}
390-
391-
// Update CoreDNS deployment.
392385
// We intentionally only parse major/minor/patch so that the subsequent code
393386
// also already applies to beta versions of new releases.
394387
parsedVersion, err := version.ParseMajorMinorPatchTolerant(kcp.Spec.Version)
395388
if err != nil {
396389
return ctrl.Result{}, errors.Wrapf(err, "failed to parse kubernetes version %q", kcp.Spec.Version)
397390
}
398391

392+
// Update kube-proxy daemonset.
393+
if err := workloadCluster.UpdateKubeProxyImageInfo(ctx, kcp, parsedVersion); err != nil {
394+
log.Error(err, "failed to update kube-proxy daemonset")
395+
return ctrl.Result{}, err
396+
}
397+
398+
// Update CoreDNS deployment.
399399
if err := workloadCluster.UpdateCoreDNS(ctx, kcp, parsedVersion); err != nil {
400400
return ctrl.Result{}, errors.Wrap(err, "failed to update CoreDNS deployment")
401401
}

controlplane/kubeadm/internal/controllers/upgrade.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"sigs.k8s.io/cluster-api/controlplane/kubeadm/internal"
2929
"sigs.k8s.io/cluster-api/util"
3030
"sigs.k8s.io/cluster-api/util/collections"
31+
"sigs.k8s.io/cluster-api/util/version"
3132
)
3233

3334
func (r *KubeadmControlPlaneReconciler) upgradeControlPlane(
@@ -75,7 +76,15 @@ func (r *KubeadmControlPlaneReconciler) upgradeControlPlane(
7576
}
7677

7778
if kcp.Spec.KubeadmConfigSpec.ClusterConfiguration != nil {
78-
imageRepository := kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.ImageRepository
79+
// We intentionally only parse major/minor/patch so that the subsequent code
80+
// also already applies to beta versions of new releases.
81+
parsedVersionTolerant, err := version.ParseMajorMinorPatchTolerant(kcp.Spec.Version)
82+
if err != nil {
83+
return ctrl.Result{}, errors.Wrapf(err, "failed to parse kubernetes version %q", kcp.Spec.Version)
84+
}
85+
// Get the imageRepository or the correct value if nothing is set and a migration is necessary.
86+
imageRepository := internal.ImageRepositoryFromClusterConfig(kcp.Spec.KubeadmConfigSpec.ClusterConfiguration, parsedVersionTolerant)
87+
7988
if err := workloadCluster.UpdateImageRepositoryInKubeadmConfigMap(ctx, imageRepository, parsedVersion); err != nil {
8089
return ctrl.Result{}, errors.Wrap(err, "failed to update the image repository in the kubeadm config map")
8190
}

0 commit comments

Comments
 (0)