Documentation ¶
Index ¶
- type ActivePodsFunc
- type DeviceRunContainerOptions
- type Manager
- type ManagerImpl
- func (m *ManagerImpl) Allocate(node *schedulercache.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error
- func (m *ManagerImpl) Devices() map[string][]pluginapi.Device
- func (m *ManagerImpl) GetCapacity() (v1.ResourceList, v1.ResourceList, []string)
- func (m *ManagerImpl) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) *DeviceRunContainerOptions
- func (m *ManagerImpl) Register(ctx context.Context, r *pluginapi.RegisterRequest) (*pluginapi.Empty, error)
- func (m *ManagerImpl) Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady) error
- func (m *ManagerImpl) Stop() error
- type ManagerStub
- func (h *ManagerStub) Allocate(node *schedulercache.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error
- func (h *ManagerStub) Devices() map[string][]pluginapi.Device
- func (h *ManagerStub) GetCapacity() (v1.ResourceList, v1.ResourceList, []string)
- func (h *ManagerStub) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) *DeviceRunContainerOptions
- func (h *ManagerStub) Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady) error
- func (h *ManagerStub) Stop() error
- type Stub
- func (m *Stub) Allocate(ctx context.Context, r *pluginapi.AllocateRequest) (*pluginapi.AllocateResponse, error)
- func (m *Stub) ListAndWatch(e *pluginapi.Empty, s pluginapi.DevicePlugin_ListAndWatchServer) error
- func (m *Stub) Register(kubeletEndpoint, resourceName string) error
- func (m *Stub) SetAllocFunc(f stubAllocFunc)
- func (m *Stub) Start() error
- func (m *Stub) Stop() error
- func (m *Stub) Update(devs []*pluginapi.Device)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActivePodsFunc ¶
ActivePodsFunc is a function that returns a list of pods to reconcile.
type DeviceRunContainerOptions ¶
type DeviceRunContainerOptions struct { // The environment variables list. Envs []kubecontainer.EnvVar // The mounts for the container. Mounts []kubecontainer.Mount // The host devices mapped into the container. Devices []kubecontainer.DeviceInfo }
DeviceRunContainerOptions contains the combined container runtime settings to consume its allocated devices.
type Manager ¶
type Manager interface { // Start starts device plugin registration service. Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady) error // Devices is the map of devices that have registered themselves // against the manager. // The map key is the ResourceName of the device plugins. Devices() map[string][]pluginapi.Device // Allocate configures and assigns devices to pods. The pods are provided // through the pod admission attributes in the attrs argument. From the // requested device resources, Allocate will communicate with the owning // device plugin to allow setup procedures to take place, and for the // device plugin to provide runtime settings to use the device (environment // variables, mount points and device files). The node object is provided // for the device manager to update the node capacity to reflect the // currently available devices. Allocate(node *schedulercache.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error // Stop stops the manager. Stop() error // GetDeviceRunContainerOptions checks whether we have cached containerDevices // for the passed-in <pod, container> and returns its DeviceRunContainerOptions // for the found one. An empty struct is returned in case no cached state is found. GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) *DeviceRunContainerOptions // GetCapacity returns the amount of available device plugin resource capacity, resource allocatable // and inactive device plugin resources previously registered on the node. GetCapacity() (v1.ResourceList, v1.ResourceList, []string) }
Manager manages all the Device Plugins running on a node.
type ManagerImpl ¶
type ManagerImpl struct {
// contains filtered or unexported fields
}
ManagerImpl is the structure in charge of managing Device Plugins.
func NewManagerImpl ¶
func NewManagerImpl() (*ManagerImpl, error)
NewManagerImpl creates a new manager.
func (*ManagerImpl) Allocate ¶
func (m *ManagerImpl) Allocate(node *schedulercache.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error
Allocate is the call that you can use to allocate a set of devices from the registered device plugins.
func (*ManagerImpl) Devices ¶
func (m *ManagerImpl) Devices() map[string][]pluginapi.Device
Devices is the map of devices that are known by the Device Plugin manager with the kind of the devices as key
func (*ManagerImpl) GetCapacity ¶
func (m *ManagerImpl) GetCapacity() (v1.ResourceList, v1.ResourceList, []string)
GetCapacity is expected to be called when Kubelet updates its node status. The first returned variable contains the registered device plugin resource capacity. The second returned variable contains the registered device plugin resource allocatable. The third returned variable contains previously registered resources that are no longer active. Kubelet uses this information to update resource capacity/allocatable in its node status. After the call, device plugin can remove the inactive resources from its internal list as the change is already reflected in Kubelet node status. Note in the special case after Kubelet restarts, device plugin resource capacities can temporarily drop to zero till corresponding device plugins re-register. This is OK because cm.UpdatePluginResource() run during predicate Admit guarantees we adjust nodeinfo capacity for already allocated pods so that they can continue to run. However, new pods requiring device plugin resources will not be scheduled till device plugin re-registers.
func (*ManagerImpl) GetDeviceRunContainerOptions ¶
func (m *ManagerImpl) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) *DeviceRunContainerOptions
GetDeviceRunContainerOptions checks whether we have cached containerDevices for the passed-in <pod, container> and returns its DeviceRunContainerOptions for the found one. An empty struct is returned in case no cached state is found.
func (*ManagerImpl) Register ¶
func (m *ManagerImpl) Register(ctx context.Context, r *pluginapi.RegisterRequest) (*pluginapi.Empty, error)
Register registers a device plugin.
func (*ManagerImpl) Start ¶
func (m *ManagerImpl) Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady) error
Start starts the Device Plugin Manager amd start initialization of podDevices and allocatedDevices information from checkpoint-ed state and starts device plugin registration service.
func (*ManagerImpl) Stop ¶
func (m *ManagerImpl) Stop() error
Stop is the function that can stop the gRPC server.
type ManagerStub ¶
type ManagerStub struct{}
ManagerStub provides a simple stub implementation for the Device Manager.
func NewManagerStub ¶
func NewManagerStub() (*ManagerStub, error)
NewManagerStub creates a ManagerStub.
func (*ManagerStub) Allocate ¶
func (h *ManagerStub) Allocate(node *schedulercache.NodeInfo, attrs *lifecycle.PodAdmitAttributes) error
Allocate simply returns nil.
func (*ManagerStub) Devices ¶
func (h *ManagerStub) Devices() map[string][]pluginapi.Device
Devices returns an empty map.
func (*ManagerStub) GetCapacity ¶
func (h *ManagerStub) GetCapacity() (v1.ResourceList, v1.ResourceList, []string)
GetCapacity simply returns nil capacity and empty removed resource list.
func (*ManagerStub) GetDeviceRunContainerOptions ¶
func (h *ManagerStub) GetDeviceRunContainerOptions(pod *v1.Pod, container *v1.Container) *DeviceRunContainerOptions
GetDeviceRunContainerOptions simply returns nil.
func (*ManagerStub) Start ¶
func (h *ManagerStub) Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady) error
Start simply returns nil.
type Stub ¶
type Stub struct {
// contains filtered or unexported fields
}
Stub implementation for DevicePlugin.
func NewDevicePluginStub ¶
NewDevicePluginStub returns an initialized DevicePlugin Stub.
func (*Stub) Allocate ¶
func (m *Stub) Allocate(ctx context.Context, r *pluginapi.AllocateRequest) (*pluginapi.AllocateResponse, error)
Allocate does a mock allocation
func (*Stub) ListAndWatch ¶
ListAndWatch lists devices and update that list according to the Update call
func (*Stub) Register ¶
Register registers the device plugin for the given resourceName with Kubelet.
func (*Stub) SetAllocFunc ¶
func (m *Stub) SetAllocFunc(f stubAllocFunc)
SetAllocFunc sets allocFunc of the device plugin