ksr

package
v0.0.0-...-792cabc Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2017 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package ksr implements plugin that watches K8s resources and causes all changes to be reflected in the ETCD data store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	local.PluginInfraDeps
	// Kubeconfig with k8s cluster address and access credentials to use.
	KubeConfig config.PluginConfig
	// Publish is used to propagate changes into a key-value datastore.
	// contiv-ksr uses ETCD as datastore.
	Publish *kvdbsync.Plugin
}

Deps defines dependencies of ksr plugin.

type K8sListWatcher

type K8sListWatcher interface {
	// NewListWatchFromClient creates a new ListWatch from the specified client, resource, namespace and field selector.
	NewListWatchFromClient(c cache.Getter, resource string, namespace string,
		fieldSelector fields.Selector) *cache.ListWatch

	// NewInformer returns a Store and a Controller for populating the store
	// while also providing event notifications.
	NewInformer(lw cache.ListerWatcher, objType runtime.Object, resyncPeriod time.Duration,
		h cache.ResourceEventHandler) (cache.Store, cache.Controller)
}

K8sListWatcher is used to watch for Kubernetes config changes.

type KeyProtoValWriter

type KeyProtoValWriter interface {
	// Put <data> to ETCD or to any other key-value based data source.
	Put(key string, data proto.Message, opts ...datasync.PutOption) error

	// Delete data under the <key> in ETCD or in any other key-value based data
	// source.
	Delete(key string, opts ...datasync.DelOption) (existed bool, err error)
}

KeyProtoValWriter allows reflectors to push their data changes to a data store. This interface extends the same name interface from cn-infra/datasync with the Delete() operation.

type NamespaceReflector

type NamespaceReflector struct {
	ReflectorDeps
	// contains filtered or unexported fields
}

NamespaceReflector subscribes to K8s cluster to watch for changes in the configuration of k8s namespaces. Protobuf-modelled changes are published into the selected key-value store.

func (*NamespaceReflector) Close

func (nr *NamespaceReflector) Close() error

Close does nothing for this particular reflector.

func (*NamespaceReflector) Init

func (nr *NamespaceReflector) Init(stopCh2 <-chan struct{}, wg *sync.WaitGroup) error

Init subscribes to K8s cluster to watch for changes in the configuration of k8s namespaces. The subscription does not become active until Start() is called.

func (*NamespaceReflector) Start

func (nr *NamespaceReflector) Start()

Start activates the K8s subscription.

type Plugin

type Plugin struct {
	Deps
	// contains filtered or unexported fields
}

Plugin watches K8s resources and causes all changes to be reflected in the ETCD data store.

func (*Plugin) AfterInit

func (plugin *Plugin) AfterInit() error

AfterInit starts all reflectors. They have to be started in AfterInit so that the kvdbsync is fully initialized and ready for publishing when a k8s notification comes.

func (*Plugin) Close

func (plugin *Plugin) Close() error

Close stops all reflectors.

func (*Plugin) Init

func (plugin *Plugin) Init() error

Init builds K8s client-set based on the supplied kubeconfig and initializes all reflectors.

type PodReflector

type PodReflector struct {
	ReflectorDeps
	// contains filtered or unexported fields
}

PodReflector subscribes to K8s cluster to watch for changes in the configuration of k8s pods. Protobuf-modelled changes are published into the selected key-value store.

func (*PodReflector) Close

func (pr *PodReflector) Close() error

Close does nothing for this particular reflector.

func (*PodReflector) Init

func (pr *PodReflector) Init(stopCh2 <-chan struct{}, wg *sync.WaitGroup) error

Init subscribes to K8s cluster to watch for changes in the configuration of k8s pods. The subscription does not become active until Start() is called.

func (*PodReflector) Start

func (pr *PodReflector) Start()

Start activates the K8s subscription.

type PolicyReflector

type PolicyReflector struct {
	ReflectorDeps
	// contains filtered or unexported fields
}

PolicyReflector subscribes to K8s cluster to watch for changes in the configuration of k8s network policies. Protobuf-modelled changes are published into the selected key-value store.

func (*PolicyReflector) Close

func (pr *PolicyReflector) Close() error

Close does nothing for this particular reflector.

func (*PolicyReflector) Init

func (pr *PolicyReflector) Init(stopCh2 <-chan struct{}, wg *sync.WaitGroup) error

Init subscribes to K8s cluster to watch for changes in the configuration of k8s network policies. The subscription does not become active until Start() is called.

func (*PolicyReflector) Start

func (pr *PolicyReflector) Start()

Start activates the K8s subscription.

type ReflectorDeps

type ReflectorDeps struct {
	// Each reflector gets a separate child logger.
	Log logging.Logger
	// A K8s client is used to get the appropriate REST client.
	K8sClientset *kubernetes.Clientset
	// K8s List-Watch is used to watch for Kubernetes config changes.
	K8sListWatch K8sListWatcher
	// Publish is used to propagate changes into a datastore.
	Publish KeyProtoValWriter
}

ReflectorDeps lists dependencies of a reflector regardless of the reflected k8s resource type.

Directories

Path Synopsis
model
namespace
Package namespace is a generated protocol buffer package.
Package namespace is a generated protocol buffer package.
pod
Package pod is a generated protocol buffer package.
Package pod is a generated protocol buffer package.
policy
Package policy is a generated protocol buffer package.
Package policy is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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