kubeletplugin

package
v0.33.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 16 Imported by: 13

Documentation

Overview

Package kubeletplugin provides helper functions for running a dynamic resource allocation kubelet plugin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DRAPlugin

type DRAPlugin interface {
	// Stop ensures that all spawned goroutines are stopped and frees
	// resources.
	Stop()

	// RegistrationStatus returns the result of registration, nil if none
	// received yet.
	RegistrationStatus() *registerapi.RegistrationStatus

	// PublishResources may be called one or more times to publish
	// resource information in ResourceSlice objects. If it never gets
	// called, then the kubelet plugin does not manage any ResourceSlice
	// objects.
	//
	// PublishResources does not block, so it might still take a while
	// after it returns before all information is actually written
	// to the API server.
	//
	// It is the responsibility of the caller to ensure that the pools and
	// slices described in the driver resources parameters are valid
	// according to the restrictions defined in the resource.k8s.io API.
	//
	// Invalid ResourceSlices will be rejected by the apiserver during
	// publishing, which happens asynchronously and thus does not
	// get returned as error here. The only error returned here is
	// when publishing was not set up properly, for example missing
	// [KubeClient] or [NodeName] options.
	//
	// The caller may modify the resources after this call returns.
	PublishResources(ctx context.Context, resources resourceslice.DriverResources) error
	// contains filtered or unexported methods
}

DRAPlugin gets returned by Start and defines the public API of the generic dynamic resource allocation plugin.

func Start

func Start(ctx context.Context, nodeServers []interface{}, opts ...Option) (result DRAPlugin, finalErr error)

Start sets up two gRPC servers (one for registration, one for the DRA node client). By default, all APIs implemented by the nodeServer get registered.

The context and/or DRAPlugin.Stop can be used to stop all background activity. Stop also blocks. A logger can be stored in the context to add values or a name to all log entries.

If the plugin will be used to publish resources, KubeClient and NodeName options are mandatory.

The DRA driver decides which gRPC interfaces it implements. At least one implementation of drapbv1alpha4.NodeServer or drapbv1beta1.DRAPluginServer is required. Implementing drapbv1beta1.DRAPluginServer is recommended for DRA driver targeting Kubernetes >= 1.32. To be compatible with Kubernetes 1.31, DRA drivers must implement only drapbv1alpha4.NodeServer.

type Option

type Option func(o *options) error

Option implements the functional options pattern for Start.

func DriverName

func DriverName(driverName string) Option

DriverName defines the driver name for the dynamic resource allocation driver. Must be set.

func GRPCInterceptor

func GRPCInterceptor(interceptor grpc.UnaryServerInterceptor) Option

GRPCInterceptor is called for each incoming gRPC method call. This option may be used more than once and each interceptor will get called.

func GRPCStreamInterceptor added in v0.30.0

func GRPCStreamInterceptor(interceptor grpc.StreamServerInterceptor) Option

GRPCStreamInterceptor is called for each gRPC streaming method call. This option may be used more than once and each interceptor will get called.

func GRPCVerbosity

func GRPCVerbosity(level int) Option

GRPCVerbosity sets the verbosity for logging gRPC calls. Default is 4. A negative value disables logging.

func KubeClient added in v0.31.0

func KubeClient(kubeClient kubernetes.Interface) Option

KubeClient grants the plugin access to the API server. This is needed for syncing ResourceSlice objects. It's the responsibility of the DRA driver developer to ensure that this client has permission to read, write, patch and list such objects. It also needs permission to read node objects. Ideally, a validating admission policy should be used to limit write access to ResourceSlices which belong to the node.

func KubeletPluginSocketPath

func KubeletPluginSocketPath(path string) Option

KubeletPluginSocketPath defines how kubelet will connect to the dynamic resource allocation plugin. This corresponds to PluginSocketPath, except that PluginSocketPath defines the path in the filesystem of the caller and KubeletPluginSocketPath in the filesystem of kubelet.

func NodeName added in v0.31.0

func NodeName(nodeName string) Option

NodeName tells the plugin on which node it is running. This is needed for syncing ResourceSlice objects.

func NodeUID added in v0.31.0

func NodeUID(nodeUID types.UID) Option

NodeUID tells the plugin the UID of the v1.Node object. This is used when syncing ResourceSlice objects, but doesn't have to be used. If not supplied, the controller will look up the object once.

func NodeV1alpha4 added in v0.32.0

func NodeV1alpha4(enabled bool) Option

NodeV1alpha4 explicitly chooses whether the DRA gRPC API v1alpha4 gets enabled.

func NodeV1beta1 added in v0.32.0

func NodeV1beta1(enabled bool) Option

NodeV1beta1 explicitly chooses whether the DRA gRPC API v1beta1 gets enabled.

func PluginListener

func PluginListener(listener net.Listener) Option

PluginListener sets an already created listener for the dynamic resource allocation plugin API. Can be combined with PluginSocketPath.

At least one of these two options is required.

func PluginSocketPath

func PluginSocketPath(path string) Option

PluginSocketPath sets the file path for a Unix domain socket. If PluginListener is not used, then Start will remove a file at that path, should one exist, and creates a socket itself. Otherwise it uses the provided listener and only removes the socket at the specified path during shutdown.

At least one of these two options is required.

func RegistrarListener

func RegistrarListener(listener net.Listener) Option

RegistrarListener sets an already created listener for the plugin registration API. Can be combined with RegistrarSocketPath.

At least one of these two options is required.

func RegistrarSocketPath

func RegistrarSocketPath(path string) Option

RegistrarSocketPath sets the file path for a Unix domain socket. If RegistrarListener is not used, then Start will remove a file at that path, should one exist, and creates a socket itself. Otherwise it uses the provided listener and only removes the socket at the specified path during shutdown.

At least one of these two options is required.

Jump to

Keyboard shortcuts

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