pluginwatcher

package
v1.13.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

README

This folder contains a utility, pluginwatcher, for Kubelet to register
different types of node-level plugins such as device plugins or CSI plugins.
It discovers plugins by monitoring inotify events under the directory returned by
kubelet.getPluginsDir(). Lets refer this directory as PluginsSockDir.
For any discovered plugin, pluginwatcher issues Registration.GetInfo grpc call
to get plugin type, name and supported service API versions. For any registered plugin type,
pluginwatcher calls the registered callback function with the received plugin
name, supported service API versions, and the full socket path. The Kubelet
component that receives this callback can acknowledge or reject the plugin
according to its own logic, and use the socket path to establish its service
communication with any API version supported by the plugin.

Here are the general rules that Kubelet plugin developers should follow:
- Run as 'root' user. Currently creating socket under PluginsSockDir, a root owned directory, requires
  plugin process to be running as 'root'.

- Implements the Registration service specified in
  pkg/kubelet/apis/pluginregistration/v*/api.proto.

- The plugin name sent during Registration.GetInfo grpc should be unique
  for the given plugin type (CSIPlugin or DevicePlugin).

- The socket path needs to be unique within one directory, in normal case, 
  each plugin type has its own sub directory, but the design does support socket file
  under any sub directory of PluginSockDir.
 
- A plugin should clean up its own socket upon exiting or when a new instance
  comes up. A plugin should NOT remove any sockets belonging to other plugins.

- A plugin should make sure it has service ready for any supported service API
  version listed in the PluginInfo.

- For an example plugin implementation, take a look at example_plugin.go
  included in this directory.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewExampleHandler added in v1.12.0

func NewExampleHandler() *exampleHandler

NewExampleHandler provide a example handler

func NewExamplePlugin

func NewExamplePlugin() *examplePlugin

NewExamplePlugin returns an initialized examplePlugin instance

func NewTestExamplePlugin

func NewTestExamplePlugin(pluginName string, pluginType string, endpoint string) *examplePlugin

NewTestExamplePlugin returns an initialized examplePlugin instance for testing

Types

type RegisterCallbackFn

type RegisterCallbackFn func(pluginName string, endpoint string, versions []string, socketPath string) (chan bool, error)

RegisterCallbackFn is the type of the callback function that handlers will provide

type Watcher

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

Watcher is the plugin watcher

func NewWatcher

func NewWatcher(sockDir string) Watcher

NewWatcher provides a new watcher

func (*Watcher) AddHandler

func (w *Watcher) AddHandler(pluginType string, handlerCbkFn RegisterCallbackFn)

AddHandler registers a callback to be invoked for a particular type of plugin

func (*Watcher) Cleanup

func (w *Watcher) Cleanup() error

Cleanup cleans the path by removing sockets

func (*Watcher) Start

func (w *Watcher) Start() error

Start watches for the creation of plugin sockets at the path

func (*Watcher) Stop

func (w *Watcher) Stop() error

Stop stops probing the creation of plugin sockets at the path

Directories

Path Synopsis
example_plugin_apis
v1beta1
Package v1beta1 is a generated protocol buffer package.
Package v1beta1 is a generated protocol buffer package.
v1beta2
Package v1beta2 is a generated protocol buffer package.
Package v1beta2 is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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