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

Commit

Permalink
etcd: expose more configs for the etcd pods.
Browse files Browse the repository at this point in the history
  • Loading branch information
andyliuliming committed Oct 5, 2019
1 parent 8347d27 commit 6bc1bfe
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/apis/etcd/v1beta2/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
24 changes: 24 additions & 0 deletions pkg/util/k8sutil/k8sutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 6bc1bfe

Please sign in to comment.