Skip to content

Commit

Permalink
kcp: patch ImageRepository in ClusterConfiguration if it is not set f…
Browse files Browse the repository at this point in the history
…or v1.25
  • Loading branch information
chrischdi committed Jul 14, 2022
1 parent ef7172a commit b55eb64
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions controlplane/kubeadm/internal/controllers/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ func (r *KubeadmControlPlaneReconciler) upgradeControlPlane(
return ctrl.Result{}, errors.Wrap(err, "failed to update the kubernetes version in the kubeadm config map")
}

// FIXME(chrischdi): use a better semver comparison
// FIXME(chrischdi): think about having a better if structure 😅
if parsedVersion.Minor == 25 &&
(kcp.Spec.KubeadmConfigSpec.ClusterConfiguration == nil || kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.ImageRepository == "") {
// FIXME(chrischdi): use a const instead of hardcoding
if err := workloadCluster.UpdateImageRepositoryInKubeadmConfigMap(ctx, "registry.k8s.io", parsedVersion); err != nil {
return ctrl.Result{}, errors.Wrapf(err, "failed to update the image repository in the kubeadm config map to %s for v1.25 compatibility", "registry.k8s.io")
}
}

if kcp.Spec.KubeadmConfigSpec.ClusterConfiguration != nil {
imageRepository := kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.ImageRepository
if err := workloadCluster.UpdateImageRepositoryInKubeadmConfigMap(ctx, imageRepository, parsedVersion); err != nil {
Expand Down

0 comments on commit b55eb64

Please sign in to comment.