From 5cc39d7d426f27c7388909e01718cddf150edbbd Mon Sep 17 00:00:00 2001 From: pixiake Date: Thu, 1 Aug 2024 11:05:44 +0800 Subject: [PATCH] support custome etcd args (#2337) Signed-off-by: pixiake (cherry picked from commit 1dd1e54db02ab76cd39dc2a9b38ae9dd60ca1409) Signed-off-by: pixiake (cherry picked from commit 3aa568db7bc09ce4543465f1cb4263df495fbf9f) --- cmd/kk/apis/kubekey/v1alpha2/etcd_types.go | 1 + cmd/kk/pkg/etcd/tasks.go | 1 + cmd/kk/pkg/etcd/templates/etcd_env.go | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/cmd/kk/apis/kubekey/v1alpha2/etcd_types.go b/cmd/kk/apis/kubekey/v1alpha2/etcd_types.go index a3dd02324..fcfe71823 100644 --- a/cmd/kk/apis/kubekey/v1alpha2/etcd_types.go +++ b/cmd/kk/apis/kubekey/v1alpha2/etcd_types.go @@ -29,6 +29,7 @@ type EtcdCluster struct { External ExternalEtcd `yaml:"external" json:"external,omitempty"` Port *int `yaml:"port" json:"port,omitempty"` PeerPort *int `yaml:"peerPort" json:"peerPort,omitempty"` + ExtraArgs []string `yaml:"extraArgs" json:"extraArgs,omitempty"` BackupDir string `yaml:"backupDir" json:"backupDir,omitempty"` BackupPeriod int `yaml:"backupPeriod" json:"backupPeriod,omitempty"` KeepBackupNumber int `yaml:"keepBackupNumber" json:"keepBackupNumber,omitempty"` diff --git a/cmd/kk/pkg/etcd/tasks.go b/cmd/kk/pkg/etcd/tasks.go index 4db3a45f7..2ccd86eec 100644 --- a/cmd/kk/pkg/etcd/tasks.go +++ b/cmd/kk/pkg/etcd/tasks.go @@ -311,6 +311,7 @@ func refreshConfig(KubeConf *common.KubeConf, runtime connector.Runtime, endpoin "Hostname": host.GetName(), "Port": KubeConf.Cluster.Etcd.GetPort(), "PeerPort": KubeConf.Cluster.Etcd.GetPeerPort(), + "ExtraArgs": KubeConf.Cluster.Etcd.ExtraArgs, "State": state, "PeerAddresses": strings.Join(endpoints, ","), "UnsupportedArch": UnsupportedArch, diff --git a/cmd/kk/pkg/etcd/templates/etcd_env.go b/cmd/kk/pkg/etcd/templates/etcd_env.go index ad6e20645..b97598eaa 100644 --- a/cmd/kk/pkg/etcd/templates/etcd_env.go +++ b/cmd/kk/pkg/etcd/templates/etcd_env.go @@ -82,6 +82,11 @@ ETCD_LOG_LEVEL={{ .LogLevel }} {{- if .UnsupportedArch }} ETCD_UNSUPPORTED_ARCH={{ .Arch }} {{ end }} +{{- if .ExtraArgs }} +{{- range $index, $value := .ExtraArgs }} +{{ $value }} +{{- end }} +{{- end }} # TLS settings ETCD_TRUSTED_CA_FILE=/etc/ssl/etcd/ssl/ca.pem