Skip to content
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
9 changes: 9 additions & 0 deletions controlplane/kubeadm/internal/workload_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,17 @@
// the spec.clusterIP field selector that is only implemented in kube-apiserver >= 1.31.0).
minKubernetesVersionControlPlaneKubeletLocalMode = semver.MustParse("1.31.0")

// droppedKubernetesVersionControlPlaneKubeletLocalMode is the version from which
// we will drop the ControlPlaneKubeletLocalMode kubeadm feature gate.
// Starting with Kubernetes 1.36, this feature graduated to GA and the feature gate
// is no longer needed (and was removed from kubeadm).
droppedKubernetesVersionControlPlaneKubeletLocalMode = semver.MustParse("1.36.0")

// ErrControlPlaneMinNodes signals that a cluster doesn't meet the minimum required nodes
// to remove an etcd member.
ErrControlPlaneMinNodes = errors.New("cluster has fewer than 2 control plane nodes; removing an etcd member is not supported")

ErrRemediationNodeIsEtcdLeader = errors.New("node is the etcd leader, skipping etcd leadership forward")

Check failure on line 83 in controlplane/kubeadm/internal/workload_cluster.go

View workflow job for this annotation

GitHub Actions / lint

exported: exported var ErrRemediationNodeIsEtcdLeader should have comment or be unexported (revive)

Check failure on line 83 in controlplane/kubeadm/internal/workload_cluster.go

View workflow job for this annotation

GitHub Actions / lint

exported: exported var ErrRemediationNodeIsEtcdLeader should have comment or be unexported (revive)
)

// WorkloadCluster defines all behaviors necessary to upgrade kubernetes on a workload cluster
Expand Down Expand Up @@ -187,6 +193,9 @@
if version.Compare(kubernetesVersion, minKubernetesVersionControlPlaneKubeletLocalMode, version.WithoutPreReleases()) < 0 {
return
}
if !kubernetesVersion.LT(droppedKubernetesVersionControlPlaneKubeletLocalMode) {
return
}

if kubeadmConfigSpec.ClusterConfiguration.FeatureGates == nil {
kubeadmConfigSpec.ClusterConfiguration.FeatureGates = map[string]bool{}
Expand Down
48 changes: 48 additions & 0 deletions controlplane/kubeadm/internal/workload_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,36 @@ func TestUpdateFeatureGatesInKubeadmConfigMap(t *testing.T) {
},
},
},
{
name: "it should not add ControlPlaneKubeletLocalMode feature gate for 1.36.0",
clusterConfigurationData: utilyaml.Raw(`
apiVersion: kubeadm.k8s.io/v1beta4
kind: ClusterConfiguration`),
kubernetesVersion: semver.MustParse("1.36.0"),
newClusterConfiguration: bootstrapv1.ClusterConfiguration{
FeatureGates: nil,
},
wantClusterConfiguration: bootstrapv1.ClusterConfiguration{
FeatureGates: nil,
},
},
{
name: "it should preserve other feature gates for 1.36.0",
clusterConfigurationData: utilyaml.Raw(`
apiVersion: kubeadm.k8s.io/v1beta4
kind: ClusterConfiguration`),
kubernetesVersion: semver.MustParse("1.36.0"),
newClusterConfiguration: bootstrapv1.ClusterConfiguration{
FeatureGates: map[string]bool{
"EtcdLearnerMode": true,
},
},
wantClusterConfiguration: bootstrapv1.ClusterConfiguration{
FeatureGates: map[string]bool{
"EtcdLearnerMode": true,
},
},
},
}

for _, tt := range tests {
Expand Down Expand Up @@ -1110,6 +1140,24 @@ func TestDefaultFeatureGates(t *testing.T) {
},
},
},
{
name: "don't default ControlPlaneKubeletLocalMode for 1.36",
kubernetesVersion: semver.MustParse("1.36.0"),
kubeadmConfigSpec: &bootstrapv1.KubeadmConfigSpec{
ClusterConfiguration: bootstrapv1.ClusterConfiguration{
FeatureGates: map[string]bool{
"EtcdLearnerMode": true,
},
},
},
wantKubeadmConfigSpec: &bootstrapv1.KubeadmConfigSpec{
ClusterConfiguration: bootstrapv1.ClusterConfiguration{
FeatureGates: map[string]bool{
"EtcdLearnerMode": true,
},
},
},
},
{
name: "default ControlPlaneKubeletLocalMode for 1.31",
kubernetesVersion: semver.MustParse("1.31.0"),
Expand Down
Loading