etcd

package
v0.0.0-...-ca78c08 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: Apache-2.0 Imports: 58 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MasterLabel       = "node-role.kubernetes.io/master"
	ControlPlaneLabel = "node-role.kubernetes.io/control-plane"
	EtcdRoleLabel     = "node-role.kubernetes.io/etcd"
)

Variables

View Source
var (

	// AddressKey will contain the value of api addresses list
	AddressKey = version.Program + "/apiaddresses"

	NodeNameAnnotation    = "etcd." + version.Program + ".cattle.io/node-name"
	NodeAddressAnnotation = "etcd." + version.Program + ".cattle.io/node-address"

	ErrAddressNotSet = errors.New("apiserver addresses not yet set")
	ErrNotMember     = errNotMember()
)

Functions

func DBDir

func DBDir(config *config.Control) string

DBDir returns the path to dataDir/db/etcd

func GetAPIServerURLsFromETCD

func GetAPIServerURLsFromETCD(ctx context.Context, cfg *config.Control) ([]string, error)

GetAPIServerURLsFromETCD will try to fetch the version.Program/apiaddresses key from etcd and unmarshal it to a list of apiserver endpoints.

func GetAdvertiseAddress

func GetAdvertiseAddress(advertiseIP string) (string, error)

getAdvertiseAddress returns the IP address best suited for advertising to clients

func GetClient

func GetClient(ctx context.Context, control *config.Control, endpoints ...string) (*clientv3.Client, error)

GetClient returns an etcd client connected to the specified endpoints. If no endpoints are provided, endpoints are retrieved from the provided runtime config. If the runtime config does not list any endpoints, the default endpoint is used. The returned client should be closed when no longer needed, in order to avoid leaking GRPC client goroutines.

func ResetFile

func ResetFile(config *config.Control) string

ResetFile returns the path to etcdDBDir/reset-flag.

Types

type ETCD

type ETCD struct {
	// contains filtered or unexported fields
}

func NewETCD

func NewETCD() *ETCD

NewETCD creates a new value of type ETCD with an initialized cron value.

func (*ETCD) DeleteSnapshots

func (e *ETCD) DeleteSnapshots(ctx context.Context, snapshots []string) error

deleteSnapshots removes the given snapshots from either local storage or S3.

func (*ETCD) EndpointName

func (e *ETCD) EndpointName() string

EndpointName returns the name of the endpoint.

func (*ETCD) GetMembersClientURLs

func (e *ETCD) GetMembersClientURLs(ctx context.Context) ([]string, error)

GetMembersClientURLs will list through the member lists in etcd and return back a combined list of client urls for each member in the cluster

func (*ETCD) GetMembersNames

func (e *ETCD) GetMembersNames(ctx context.Context) ([]string, error)

GetMembersNames will list through the member lists in etcd and return back a combined list of member names

func (*ETCD) IsInitialized

func (e *ETCD) IsInitialized(ctx context.Context, config *config.Control) (bool, error)

IsInitialized checks to see if a WAL directory exists. If so, we assume that etcd has already been brought up at least once.

func (*ETCD) ListSnapshots

func (e *ETCD) ListSnapshots(ctx context.Context) (map[string]snapshotFile, error)

ListSnapshots is an exported wrapper method that wraps an unexported method of the same name.

func (*ETCD) PruneSnapshots

func (e *ETCD) PruneSnapshots(ctx context.Context) error

PruneSnapshots performs a retention run with the given retention duration and removes expired snapshots.

func (*ETCD) ReconcileSnapshotData

func (e *ETCD) ReconcileSnapshotData(ctx context.Context) error

ReconcileSnapshotData reconciles snapshot data in the snapshot ConfigMap. It will reconcile snapshot data from disk locally always, and if S3 is enabled, will attempt to list S3 snapshots and reconcile snapshots from S3. Notably,

func (*ETCD) Register

func (e *ETCD) Register(ctx context.Context, config *config.Control, handler http.Handler) (http.Handler, error)

Register configures a new etcd client and adds db info routes for the http request handler.

func (*ETCD) RemovePeer

func (e *ETCD) RemovePeer(ctx context.Context, name, address string, allowSelfRemoval bool) error

RemovePeer removes a peer from the cluster. The peer name and IP address must both match.

func (*ETCD) RemoveSelf

func (e *ETCD) RemoveSelf(ctx context.Context) error

RemoveSelf will remove the member if it exists in the cluster

func (*ETCD) Reset

func (e *ETCD) Reset(ctx context.Context, rebootstrap func() error) error

Reset resets an etcd node to a single node cluster.

func (*ETCD) Restore

func (e *ETCD) Restore(ctx context.Context) error

Restore performs a restore of the ETCD datastore from the given snapshot path. This operation exists upon completion.

func (*ETCD) SetControlConfig

func (e *ETCD) SetControlConfig(ctx context.Context, config *config.Control) error

SetControlConfig sets the given config on the etcd struct.

func (*ETCD) Snapshot

func (e *ETCD) Snapshot(ctx context.Context, config *config.Control) error

Snapshot attempts to save a new snapshot to the configured directory, and then clean up any old and failed snapshots in excess of the retention limits. This method is used in the internal cron snapshot system as well as used to do on-demand snapshots.

func (*ETCD) Start

func (e *ETCD) Start(ctx context.Context, clientAccessInfo *clientaccess.Info) error

Start starts the datastore

func (*ETCD) StartEmbeddedTemporary

func (e *ETCD) StartEmbeddedTemporary(ctx context.Context) error

func (*ETCD) Test

func (e *ETCD) Test(ctx context.Context) error

Test ensures that the local node is a voting member of the target cluster, and that the datastore is defragmented and not in maintenance mode due to alarms. If it is still a learner or not a part of the cluster, an error is raised. If it cannot be defragmented or has any alarms that cannot be disarmed, an error is raised.

type Members

type Members struct {
	Members []*etcdserverpb.Member `json:"members"`
}

Members contains a slice that holds all members of the cluster.

func ClientURLs

func ClientURLs(ctx context.Context, clientAccessInfo *clientaccess.Info, selfIP string) ([]string, Members, error)

clientURLs returns a list of all non-learner etcd cluster member client access URLs. The list is retrieved from the remote server that is being joined.

type MembershipError

type MembershipError struct {
	Self    string
	Members []string
}

func (*MembershipError) Error

func (e *MembershipError) Error() string

func (*MembershipError) Is

func (e *MembershipError) Is(target error) bool

type NodeControllerGetter

type NodeControllerGetter func() controllerv1.NodeController

type Proxy

type Proxy interface {
	Update(addresses []string)
	ETCDURL() string
	ETCDAddresses() []string
	ETCDServerURL() string
}

func NewETCDProxy

func NewETCDProxy(ctx context.Context, enabled bool, dataDir, etcdURL string, isIPv6 bool) (Proxy, error)

NewETCDProxy initializes a new proxy structure that contain a load balancer which listens on port 2379 and proxy between etcd cluster members

type S3

type S3 struct {
	// contains filtered or unexported fields
}

S3 maintains state for S3 functionality.

func NewS3

func NewS3(ctx context.Context, config *config.Control) (*S3, error)

newS3 creates a new value of type s3 pointer with a copy of the config.Control pointer and initializes a new Minio client.

func (*S3) Download

func (s *S3) Download(ctx context.Context) error

download downloads the given snapshot from the configured S3 compatible backend.

Jump to

Keyboard shortcuts

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