Skip to content

Commit

Permalink
Revert "Revert "[release-0.19] Disable ETCD Learner Mode (#7719)" (#7728
Browse files Browse the repository at this point in the history
)" (#7767)

This reverts commit 3311d96.
  • Loading branch information
abhinavmpandey08 authored Mar 1, 2024
1 parent d6aaaed commit b865194
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 11 deletions.
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
24 changes: 15 additions & 9 deletions pkg/providers/snow/apibuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ func KubeadmControlPlane(log logr.Logger, clusterSpec *cluster.Spec, snowMachine

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

kubeVersionSemver, err := semver.New(string(clusterSpec.Cluster.Spec.KubernetesVersion) + ".0")
if err != nil {
return nil, fmt.Errorf("error converting kubeVersion %v to semver %v", clusterSpec.Cluster.Spec.KubernetesVersion, err)
}

kube129Semver, err := semver.New(string(v1alpha1.Kube129) + ".0")
if err != nil {
return nil, fmt.Errorf("error converting kubeVersion %v to semver %v", v1alpha1.Kube129, err)
}

osFamily := machineConfig.OSFamily()
switch osFamily {
case v1alpha1.Bottlerocket:
Expand All @@ -70,24 +80,20 @@ func KubeadmControlPlane(log logr.Logger, clusterSpec *cluster.Spec, snowMachine
addBottlerocketBootstrapSnowInKubeadmControlPlane(kcp, versionsBundle.Snow.BottlerocketBootstrapSnow)
clusterapi.SetBottlerocketHostConfigInKubeadmControlPlane(kcp, machineConfig.Spec.HostOSConfiguration)

if kubeVersionSemver.Compare(kube129Semver) != -1 {
disableEtcdLearnerMode(kcp)
}

case v1alpha1.Ubuntu:
kcp.Spec.KubeadmConfigSpec.PreKubeadmCommands = append(kcp.Spec.KubeadmConfigSpec.PreKubeadmCommands,
"/etc/eks/bootstrap.sh",
)
kubeVersionSemver, err := semver.New(string(clusterSpec.Cluster.Spec.KubernetesVersion) + ".0")
if err != nil {
return nil, fmt.Errorf("error converting kubeVersion %v to semver %v", clusterSpec.Cluster.Spec.KubernetesVersion, err)
}

kube129Semver, err := semver.New(string(v1alpha1.Kube129) + ".0")
if err != nil {
return nil, fmt.Errorf("error converting kubeVersion %v to semver %v", v1alpha1.Kube129, err)
}

if kubeVersionSemver.Compare(kube129Semver) != -1 {
kcp.Spec.KubeadmConfigSpec.PreKubeadmCommands = append(kcp.Spec.KubeadmConfigSpec.PreKubeadmCommands,
"if [ -f /run/kubeadm/kubeadm.yaml ]; then sed -i 's#path: /etc/kubernetes/admin.conf#path: /etc/kubernetes/super-admin.conf#' /etc/kubernetes/manifests/kube-vip.yaml; fi",
)
disableEtcdLearnerMode(kcp)
}

if err := clusterapi.SetProxyConfigInKubeadmControlPlaneForUbuntu(kcp, clusterSpec.Cluster); err != nil {
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
}
6 changes: 5 additions & 1 deletion pkg/providers/tinkerbell/config/template-cp.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- $kube_minor_version := (index (splitList "." (trimPrefix "v" .kubernetesVersion)) 1) -}}
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
Expand Down Expand Up @@ -37,6 +38,10 @@ metadata:
spec:
kubeadmConfigSpec:
clusterConfiguration:
{{- if (ge (atoi $kube_minor_version) 29) }}
featureGates:
EtcdLearnerMode: false
{{- end }}
imageRepository: {{.kubernetesRepository}}
etcd:
{{- if .externalEtcd }}
Expand Down Expand Up @@ -395,7 +400,6 @@ spec:
- {{ . }}
{{- end }}
{{- end }}
{{- $kube_minor_version := (index (splitList "." (trimPrefix "v" .kubernetesVersion)) 1) }}
{{- if and (or .registryMirrorMap .proxyConfig (ge (atoi $kube_minor_version) 29)) (ne .format "bottlerocket") }}
preKubeadmCommands:
{{- if .registryMirrorMap }}
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 b865194

Please sign in to comment.