Documentation
¶
Overview ¶
Package kubeletplugin provides helper functions for running a dynamic resource allocation kubelet plugin.
Index ¶
- type DRAPlugin
- type Option
- func DriverName(driverName string) Option
- func GRPCInterceptor(interceptor grpc.UnaryServerInterceptor) Option
- func GRPCStreamInterceptor(interceptor grpc.StreamServerInterceptor) Option
- func GRPCVerbosity(level int) Option
- func KubeClient(kubeClient kubernetes.Interface) Option
- func KubeletPluginSocketPath(path string) Option
- func NodeName(nodeName string) Option
- func NodeUID(nodeUID types.UID) Option
- func NodeV1alpha3(enabled bool) Option
- func PluginListener(listener net.Listener) Option
- func PluginSocketPath(path string) Option
- func RegistrarListener(listener net.Listener) Option
- func RegistrarSocketPath(path string) Option
- type Resources
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. // // The caller must not modify the content after the call. // // Returns an error if KubeClient or NodeName options were not // set in Start() to create the DRAPlugin instance. PublishResources(ctx context.Context, resources Resources) 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, nodeServer 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.
type Option ¶
type Option func(o *options) error
Option implements the functional options pattern for Start.
func DriverName ¶
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 ¶
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 ¶
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
NodeName tells the plugin on which node it is running. This is needed for syncing ResourceSlice objects.
func NodeUID ¶ added in v0.31.0
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 NodeV1alpha3 ¶ added in v0.28.0
NodeV1alpha3 explicitly chooses whether the DRA gRPC API v1alpha3 gets enabled.
func PluginListener ¶
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 ¶
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 ¶
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 ¶
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.
type Resources ¶ added in v0.31.0
type Resources struct {
Devices []resourceapi.Device
}
Resources currently only supports devices. Might get extended in the future.