Skip to content

Commit

Permalink
Disable ETCD Learner Mode in v1.29
Browse files Browse the repository at this point in the history
ETCD Learner Mode went to Beta in k8s 1.29 and is now default enabled.

When a new stacked etcd instance comes up, it joins the cluster in learner mode.

The API Server cannot perform rpc calls against its etcd instance, and fails to come online.

In theory the etcd instance should be promoted to a full member and this issue should
be resolved, but for some reason this is not happening.

While we investigate a root cause, we are disabling this new feature flag explicitly.
  • Loading branch information
jonathanmeier5 committed Feb 26, 2024
1 parent 7bf3382 commit 87f158b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/providers/cloudstack/config/template-cp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ spec:
name: {{.controlPlaneTemplateName}}
kubeadmConfigSpec:
clusterConfiguration:
{{- if (ge (atoi $kube_minor_version) 29) }}
featureGates:
EtcdLearnerMode: false
{{- end }}
imageRepository: {{.kubernetesRepository}}
etcd:
{{- if .externalEtcd }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ spec:
name: test-control-plane-template-1234567890000
kubeadmConfigSpec:
clusterConfiguration:
featureGates:
EtcdLearnerMode: false
imageRepository: public.ecr.aws/eks-distro/kubernetes
etcd:
local:
Expand Down
3 changes: 3 additions & 0 deletions pkg/providers/snow/apibuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func KubeadmControlPlane(log logr.Logger, clusterSpec *cluster.Spec, snowMachine
joinConfigKubeletExtraArg["provider-id"] = "aws-snow:////'{{ ds.meta_data.instance_id }}'"

addStackedEtcdExtraArgsInKubeadmControlPlane(kcp, clusterSpec.Cluster.Spec.ExternalEtcdConfiguration)
if versionsBundle.KubeVersion == "1.29" {
disableEtcdLearnerMode(kcp)
}

machineConfig := clusterSpec.SnowMachineConfig(clusterSpec.Cluster.Spec.ControlPlaneConfiguration.MachineGroupRef.Name)

Expand Down
10 changes: 9 additions & 1 deletion pkg/providers/snow/apibuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func wantKubeadmControlPlane(kubeVersion v1alpha1.KubernetesVersion) *controlpla
wantReplicas := int32(3)
wantMaxSurge := intstr.FromInt(1)
versionBundles := givenVersionsBundle(kubeVersion)
return &controlplanev1.KubeadmControlPlane{
kcp := &controlplanev1.KubeadmControlPlane{
TypeMeta: metav1.TypeMeta{
APIVersion: "controlplane.cluster.x-k8s.io/v1beta1",
Kind: "KubeadmControlPlane",
Expand Down Expand Up @@ -200,6 +200,14 @@ func wantKubeadmControlPlane(kubeVersion v1alpha1.KubernetesVersion) *controlpla
Version: versionBundles.KubeDistro.Kubernetes.Tag,
},
}

if kubeVersion == "1.29" {
kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.FeatureGates = map[string]bool{
"EtcdLearnerMode": false,
}
}

return kcp
}

func wantKubeadmControlPlaneUnstackedEtcd() *controlplanev1.KubeadmControlPlane {
Expand Down
8 changes: 8 additions & 0 deletions pkg/providers/snow/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ func addStackedEtcdExtraArgsInKubeadmControlPlane(kcp *controlplanev1.KubeadmCon
stackedEtcdExtraArgs["listen-peer-urls"] = "https://0.0.0.0:2380"
stackedEtcdExtraArgs["listen-client-urls"] = "https://0.0.0.0:2379"
}

func disableEtcdLearnerMode(kcp *controlplanev1.KubeadmControlPlane) {
if kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.FeatureGates == nil {
kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.FeatureGates = map[string]bool{}
}

kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.FeatureGates["EtcdLearnerMode"] = false
}
5 changes: 5 additions & 0 deletions pkg/providers/tinkerbell/config/template-cp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ metadata:
spec:
kubeadmConfigSpec:
clusterConfiguration:
{{- $kube_minor_version := (index (splitList "." (trimPrefix "v" .kubernetesVersion)) 1) }}
{{- if (ge (atoi $kube_minor_version) 29) }}
featureGates:
EtcdLearnerMode: false
{{- end }}
imageRepository: {{.kubernetesRepository}}
etcd:
{{- if .externalEtcd }}
Expand Down
4 changes: 4 additions & 0 deletions pkg/providers/vsphere/config/template-cp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ spec:
name: {{.controlPlaneTemplateName}}
kubeadmConfigSpec:
clusterConfiguration:
{{- if (ge (atoi $kube_minor_version) 29) }}
featureGates:
EtcdLearnerMode: false
{{- end }}
imageRepository: {{.kubernetesRepository}}
etcd:
{{- if .externalEtcd }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ spec:
name: test-control-plane-template-1234567890000
kubeadmConfigSpec:
clusterConfiguration:
featureGates:
EtcdLearnerMode: false
imageRepository: public.ecr.aws/eks-distro/kubernetes
etcd:
external:
Expand Down

0 comments on commit 87f158b

Please sign in to comment.