diff --git a/pkg/apis/etcd/v1beta2/cluster.go b/pkg/apis/etcd/v1beta2/cluster.go index 889534b6b..a5a1f3e1f 100644 --- a/pkg/apis/etcd/v1beta2/cluster.go +++ b/pkg/apis/etcd/v1beta2/cluster.go @@ -64,6 +64,26 @@ func (c *EtcdCluster) AsOwner() metav1.OwnerReference { } } +type EtcdConfig struct { + // Heartbeat timeout setting for etcd pod + HeartbeatTimeout int `json:"heartbeatTimeout,omitempty"` + + // Election timeout setting for etcd pod + ElectionTimeout int `json:"electionTimeout,omitempty"` + + // Snapshot count setting for etcd pod + SnapshotCount int `json:"snapshotCount,omitempty"` + + // AutoCompactionMode, https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/maintenance.md + AutoCompactionMode string `json:"autoCompactionMode,omitempty"` + + // AutoCompactionRetention, https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/maintenance.md + AutoCompactionRetention string `json:"autoCompactionRetention,omitempty"` + + // ExperimentalPeerSkipClientSANVerification indicates whether the peer client san verification will be skipped. + ExperimentalPeerSkipClientSANVerification bool `json:"ExperimentalPeerSkipClientSANVerification,omitempty"` +} + type ClusterSpec struct { // Size is the expected size of the etcd cluster. // The etcd-operator will eventually make the size of the running @@ -92,6 +112,9 @@ type ClusterSpec struct { // Paused is to pause the control of the operator for the etcd cluster. Paused bool `json:"paused,omitempty"` + // EtcdConfig contains the more configs for the etcd pods. + EtcdConfig `json:",inline"` + // Pod defines the policy to create pod for the etcd pod. // // Updating Pod does not take effect on any existing etcd pods. diff --git a/pkg/util/k8sutil/k8sutil.go b/pkg/util/k8sutil/k8sutil.go index 8db36f18a..c0462c505 100644 --- a/pkg/util/k8sutil/k8sutil.go +++ b/pkg/util/k8sutil/k8sutil.go @@ -302,6 +302,30 @@ func newEtcdPod(m *etcdutil.Member, initialCluster []string, clusterName, state, "--listen-peer-urls=%s --listen-client-urls=%s --advertise-client-urls=%s "+ "--initial-cluster=%s --initial-cluster-state=%s", dataDir, m.Name, m.PeerURL(), m.ListenPeerURL(), m.ListenClientURL(), m.ClientURL(), strings.Join(initialCluster, ","), state) + if cs.HeartbeatTimeout > 0 { + commands += fmt.Sprintf(" --heartbeat-interval=%d", cs.HeartbeatTimeout) + } + + if cs.ElectionTimeout > 0 { + commands += fmt.Sprintf(" --election-timeout=%d", cs.ElectionTimeout) + } + + if cs.SnapshotCount > 0 { + commands += fmt.Sprintf(" --snapshot-count=%d", cs.SnapshotCount) + } + + if cs.AutoCompactionMode != "" { + commands += fmt.Sprintf(" --auto-compaction-mode=%s", cs.AutoCompactionMode) + } + + if cs.AutoCompactionRetention != "" { + commands += fmt.Sprintf(" --auto-compaction-retention=%s", cs.AutoCompactionRetention) + } + + if cs.ExperimentalPeerSkipClientSANVerification { + commands += fmt.Sprintf(" --experimental-peer-skip-client-san-verification") + } + if m.SecurePeer { commands += fmt.Sprintf(" --peer-client-cert-auth=true --peer-trusted-ca-file=%[1]s/peer-ca.crt --peer-cert-file=%[1]s/peer.crt --peer-key-file=%[1]s/peer.key", peerTLSDir) }