etcd

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 78 Imported by: 0

Documentation

Overview

Package etcd provides a method for operators the data in etcd.

Index

Constants

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

Variables

View Source
var IgnoreKeys = map[string]struct{}{
	"/ranges/serviceips":       {},
	"/ranges/servicenodeports": {},
	"/masterleases/":           {},
	"/peerserverleases/":       {},
}
View Source
var SpecialDefaultMediaTypes = map[string]struct{}{
	"apiextensions.k8s.io":   {},
	"apiregistration.k8s.io": {},
}
View Source
var SpecialDefaultResourcePrefixes = map[schema.GroupResource]string{
	{Group: "", Resource: "replicationcontrollers"}:     "controllers",
	{Group: "", Resource: "endpoints"}:                  "services/endpoints",
	{Group: "", Resource: "services"}:                   "services/specs",
	{Group: "", Resource: "nodes"}:                      "minions",
	{Group: "extensions", Resource: "ingresses"}:        "ingress",
	{Group: "networking.k8s.io", Resource: "ingresses"}: "ingress",
}

SpecialDefaultResourcePrefixes are prefixes compiled into Kubernetes. see k8s.io/kubernetes/pkg/kubeapiserver/default_storage_factory_builder.go

Functions

func AddToScheme

func AddToScheme(scheme *runtime.Scheme)

AddToScheme adds all types of this clientset into the given scheme.

func Convert

func Convert(inMediaType, outMediaType string, in []byte) (*runtime.TypeMeta, []byte, error)

Convert converts the given data from one media type to another.

func DetectMediaType

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

DetectMediaType detects the media type of the given data.

func MediaTypeFromGVR

func MediaTypeFromGVR(gvr schema.GroupVersionResource) (mediaType string, err error)

MediaTypeFromGVR returns the media type of the given GroupVersionResource.

func PatchMetaFromStruct

func PatchMetaFromStruct(gvk schema.GroupVersionKind) (strategicpatch.LookupPatchMeta, error)

PatchMetaFromStruct is a PatchMetaFromStruct implementation that uses strategicpatch.

func PrefixFromGVR

func PrefixFromGVR(gvr schema.GroupVersionResource) (prefix string, err error)

PrefixFromGVR returns the prefix of the given GroupVersionResource.

Types

type Client

type Client interface {
	// Get is a method that retrieves a key-value pair from the etcd server.
	// It returns the revision of the key-value pair
	Get(ctx context.Context, prefix string, opOpts ...OpOption) (rev int64, err error)

	// Watch is a method that watches for changes to a key-value pair on the etcd server.
	Watch(ctx context.Context, prefix string, opOpts ...OpOption) error

	// Delete is a method that deletes a key-value pair from the etcd server.
	Delete(ctx context.Context, prefix string, opOpts ...OpOption) error

	// Put is a method that sets a key-value pair on the etcd server.
	Put(ctx context.Context, prefix string, value []byte, opOpts ...OpOption) error
}

Client is an interface that defines the operations that can be performed on an etcd client.

func NewClient

func NewClient(conf ClientConfig) (Client, error)

NewClient creates a new etcd client.

type ClientConfig

type ClientConfig struct {
	// Endpoints is a list of URLs.
	Endpoints []string
	// TLS holds the client secure credentials, if any.
	TLS *tls.Config
	// Username is a user name for authentication.
	Username string
	// Password is a password for authentication.
	Password string
}

ClientConfig is the etcd client config.

type KeyValue

type KeyValue struct {
	Key       []byte
	Value     []byte
	PrevValue []byte
}

KeyValue is the key-value pair.

type LoadConfig

type LoadConfig struct {
	Clientset clientset.Clientset
	Client    Client
	Prefix    string
}

LoadConfig is the combination of the impersonation config

type Loader

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

Loader loads the resources to cluster This way does not delete existing resources in the cluster, which will Handle the ownerReference so that the resources remain relative to each other

func NewLoader

func NewLoader(loadConfig LoadConfig) (*Loader, error)

NewLoader creates a new snapshot Loader.

func (*Loader) AllowHandle

func (l *Loader) AllowHandle(ctx context.Context) context.CancelFunc

AllowHandle allows the handle to be used

func (*Loader) Load

func (l *Loader) Load(ctx context.Context, decoder *yaml.Decoder) error

Load loads the resources to cluster

func (*Loader) Replay

func (l *Loader) Replay(ctx context.Context, decoder *yaml.Decoder) error

Replay replays the resources to cluster

type Op

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

Op is the option for the operation.

type OpOption

type OpOption func(*Op)

OpOption is the option for the operation.

func WithGVR

WithGVR sets the gvr for the target.

func WithKeysOnly

func WithKeysOnly() OpOption

WithKeysOnly sets the keys only for the target.

func WithName

func WithName(name, namespace string) OpOption

WithName sets the name and namespace for the target.

func WithPageLimit

func WithPageLimit(pageLimit int64) OpOption

WithPageLimit sets the page limit for the target.

func WithResponse

func WithResponse(response func(kv *KeyValue) error) OpOption

WithResponse sets the response callback for the target.

func WithRevision

func WithRevision(revision int64) OpOption

WithRevision sets the revision for the target.

type SaveConfig

type SaveConfig struct {
	Clientset clientset.Clientset
	Client    Client
	Prefix    string
}

SaveConfig is the combination of the impersonation config and the PagerConfig.

type Saver

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

Saver is a snapshot saver.

func NewSaver

func NewSaver(saveConfig SaveConfig) (*Saver, error)

NewSaver creates a new snapshot saver.

func (*Saver) Record

func (s *Saver) Record(ctx context.Context, encoder *yaml.Encoder) error

Record records the snapshot of cluster.

func (*Saver) Save

func (s *Saver) Save(ctx context.Context, encoder *yaml.Encoder) error

Save saves the snapshot of cluster

Jump to

Keyboard shortcuts

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