etcd

package
v1.10.0-alpha.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2024 License: MPL-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const QuorumCheckTimeout = 15 * time.Second

QuorumCheckTimeout is the amount of time to allow for KV operations before quorum is declared invalid.

Variables

This section is empty.

Functions

func GetEndpoints

func GetEndpoints(ctx context.Context, resources state.State) ([]string, error)

GetEndpoints returns expected endpoints of etcd cluster members.

It is not guaranteed that etcd is running on each listed endpoint.

func GetLocalMemberID

func GetLocalMemberID(ctx context.Context, s state.State) (uint64, error)

GetLocalMemberID gets the etcd member id of the local node via resources.

func WithLock

func WithLock(ctx context.Context, key string, logger *zap.Logger, f func() error) error

WithLock executes the given function exclusively by acquiring an Etcd lock with the given key.

Types

type CertificateGenerator

type CertificateGenerator struct {
	CA *x509.PEMEncodedCertificateAndKey

	NodeAddresses  *network.NodeAddress
	HostnameStatus *network.HostnameStatus
}

CertificateGenerator contains etcd certificate options.

func (*CertificateGenerator) GenerateClientCert

func (gen *CertificateGenerator) GenerateClientCert(commonName string) (*x509.PEMEncodedCertificateAndKey, error)

GenerateClientCert generates client certificate and key from etcd CA.

func (*CertificateGenerator) GeneratePeerCert

func (gen *CertificateGenerator) GeneratePeerCert() (*x509.PEMEncodedCertificateAndKey, error)

GeneratePeerCert generates etcd peer certificate and key from etcd CA.

func (*CertificateGenerator) GenerateServerCert

func (gen *CertificateGenerator) GenerateServerCert() (*x509.PEMEncodedCertificateAndKey, error)

GenerateServerCert generates server etcd certificate and key from etcd CA.

type Client

type Client struct {
	*clientv3.Client
}

Client is a wrapper around the official etcd client.

func NewClient

func NewClient(ctx context.Context, endpoints []string, dialOpts ...grpc.DialOption) (client *Client, err error)

NewClient initializes and returns an etcd client configured to talk to a list of endpoints.

func NewClientFromControlPlaneIPs

func NewClientFromControlPlaneIPs(ctx context.Context, resources state.State, dialOpts ...grpc.DialOption) (client *Client, err error)

NewClientFromControlPlaneIPs initializes and returns an etcd client configured to talk to all members.

func NewLocalClient

func NewLocalClient(ctx context.Context, dialOpts ...grpc.DialOption) (client *Client, err error)

NewLocalClient initializes and returns etcd client configured to talk to localhost endpoint.

func (*Client) ForfeitLeadership

func (c *Client) ForfeitLeadership(ctx context.Context, memberID string) (string, error)

ForfeitLeadership transfers leadership from the current member to another member.

func (*Client) GetMemberID

func (c *Client) GetMemberID(ctx context.Context) (uint64, error)

GetMemberID returns the member ID of the node client is connected to.

func (*Client) LeaveCluster

func (c *Client) LeaveCluster(ctx context.Context, st state.State) error

LeaveCluster removes the current member from the etcd cluster and nukes etcd data directory.

func (*Client) RemoveMemberByMemberID

func (c *Client) RemoveMemberByMemberID(ctx context.Context, memberID uint64) error

RemoveMemberByMemberID removes the member from the etcd cluster.

func (*Client) ValidateForUpgrade

func (c *Client) ValidateForUpgrade(ctx context.Context, config config.Config) error

ValidateForUpgrade validates the etcd cluster state to ensure that performing an upgrade is safe.

func (*Client) ValidateQuorum

func (c *Client) ValidateQuorum(ctx context.Context) (err error)

ValidateQuorum performs a KV operation to make certain that quorum is good.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL