type DRAPlugin … type Resources … type Option … // DriverName defines the driver name for the dynamic resource allocation driver. // Must be set. func DriverName(driverName string) Option { … } // GRPCVerbosity sets the verbosity for logging gRPC calls. Default is 4. A negative // value disables logging. func GRPCVerbosity(level int) 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. func RegistrarSocketPath(path string) 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 RegistrarListener(listener net.Listener) 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 PluginSocketPath(path string) 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 PluginListener(listener net.Listener) 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 KubeletPluginSocketPath(path string) 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 GRPCInterceptor(interceptor grpc.UnaryServerInterceptor) 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 GRPCStreamInterceptor(interceptor grpc.StreamServerInterceptor) Option { … } // NodeV1alpha3 explicitly chooses whether the DRA gRPC API v1alpha3 // gets enabled. func NodeV1alpha3(enabled bool) 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 KubeClient(kubeClient kubernetes.Interface) Option { … } // NodeName tells the plugin on which node it is running. This is needed for // syncing ResourceSlice objects. func NodeName(nodeName string) 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 NodeUID(nodeUID types.UID) Option { … } type options … type draPlugin … // 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. func Start(ctx context.Context, nodeServer interface{ … } // Stop implements [DRAPlugin.Stop]. func (d *draPlugin) Stop() { … } // PublishResources implements [DRAPlugin.PublishResources]. Returns en error if // kubeClient or nodeName are unset. func (d *draPlugin) PublishResources(ctx context.Context, resources Resources) error { … } // RegistrationStatus implements [DRAPlugin.RegistrationStatus]. func (d *draPlugin) RegistrationStatus() *registerapi.RegistrationStatus { … } func (d *draPlugin) internal() { … }