Documentation
¶
Index ¶
- Constants
- Variables
- func AddMemberWithCmd(isLearner bool, endpoints, peerURL, ca, cert, key string) error
- func AlarmList(cli *clientv3.Client) (*clientv3.AlarmResponse, error)
- func ConvertToData(inMediaType string, in []byte) (map[string]string, error)
- func ConvertToJSON(kv *mvccpb.KeyValue) string
- func DecodeRawToString(in []byte) string
- func DecodeUnknown(in []byte) (*runtime.Unknown, error)
- func DetectAndExtract(in []byte) (string, []byte, error)
- func GetTLSConfigPath(clusterName string, certData, keyData, caData []byte) (string, string, string, error)
- func MemberHealthy(endpoint string, cli *ClientConfig) (bool, error)
- func MemberList(cli *clientv3.Client) (*clientv3.MemberListResponse, error)
- func NewClientv3(config *ClientConfig) (*clientv3.Client, error)
- func NewShortConnectionClientv2(config *ClientConfig) (*clientv2.Client, error)
- func Secret(t *ClientConfigSecret, namespace, secretName string) (*v1.Secret, error)
- func SecretCache(t *ClientConfigSecret, namespace, secretName string) (*v1.Secret, error)
- func Status(endpoint string, cli *clientv3.Client) (*clientv3.StatusResponse, error)
- type ClientConfig
- type ClientConfigGetter
- type ClientConfigSecret
- type Health
- type HealthCheckHTTPClient
- func (c *HealthCheckHTTPClient) Close() error
- func (c *HealthCheckHTTPClient) GetByAPI(path string) ([]byte, error)
- func (c *HealthCheckHTTPClient) Init(ca, cert, key, endpoint string) error
- func (c *HealthCheckHTTPClient) IsHealthy() error
- func (c *HealthCheckHTTPClient) Stats() (*Stats, error)
- func (c *HealthCheckHTTPClient) Version() (string, error)
- type HealthCheckMethod
- type SecureConfig
- type Stat
- type StatV2
- type StatV3
- type Stats
- type Version
Constants ¶
const ( StorageBinaryMediaType = "application/vnd.kubernetes.storagebinary" ProtobufMediaType = "application/vnd.kubernetes.protobuf" YamlMediaType = "application/yaml" JSONMediaType = "application/json" ProtobufShortname = "proto" YamlShortname = "yaml" JSONShortname = "json" )
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" )
const ( EtcdV2Backend = "v2" EtcdV3Backend = "v3" )
Variables ¶
var Codecs = kubectlScheme.Codecs
var MediaTypeList = []string{JSONMediaType, YamlMediaType}
var MediaTypeMap = map[string]string{ "raw": StorageBinaryMediaType, ProtobufShortname: ProtobufMediaType, YamlShortname: YamlMediaType, JSONShortname: JSONMediaType, StorageBinaryMediaType: "raw", ProtobufMediaType: ProtobufShortname, YamlMediaType: YamlShortname, JSONMediaType: JSONShortname, }
var ProtoEncodingPrefix = []byte{0x6b, 0x38, 0x73, 0x00}
ProtoEncodingPrefix ... see k8s.io/apimachinery/pkg/runtime/serializer/protobuf.go
Functions ¶
func AddMemberWithCmd ¶
func AlarmList ¶
func AlarmList(cli *clientv3.Client) (*clientv3.AlarmResponse, error)
AlarmList list etcd alarm
func ConvertToData ¶
ConvertToData converts content input to data with inMediaType
func ConvertToJSON ¶
ConvertToJSON converts kv to json string
func DecodeRawToString ¶
DecodeRawToString decodes the raw payload bytes contained within the 'Unknown' protobuf envelope of the given storage data.
func DecodeUnknown ¶
DecodeUnknown decodes the Unknown protobuf type from the given storage data.
func DetectAndExtract ¶
DetectAndExtract searches the start of either json of protobuf data, and, if found, returns the mime type and data.
func GetTLSConfigPath ¶
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 SecretCache ¶
func SecretCache(t *ClientConfigSecret, namespace, secretName string) (*v1.Secret, error)
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 ¶
type StatV2 ¶
type StatV2 struct {
// contains filtered or unexported fields
}
func (*StatV2) GetIndex ¶
func (c *StatV2) GetIndex(ctx context.Context, endpoint string) (map[featureutil.ConsistencyType]uint64, error)
func (*StatV2) GetTotalKeyNum ¶
func (*StatV2) Init ¶
func (c *StatV2) Init(config *ClientConfig) error
type StatV3 ¶
type StatV3 struct {
// contains filtered or unexported fields
}
func (*StatV3) GetIndex ¶
func (c *StatV3) GetIndex(ctx context.Context, endpoint string) (map[featureutil.ConsistencyType]uint64, error)
func (*StatV3) GetTotalKeyNum ¶
func (*StatV3) Init ¶
func (c *StatV3) Init(config *ClientConfig) error