Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 6bc1bfe

Browse files
committed
etcd: expose more configs for the etcd pods.
1 parent 8347d27 commit 6bc1bfe

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

pkg/apis/etcd/v1beta2/cluster.go

+23
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,26 @@ func (c *EtcdCluster) AsOwner() metav1.OwnerReference {
6464
}
6565
}
6666

67+
type EtcdConfig struct {
68+
// Heartbeat timeout setting for etcd pod
69+
HeartbeatTimeout int `json:"heartbeatTimeout,omitempty"`
70+
71+
// Election timeout setting for etcd pod
72+
ElectionTimeout int `json:"electionTimeout,omitempty"`
73+
74+
// Snapshot count setting for etcd pod
75+
SnapshotCount int `json:"snapshotCount,omitempty"`
76+
77+
// AutoCompactionMode, https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/maintenance.md
78+
AutoCompactionMode string `json:"autoCompactionMode,omitempty"`
79+
80+
// AutoCompactionRetention, https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/maintenance.md
81+
AutoCompactionRetention string `json:"autoCompactionRetention,omitempty"`
82+
83+
// ExperimentalPeerSkipClientSANVerification indicates whether the peer client san verification will be skipped.
84+
ExperimentalPeerSkipClientSANVerification bool `json:"ExperimentalPeerSkipClientSANVerification,omitempty"`
85+
}
86+
6787
type ClusterSpec struct {
6888
// Size is the expected size of the etcd cluster.
6989
// The etcd-operator will eventually make the size of the running
@@ -92,6 +112,9 @@ type ClusterSpec struct {
92112
// Paused is to pause the control of the operator for the etcd cluster.
93113
Paused bool `json:"paused,omitempty"`
94114

115+
// EtcdConfig contains the more configs for the etcd pods.
116+
EtcdConfig `json:",inline"`
117+
95118
// Pod defines the policy to create pod for the etcd pod.
96119
//
97120
// Updating Pod does not take effect on any existing etcd pods.

pkg/util/k8sutil/k8sutil.go

+24
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,30 @@ func newEtcdPod(m *etcdutil.Member, initialCluster []string, clusterName, state,
302302
"--listen-peer-urls=%s --listen-client-urls=%s --advertise-client-urls=%s "+
303303
"--initial-cluster=%s --initial-cluster-state=%s",
304304
dataDir, m.Name, m.PeerURL(), m.ListenPeerURL(), m.ListenClientURL(), m.ClientURL(), strings.Join(initialCluster, ","), state)
305+
if cs.HeartbeatTimeout > 0 {
306+
commands += fmt.Sprintf(" --heartbeat-interval=%d", cs.HeartbeatTimeout)
307+
}
308+
309+
if cs.ElectionTimeout > 0 {
310+
commands += fmt.Sprintf(" --election-timeout=%d", cs.ElectionTimeout)
311+
}
312+
313+
if cs.SnapshotCount > 0 {
314+
commands += fmt.Sprintf(" --snapshot-count=%d", cs.SnapshotCount)
315+
}
316+
317+
if cs.AutoCompactionMode != "" {
318+
commands += fmt.Sprintf(" --auto-compaction-mode=%s", cs.AutoCompactionMode)
319+
}
320+
321+
if cs.AutoCompactionRetention != "" {
322+
commands += fmt.Sprintf(" --auto-compaction-retention=%s", cs.AutoCompactionRetention)
323+
}
324+
325+
if cs.ExperimentalPeerSkipClientSANVerification {
326+
commands += fmt.Sprintf(" --experimental-peer-skip-client-san-verification")
327+
}
328+
305329
if m.SecurePeer {
306330
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)
307331
}

0 commit comments

Comments
 (0)