diff --git a/cmd/kubeadm/app/phases/etcd/local.go b/cmd/kubeadm/app/phases/etcd/local.go index e10aa9a76c8..3768ee57f07 100644 --- a/cmd/kubeadm/app/phases/etcd/local.go +++ b/cmd/kubeadm/app/phases/etcd/local.go @@ -28,7 +28,6 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" - "k8s.io/apimachinery/pkg/util/version" clientset "k8s.io/client-go/kubernetes" "k8s.io/klog/v2" utilsnet "k8s.io/utils/net" @@ -263,21 +262,8 @@ func getEtcdCommand(cfg *kubeadmapi.ClusterConfiguration, endpoint *kubeadmapi.A {Name: "peer-client-cert-auth", Value: "true"}, {Name: "snapshot-count", Value: "10000"}, {Name: "listen-metrics-urls", Value: fmt.Sprintf("http://%s", net.JoinHostPort(etcdLocalhostAddress, strconv.Itoa(kubeadmconstants.EtcdMetricsPort)))}, - } - - etcdImageTag := images.GetEtcdImageTag(cfg, supportedEtcdVersion) - if etcdVersion, err := version.ParseSemantic(etcdImageTag); err == nil && etcdVersion.AtLeast(version.MustParseSemantic("3.6.0")) { - // Arguments used by Etcd 3.6.0+. - // TODO: Start always using these once kubeadm only supports etcd >= 3.6.0 for all its supported k8s versions. - defaultArguments = append(defaultArguments, []kubeadmapi.Arg{ - {Name: "feature-gates", Value: "InitialCorruptCheck=true"}, - {Name: "watch-progress-notify-interval", Value: "5s"}, - }...) - } else { - defaultArguments = append(defaultArguments, []kubeadmapi.Arg{ - {Name: "experimental-initial-corrupt-check", Value: "true"}, - {Name: "experimental-watch-progress-notify-interval", Value: "5s"}, - }...) + {Name: "feature-gates", Value: "InitialCorruptCheck=true"}, + {Name: "watch-progress-notify-interval", Value: "5s"}, } if len(initialCluster) == 0 { diff --git a/cmd/kubeadm/app/phases/etcd/local_test.go b/cmd/kubeadm/app/phases/etcd/local_test.go index aa0bc2d56c1..1039fb6951e 100644 --- a/cmd/kubeadm/app/phases/etcd/local_test.go +++ b/cmd/kubeadm/app/phases/etcd/local_test.go @@ -412,94 +412,6 @@ func TestGetEtcdCommand(t *testing.T) { fmt.Sprintf("--initial-cluster=foo=https://[2001:db8::3]:%d", kubeadmconstants.EtcdListenPeerPort), }, }, - { - name: "Default args - with k8s 1.33.0", - advertiseAddress: "1.2.3.4", - k8sVersion: "1.33.0", - nodeName: "bar", - supportedEtcdVersion: map[uint8]string{ - 33: "3.5.24", - 34: "3.6.5", - }, - expected: []string{ - "etcd", - "--name=bar", - "--experimental-initial-corrupt-check=true", - "--experimental-watch-progress-notify-interval=5s", - fmt.Sprintf("--listen-client-urls=https://127.0.0.1:%d,https://1.2.3.4:%d", kubeadmconstants.EtcdListenClientPort, kubeadmconstants.EtcdListenClientPort), - fmt.Sprintf("--listen-metrics-urls=http://127.0.0.1:%d", kubeadmconstants.EtcdMetricsPort), - fmt.Sprintf("--advertise-client-urls=https://1.2.3.4:%d", kubeadmconstants.EtcdListenClientPort), - fmt.Sprintf("--listen-peer-urls=https://1.2.3.4:%d", kubeadmconstants.EtcdListenPeerPort), - fmt.Sprintf("--initial-advertise-peer-urls=https://1.2.3.4:%d", kubeadmconstants.EtcdListenPeerPort), - "--data-dir=/var/lib/etcd", - "--cert-file=" + filepath.FromSlash(kubeadmconstants.EtcdServerCertName), - "--key-file=" + filepath.FromSlash(kubeadmconstants.EtcdServerKeyName), - "--trusted-ca-file=" + filepath.FromSlash(kubeadmconstants.EtcdCACertName), - "--client-cert-auth=true", - "--peer-cert-file=" + filepath.FromSlash(kubeadmconstants.EtcdPeerCertName), - "--peer-key-file=" + filepath.FromSlash(kubeadmconstants.EtcdPeerKeyName), - "--peer-trusted-ca-file=" + filepath.FromSlash(kubeadmconstants.EtcdCACertName), - "--snapshot-count=10000", - "--peer-client-cert-auth=true", - fmt.Sprintf("--initial-cluster=bar=https://1.2.3.4:%d", kubeadmconstants.EtcdListenPeerPort), - }, - }, - { - name: "Default args - with semver etcd image (3.5.21-0)", - advertiseAddress: "1.2.3.4", - etcdImageTag: "3.5.21-0", - nodeName: "bar", - expected: []string{ - "etcd", - "--name=bar", - "--experimental-initial-corrupt-check=true", - "--experimental-watch-progress-notify-interval=5s", - fmt.Sprintf("--listen-client-urls=https://127.0.0.1:%d,https://1.2.3.4:%d", kubeadmconstants.EtcdListenClientPort, kubeadmconstants.EtcdListenClientPort), - fmt.Sprintf("--listen-metrics-urls=http://127.0.0.1:%d", kubeadmconstants.EtcdMetricsPort), - fmt.Sprintf("--advertise-client-urls=https://1.2.3.4:%d", kubeadmconstants.EtcdListenClientPort), - fmt.Sprintf("--listen-peer-urls=https://1.2.3.4:%d", kubeadmconstants.EtcdListenPeerPort), - fmt.Sprintf("--initial-advertise-peer-urls=https://1.2.3.4:%d", kubeadmconstants.EtcdListenPeerPort), - "--data-dir=/var/lib/etcd", - "--cert-file=" + filepath.FromSlash(kubeadmconstants.EtcdServerCertName), - "--key-file=" + filepath.FromSlash(kubeadmconstants.EtcdServerKeyName), - "--trusted-ca-file=" + filepath.FromSlash(kubeadmconstants.EtcdCACertName), - "--client-cert-auth=true", - "--peer-cert-file=" + filepath.FromSlash(kubeadmconstants.EtcdPeerCertName), - "--peer-key-file=" + filepath.FromSlash(kubeadmconstants.EtcdPeerKeyName), - "--peer-trusted-ca-file=" + filepath.FromSlash(kubeadmconstants.EtcdCACertName), - "--snapshot-count=10000", - "--peer-client-cert-auth=true", - fmt.Sprintf("--initial-cluster=bar=https://1.2.3.4:%d", kubeadmconstants.EtcdListenPeerPort), - }, - }, - { - name: "Default args - with non-semver etcd image", - advertiseAddress: "1.2.3.4", - etcdImageTag: "non-semver", - nodeName: "bar", - expected: []string{ - "etcd", - "--name=bar", - "--experimental-initial-corrupt-check=true", - "--experimental-watch-progress-notify-interval=5s", - fmt.Sprintf("--listen-client-urls=https://127.0.0.1:%d,https://1.2.3.4:%d", kubeadmconstants.EtcdListenClientPort, kubeadmconstants.EtcdListenClientPort), - fmt.Sprintf("--listen-metrics-urls=http://127.0.0.1:%d", kubeadmconstants.EtcdMetricsPort), - fmt.Sprintf("--advertise-client-urls=https://1.2.3.4:%d", kubeadmconstants.EtcdListenClientPort), - fmt.Sprintf("--listen-peer-urls=https://1.2.3.4:%d", kubeadmconstants.EtcdListenPeerPort), - fmt.Sprintf("--initial-advertise-peer-urls=https://1.2.3.4:%d", kubeadmconstants.EtcdListenPeerPort), - "--data-dir=/var/lib/etcd", - "--cert-file=" + filepath.FromSlash(kubeadmconstants.EtcdServerCertName), - "--key-file=" + filepath.FromSlash(kubeadmconstants.EtcdServerKeyName), - "--trusted-ca-file=" + filepath.FromSlash(kubeadmconstants.EtcdCACertName), - "--client-cert-auth=true", - "--peer-cert-file=" + filepath.FromSlash(kubeadmconstants.EtcdPeerCertName), - "--peer-key-file=" + filepath.FromSlash(kubeadmconstants.EtcdPeerKeyName), - "--peer-trusted-ca-file=" + filepath.FromSlash(kubeadmconstants.EtcdCACertName), - "--snapshot-count=10000", - "--peer-client-cert-auth=true", - fmt.Sprintf("--initial-cluster=bar=https://1.2.3.4:%d", kubeadmconstants.EtcdListenPeerPort), - }, - }, } for _, rt := range tests {