etcd

package
v0.2.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StorageBinaryMediaType = "application/vnd.kubernetes.storagebinary"
	ProtobufMediaType      = "application/vnd.kubernetes.protobuf"
	YamlMediaType          = "application/yaml"
	JSONMediaType          = "application/json"

	ProtobufShortname = "proto"
	YamlShortname     = "yaml"
	JSONShortname     = "json"
)
View Source
const (
	DefaultDialTimeout      = 3 * time.Second
	DefaultCommandTimeOut   = 10 * time.Second
	DefaultKeepAliveTime    = 10 * time.Second
	DefaultKeepAliveTimeOut = 30 * time.Second

	CliCertFile = "client.pem"
	CliKeyFile  = "client-key.pem"
	CliCAFile   = "ca.pem"
	CliUsername = "username"
	CliPassword = "password"
)
View Source
const (
	EtcdV2Backend = "v2"
	EtcdV3Backend = "v3"
)

Variables

View Source
var MediaTypeList = []string{JSONMediaType, YamlMediaType}
View Source
var ProtoEncodingPrefix = []byte{0x6b, 0x38, 0x73, 0x00}

ProtoEncodingPrefix ... see k8s.io/apimachinery/pkg/runtime/serializer/protobuf.go

Functions

func AddMemberWithCmd

func AddMemberWithCmd(isLearner bool, endpoints, peerURL, ca, cert, key string) error

func AlarmList

func AlarmList(cli *clientv3.Client) (*clientv3.AlarmResponse, error)

AlarmList list etcd alarm

func ConvertToData

func ConvertToData(inMediaType string, in []byte) (map[string]string, error)

ConvertToData converts content input to data with inMediaType

func ConvertToJSON

func ConvertToJSON(kv *mvccpb.KeyValue) string

ConvertToJSON converts kv to json string

func DecodeRawToString

func DecodeRawToString(in []byte) string

DecodeRawToString decodes the raw payload bytes contained within the 'Unknown' protobuf envelope of the given storage data.

func DecodeUnknown

func DecodeUnknown(in []byte) (*runtime.Unknown, error)

DecodeUnknown decodes the Unknown protobuf type from the given storage data.

func DetectAndExtract

func DetectAndExtract(in []byte) (string, []byte, error)

DetectAndExtract searches the start of either json of protobuf data, and, if found, returns the mime type and data.

func GetTLSConfigPath

func GetTLSConfigPath(clusterName string, certData, keyData, caData []byte) (string, string, string, error)

func MemberHealthy

func MemberHealthy(endpoint string, cli *ClientConfig) (bool, error)

MemberHealthy checks healthy of member

func MemberList

func MemberList(cli *clientv3.Client) (*clientv3.MemberListResponse, error)

MemberList gets etcd members

func NewClientv3

func NewClientv3(config *ClientConfig) (*clientv3.Client, error)

NewClientv3 generates etcd client v3

func NewShortConnectionClientv2

func NewShortConnectionClientv2(config *ClientConfig) (*clientv2.Client, error)

func Secret

func Secret(t *ClientConfigSecret, namespace, secretName string) (*v1.Secret, error)

func SecretCache

func SecretCache(t *ClientConfigSecret, namespace, secretName string) (*v1.Secret, error)

func Status

func Status(endpoint string, cli *clientv3.Client) (*clientv3.StatusResponse, error)

Status returns new status

Types

type ClientConfig

type ClientConfig struct {
	// Endpoints is a list of URLs.
	Endpoints []string

	// DialTimeout is the timeout for failing to establish a connection.
	DialTimeout time.Duration

	// DialKeepAliveTime is the time after which client pings the server to see if
	// transport is alive.
	DialKeepAliveTime time.Duration

	// DialKeepAliveTimeout is the time that the client waits for a response for the
	// keep-alive probe. If the response is not received in this time, the connection is closed.
	DialKeepAliveTimeout time.Duration

	// SecureConfig is secure config for authentication
	SecureConfig
}

type ClientConfigGetter

type ClientConfigGetter interface {
	New(path string, sc string) (*ClientConfig, error)
}

type ClientConfigSecret

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

func NewClientConfigSecretCacheGetter

func NewClientConfigSecretCacheGetter(secretLister listerscorev1.SecretLister) *ClientConfigSecret

func NewClientConfigSecretGetter

func NewClientConfigSecretGetter(clientBuilder util.ClientBuilder) *ClientConfigSecret

func (*ClientConfigSecret) New

func (t *ClientConfigSecret) New(path string, sc string) (*ClientConfig, error)

type Health

type Health interface {

	// Init creates etcd healthcheck client
	Init(ca, cert, key, endpoint string) error

	// IsHealthy checks etcd health info
	IsHealthy() error

	// Version returns etcd version
	Version() (string, error)

	// Stats returns etcd status
	Stats() (*Stats, error)

	// Close closes etcd healthcheck client
	Close() error
}

func NewEtcdHealthCheckBackend

func NewEtcdHealthCheckBackend(method HealthCheckMethod) (Health, error)

NewEtcdHealthCheckBackend generates etcd healthcheck client

type HealthCheckHTTPClient

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

HealthCheckHTTPClient struct of etcd healthcheck client

func (*HealthCheckHTTPClient) Close

func (c *HealthCheckHTTPClient) Close() error

Close closes etcd healthcheck client

func (*HealthCheckHTTPClient) GetByAPI

func (c *HealthCheckHTTPClient) GetByAPI(path string) ([]byte, error)

func (*HealthCheckHTTPClient) Init

func (c *HealthCheckHTTPClient) Init(ca, cert, key, endpoint string) error

Init creates etcd healthcheck client

func (*HealthCheckHTTPClient) IsHealthy

func (c *HealthCheckHTTPClient) IsHealthy() error

IsHealthy returns etcd healthy info by access etcd endpoint

func (*HealthCheckHTTPClient) Stats

func (c *HealthCheckHTTPClient) Stats() (*Stats, error)

func (*HealthCheckHTTPClient) Version

func (c *HealthCheckHTTPClient) Version() (string, error)

type HealthCheckMethod

type HealthCheckMethod string
const (
	HealthCheckHTTP    HealthCheckMethod = "http"
	HealthCheckEtcdctl HealthCheckMethod = "etcdctl"
)

type SecureConfig

type SecureConfig struct {
	// Cert is a cert for authentication.
	Cert string

	// Key is a key for authentication.
	Key string

	// CaCert is a CA cert for authentication.
	CaCert string

	// Username is a user name for authentication.
	Username string

	// Password is a password for authentication.
	Password string
}

type Stat

type Stat interface {

	// Init create etcd client
	Init(config *ClientConfig) error

	// GetTotalKeyNum counts the number of total keys
	GetTotalKeyNum(ctx context.Context, keyPrefix string) (uint64, error)

	// GetIndex gets the etcd metadata index
	GetIndex(ctx context.Context, endpoint string) (map[featureutil.ConsistencyType]uint64, error)

	// Close close etcd client
	Close() error
}

func NewEtcdStatBackend

func NewEtcdStatBackend(storageBackend string) (Stat, error)

type StatV2

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

func (*StatV2) Close

func (c *StatV2) Close() error

func (*StatV2) GetIndex

func (c *StatV2) GetIndex(ctx context.Context, endpoint string) (map[featureutil.ConsistencyType]uint64, error)

func (*StatV2) GetTotalKeyNum

func (c *StatV2) GetTotalKeyNum(ctx context.Context, keyPrefix string) (uint64, error)

func (*StatV2) Init

func (c *StatV2) Init(config *ClientConfig) error

type StatV3

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

func (*StatV3) Close

func (c *StatV3) Close() error

func (*StatV3) GetIndex

func (c *StatV3) GetIndex(ctx context.Context, endpoint string) (map[featureutil.ConsistencyType]uint64, error)

func (*StatV3) GetTotalKeyNum

func (c *StatV3) GetTotalKeyNum(ctx context.Context, keyPrefix string) (uint64, error)

func (*StatV3) Init

func (c *StatV3) Init(config *ClientConfig) error

type Stats

type Stats struct {
	Name       string `json:"name"`
	ID         string `json:"id"`
	LeaderInfo struct {
		Leader string `json:"leader"`
	} `json:"leaderInfo"`
}

type Version

type Version struct {
	EtcdServer string `json:"etcdserver"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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