etcd

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 23 Imported by: 32

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMemberIDForPeerURL = errors.New("no member id found for peer URL")

ErrNoMemberIDForPeerURL is returned when it is not possible to obtain a member ID from a given peer URL

Functions

func CreateDataDirectory added in v1.20.0

func CreateDataDirectory(dir string) error

CreateDataDirectory creates the etcd data directory (commonly /var/lib/etcd) with the right permissions.

func GetClientURL added in v1.13.0

func GetClientURL(localEndpoint *kubeadmapi.APIEndpoint) string

GetClientURL creates an HTTPS URL that uses the configured advertise address and client port for the API controller

func GetClientURLByIP added in v1.13.0

func GetClientURLByIP(ip string) string

GetClientURLByIP creates an HTTPS URL based on an IP address and the client listening port.

func GetPeerURL added in v1.13.0

func GetPeerURL(localEndpoint *kubeadmapi.APIEndpoint) string

GetPeerURL creates an HTTPS URL that uses the configured advertise address and peer port for the API controller

Types

type Client

type Client struct {
	Endpoints []string
	// contains filtered or unexported fields
}

Client provides connection parameters for an etcd cluster

func New added in v1.10.3

func New(endpoints []string, ca, cert, key string) (*Client, error)

New creates a new EtcdCluster client

func NewFromCluster added in v1.13.0

func NewFromCluster(client clientset.Interface, certificatesDir string) (*Client, error)

NewFromCluster creates an etcd client for the etcd endpoints present in etcd member list. In order to compose this information, it will first discover at least one etcd endpoint to connect to. Once created, the client synchronizes client's endpoints with the known endpoints from the etcd membership API, since it is the authoritative source of truth for the list of available members.

func (*Client) AddMember added in v1.13.0

func (c *Client) AddMember(name string, peerAddrs string) ([]Member, error)

AddMember adds a new member into the etcd cluster

func (*Client) AddMemberAsLearner added in v1.27.0

func (c *Client) AddMemberAsLearner(name string, peerAddrs string) ([]Member, error)

AddMemberAsLearner adds a new learner member into the etcd cluster.

func (*Client) CheckClusterHealth added in v1.17.0

func (c *Client) CheckClusterHealth() error

CheckClusterHealth returns nil for status Up or error for status Down

func (*Client) GetMemberID added in v1.14.0

func (c *Client) GetMemberID(peerURL string) (uint64, error)

GetMemberID returns the member ID of the given peer URL

func (*Client) ListMembers added in v1.17.9

func (c *Client) ListMembers() ([]Member, error)

ListMembers returns the member list.

func (*Client) MemberPromote added in v1.27.0

func (c *Client) MemberPromote(learnerID uint64) error

MemberPromote promotes a member as a voting member. If the given member ID is already a voting member this method will return early and do nothing.

func (*Client) RemoveMember added in v1.14.0

func (c *Client) RemoveMember(id uint64) ([]Member, error)

RemoveMember notifies an etcd cluster to remove an existing member

func (*Client) Sync added in v1.13.0

func (c *Client) Sync() error

Sync synchronizes client's endpoints with the known endpoints from the etcd membership.

func (*Client) WaitForClusterAvailable added in v1.10.3

func (c *Client) WaitForClusterAvailable(retries int, retryInterval time.Duration) (bool, error)

WaitForClusterAvailable returns true if all endpoints in the cluster are available after retry attempts, an error is returned otherwise

type ClusterInterrogator added in v1.10.3

type ClusterInterrogator interface {
	CheckClusterHealth() error
	WaitForClusterAvailable(retries int, retryInterval time.Duration) (bool, error)
	Sync() error
	ListMembers() ([]Member, error)
	AddMember(name string, peerAddrs string) ([]Member, error)
	AddMemberAsLearner(name string, peerAddrs string) ([]Member, error)
	MemberPromote(learnerID uint64) error
	GetMemberID(peerURL string) (uint64, error)
	RemoveMember(id uint64) ([]Member, error)
}

ClusterInterrogator is an interface to get etcd cluster related information

type Member added in v1.13.0

type Member struct {
	Name    string
	PeerURL string
}

Member struct defines an etcd member; it is used for avoiding to spread github.com/coreos/etcd dependency across kubeadm codebase

Jump to

Keyboard shortcuts

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