Documentation ¶
Overview ¶
Package ksr implements plugin that watches K8s resources and causes all changes to be reflected in the ETCD data store.
Index ¶
- Constants
- Variables
- type Deps
- type DsItems
- type EndpointsReflector
- type EtcdMonitor
- type K8sClientGetter
- type K8sListWatcher
- type K8sToProtoConverter
- type KeyProtoValBroker
- type NamespaceReflector
- type NodeReflector
- type Option
- type Plugin
- type PodReflector
- type PolicyReflector
- type ProtoAllocator
- type Reflector
- type ReflectorFunctions
- type ReflectorRegistry
- type ServiceReflector
- type StatsCollector
Constants ¶
const ( // ConfigFlagName is name of the flag that defines kubeconfig location ConfigFlagName = "kube-config" // MicroserviceLabel is the microservice label used by contiv-ksr. MicroserviceLabel = "contiv-ksr" // KubeConfigAdmin is the default location of kubeconfig with admin credentials. KubeConfigAdmin = "/etc/kubernetes/admin.conf" // KubeConfigUsage explains the purpose of 'kube-config' flag. KubeConfigUsage = "Path to the kubeconfig file to use for the client connection to K8s cluster" )
Variables ¶
var DefaultPlugin = *NewPlugin()
DefaultPlugin is default instance of Plugin.
var MockK8sCache = &cache.FakeCustomStore{}
MockK8sCache holds the k8s mock cache
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct { infra.PluginDeps ServiceLabel servicelabel.ReaderAPI // Kubeconfig with k8s cluster address and access credentials to use. KubeConfig config.PluginConfig // broker is used to propagate changes into a key-value datastore. // contiv-ksr uses ETCD as datastore. Publish *kvdbsync.Plugin // Prometheus used to publish statistics Prometheus *prometheus.Plugin }
Deps defines dependencies of ksr plugin.
type DsItems ¶
type DsItems map[string]interface{}
DsItems defines the structure holding items listed from the data store.
type EndpointsReflector ¶
type EndpointsReflector struct {
Reflector
}
EndpointsReflector subscribes to K8s cluster to watch for changes in the configuration of k8s service endpoints. Protobuf-modelled changes are published into the selected key-value store.
type EtcdMonitor ¶
type EtcdMonitor struct {
// contains filtered or unexported fields
}
EtcdMonitor defines the state data for the Etcd Monitor
type K8sClientGetter ¶
type K8sClientGetter func(*kubernetes.Clientset) rest.Interface
K8sClientGetter defines the signature for a function that allocates a REST client for a given K8s data type
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 K8sToProtoConverter ¶
K8sToProtoConverter defines the signature for a function converting k8s objects to KSR protobuf objects.
type KeyProtoValBroker ¶
type KeyProtoValBroker 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) // GetValue reads a value from etcd stored under the given key. GetValue(key string, reqObj proto.Message) (found bool, revision int64, err error) // List values stored in etcd under the given prefix. ListValues(prefix string) (keyval.ProtoKeyValIterator, error) }
KeyProtoValBroker defines KSR's interface to the key-value data store. It defines a subset of operations from a generic cn-infra broker interface (keyval.ProtoBroker in cn-infra).
type NamespaceReflector ¶
type NamespaceReflector struct {
Reflector
}
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.
type NodeReflector ¶
type NodeReflector struct { Reflector // contains filtered or unexported fields }
NodeReflector subscribes to K8s cluster to watch for changes in the configuration of k8s nodes. Protobuf-modelled changes are published into the selected key-value store.
type Option ¶
type Option func(*Plugin)
Option is a function that acts on a Plugin to inject Dependencies or configuration
type Plugin ¶
type Plugin struct { Deps StatusMonitor statuscheck.StatusReader StatsCollector StatsCollector // contains filtered or unexported fields }
Plugin watches K8s resources and causes all changes to be reflected in the ETCD data store.
type PodReflector ¶
type PodReflector struct {
Reflector
}
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.
type PolicyReflector ¶
type PolicyReflector struct {
Reflector
}
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.
type ProtoAllocator ¶
ProtoAllocator defines the signature for a protobuf message allocation function
type Reflector ¶
type Reflector struct { // Each reflector gets a separate child logger. Log logging.Logger // A K8s client gets the appropriate REST client. K8sClientset *kubernetes.Clientset // K8s List-Watch watches for Kubernetes config changes. K8sListWatch K8sListWatcher // broker is the interface to a key-val data store. Broker KeyProtoValBroker // reflector registry *ReflectorRegistry // contains filtered or unexported fields }
Reflector holds data that is common to all KSR reflectors.
type ReflectorFunctions ¶
type ReflectorFunctions struct { EventHdlrFunc cache.ResourceEventHandlerFuncs ProtoAllocFunc ProtoAllocator K8s2NodeFunc K8sToProtoConverter K8sClntGetFunc K8sClientGetter }
ReflectorFunctions defines the function types required in the KSR reflector
type ReflectorRegistry ¶
type ReflectorRegistry struct {
// contains filtered or unexported fields
}
ReflectorRegistry defines the data structures for the KSR Reflector Registry
type ServiceReflector ¶
type ServiceReflector struct {
Reflector
}
ServiceReflector subscribes to K8s cluster to watch for changes in the configuration of k8s services. Protobuf-modelled changes are published into the selected key-value store.
type StatsCollector ¶
type StatsCollector struct { Log logging.Logger Prometheus prometheusplugin.API // contains filtered or unexported fields }
StatsCollector defines the data structures for the KSR Stats Collector
func (*StatsCollector) Init ¶
func (ksc *StatsCollector) Init() error
Init initializes the KSR Statistics Collector
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
model
|
|
endpoints
Package endpoints is a generated protocol buffer package.
|
Package endpoints is a generated protocol buffer package. |
ksrapi
Package ksrapi is a generated protocol buffer package.
|
Package ksrapi is a generated protocol buffer package. |
namespace
Package namespace is a generated protocol buffer package.
|
Package namespace is a generated protocol buffer package. |
node
Package node is a generated protocol buffer package.
|
Package node 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. |
service
Package service is a generated protocol buffer package.
|
Package service is a generated protocol buffer package. |