Documentation ¶
Overview ¶
Package app does all of the work necessary to configure and run a Kubernetes app process.
Package app does all of the work necessary to configure and run a Kubernetes app process.
Index ¶
- Variables
- func NewCommand() *cobra.Command
- type AllocateWrapperType
- type ClaimID
- type Device
- type ExampleController
- func (c *ExampleController) Allocate(ctx context.Context, claimAllocations []*controller.ClaimAllocation, ...)
- func (c *ExampleController) Deallocate(ctx context.Context, claim *resourceapi.ResourceClaim) error
- func (c *ExampleController) GetNumAllocations() int64
- func (c *ExampleController) GetNumDeallocations() int64
- func (c *ExampleController) Run(ctx context.Context, workers int)
- func (c *ExampleController) UnsuitableNodes(ctx context.Context, pod *v1.Pod, claims []*controller.ClaimAllocation, ...) (finalErr error)
- type ExamplePlugin
- func (ex *ExamplePlugin) BlockNodePrepareResources() func()
- func (ex *ExamplePlugin) BlockNodeUnprepareResources() func()
- func (ex *ExamplePlugin) CountCalls(methodSuffix string) int
- func (ex *ExamplePlugin) GetGRPCCalls() []GRPCCall
- func (ex *ExamplePlugin) GetPreparedResources() []ClaimID
- func (ex *ExamplePlugin) IsRegistered() bool
- func (ex *ExamplePlugin) NodePrepareResources(ctx context.Context, req *drapb.NodePrepareResourcesRequest) (*drapb.NodePrepareResourcesResponse, error)
- func (ex *ExamplePlugin) NodeUnprepareResources(ctx context.Context, req *drapb.NodeUnprepareResourcesRequest) (*drapb.NodeUnprepareResourcesResponse, error)
- func (ex *ExamplePlugin) SetNodePrepareResourcesFailureMode() func()
- func (ex *ExamplePlugin) SetNodeUnprepareResourcesFailureMode() func()
- func (ex *ExamplePlugin) Stop()
- type FileOperations
- type GRPCCall
- type Resources
Constants ¶
This section is empty.
Variables ¶
var BeRegistered = gcustom.MakeMatcher(func(actualCalls []GRPCCall) (bool, error) { for _, call := range actualCalls { if call.FullMethod == "/pluginregistration.Registration/NotifyRegistrationStatus" && call.Err == nil { return true, nil } } return false, nil }).WithMessage("contain successful NotifyRegistrationStatus call")
BeRegistered checks that plugin registration has completed.
var NodePrepareResourcesFailed = gcustom.MakeMatcher(func(actualCalls []GRPCCall) (bool, error) { for _, call := range actualCalls { if strings.HasSuffix(call.FullMethod, "/NodePrepareResources") && call.Err != nil { return true, nil } } return false, nil }).WithMessage("contain unsuccessful NodePrepareResources call")
NodePrepareResoucesFailed checks that NodePrepareResources API has been called and returned an error
var NodePrepareResourcesSucceeded = gcustom.MakeMatcher(func(actualCalls []GRPCCall) (bool, error) { for _, call := range actualCalls { if strings.HasSuffix(call.FullMethod, "/NodePrepareResources") && call.Response != nil && call.Err == nil { return true, nil } } return false, nil }).WithMessage("contain successful NodePrepareResources call")
NodePrepareResoucesSucceeded checks that NodePrepareResources API has been called and succeeded
var NodeUnprepareResourcesFailed = gcustom.MakeMatcher(func(actualCalls []GRPCCall) (bool, error) { for _, call := range actualCalls { if strings.HasSuffix(call.FullMethod, "/NodeUnprepareResources") && call.Err != nil { return true, nil } } return false, nil }).WithMessage("contain unsuccessful NodeUnprepareResources call")
NodeUnprepareResoucesFailed checks that NodeUnprepareResources API has been called and returned an error
var NodeUnprepareResourcesSucceeded = gcustom.MakeMatcher(func(actualCalls []GRPCCall) (bool, error) { for _, call := range actualCalls { if strings.HasSuffix(call.FullMethod, "/NodeUnprepareResources") && call.Response != nil && call.Err == nil { return true, nil } } return false, nil }).WithMessage("contain successful NodeUnprepareResources call")
NodeUnprepareResoucesSucceeded checks that NodeUnprepareResources API has been called and succeeded
Functions ¶
func NewCommand ¶
NewCommand creates a *cobra.Command object with default parameters.
Types ¶
type AllocateWrapperType ¶
type AllocateWrapperType func(ctx context.Context, claimAllocations []*controller.ClaimAllocation, selectedNode string, handler func(ctx context.Context, claimAllocations []*controller.ClaimAllocation, selectedNode string), )
type ClaimID ¶
ClaimID contains both claim name and UID to simplify debugging. The namespace is not included because it is random in E2E tests and the UID is sufficient to make the ClaimID unique.
type ExampleController ¶
type ExampleController struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(clientset kubernetes.Interface, resources Resources) *ExampleController
func (*ExampleController) Allocate ¶
func (c *ExampleController) Allocate(ctx context.Context, claimAllocations []*controller.ClaimAllocation, selectedNode string)
func (*ExampleController) Deallocate ¶
func (c *ExampleController) Deallocate(ctx context.Context, claim *resourceapi.ResourceClaim) error
func (*ExampleController) GetNumAllocations ¶
func (c *ExampleController) GetNumAllocations() int64
GetNumAllocations returns the number of times that a claim was allocated. Idempotent calls to Allocate that do not need to allocate the claim again do not contribute to that counter.
func (*ExampleController) GetNumDeallocations ¶
func (c *ExampleController) GetNumDeallocations() int64
GetNumDeallocations returns the number of times that a claim was allocated. Idempotent calls to Allocate that do not need to allocate the claim again do not contribute to that counter.
func (*ExampleController) UnsuitableNodes ¶
func (c *ExampleController) UnsuitableNodes(ctx context.Context, pod *v1.Pod, claims []*controller.ClaimAllocation, potentialNodes []string) (finalErr error)
type ExamplePlugin ¶
type ExamplePlugin struct {
// contains filtered or unexported fields
}
func StartPlugin ¶
func StartPlugin(ctx context.Context, cdiDir, driverName string, kubeClient kubernetes.Interface, nodeName string, fileOps FileOperations, opts ...kubeletplugin.Option) (*ExamplePlugin, error)
StartPlugin sets up the servers that are necessary for a DRA kubelet plugin.
func (*ExamplePlugin) BlockNodePrepareResources ¶ added in v1.31.0
func (ex *ExamplePlugin) BlockNodePrepareResources() func()
BlockNodePrepareResources locks blockPrepareResourcesMutex and returns unlocking function for it
func (*ExamplePlugin) BlockNodeUnprepareResources ¶ added in v1.31.0
func (ex *ExamplePlugin) BlockNodeUnprepareResources() func()
BlockNodeUnprepareResources locks blockUnprepareResourcesMutex and returns unlocking function for it
func (*ExamplePlugin) CountCalls ¶ added in v1.31.0
func (ex *ExamplePlugin) CountCalls(methodSuffix string) int
CountCalls counts GRPC calls with the given method suffix.
func (*ExamplePlugin) GetGRPCCalls ¶ added in v1.28.0
func (ex *ExamplePlugin) GetGRPCCalls() []GRPCCall
func (*ExamplePlugin) GetPreparedResources ¶
func (ex *ExamplePlugin) GetPreparedResources() []ClaimID
func (*ExamplePlugin) IsRegistered ¶
func (ex *ExamplePlugin) IsRegistered() bool
func (*ExamplePlugin) NodePrepareResources ¶ added in v1.28.0
func (ex *ExamplePlugin) NodePrepareResources(ctx context.Context, req *drapb.NodePrepareResourcesRequest) (*drapb.NodePrepareResourcesResponse, error)
func (*ExamplePlugin) NodeUnprepareResources ¶ added in v1.28.0
func (ex *ExamplePlugin) NodeUnprepareResources(ctx context.Context, req *drapb.NodeUnprepareResourcesRequest) (*drapb.NodeUnprepareResourcesResponse, error)
func (*ExamplePlugin) SetNodePrepareResourcesFailureMode ¶ added in v1.31.0
func (ex *ExamplePlugin) SetNodePrepareResourcesFailureMode() func()
SetNodePrepareResourcesFailureMode sets the failure mode for NodePrepareResources call and returns a function to unset the failure mode
func (*ExamplePlugin) SetNodeUnprepareResourcesFailureMode ¶ added in v1.31.0
func (ex *ExamplePlugin) SetNodeUnprepareResourcesFailureMode() func()
SetNodeUnprepareResourcesFailureMode sets the failure mode for NodeUnprepareResources call and returns a function to unset the failure mode
func (*ExamplePlugin) Stop ¶
func (ex *ExamplePlugin) Stop()
Stop ensures that all servers are stopped and resources freed.
type FileOperations ¶
type FileOperations struct { // Create must overwrite the file. Create func(name string, content []byte) error // Remove must remove the file. It must not return an error when the // file does not exist. Remove func(name string) error // NumDevices determines whether the plugin reports devices // and how many. It reports nothing if negative. NumDevices int // Pre-defined devices, with each device name mapped to // the device attributes. Not used if NumDevices >= 0. Devices map[string]map[resourceapi.QualifiedName]resourceapi.DeviceAttribute }
FileOperations defines optional callbacks for handling CDI files and some other configuration.
type GRPCCall ¶ added in v1.28.0
type GRPCCall struct { // FullMethod is the fully qualified, e.g. /package.service/method. FullMethod string // Request contains the parameters of the call. Request interface{} // Response contains the reply of the plugin. It is nil for calls that are in progress. Response interface{} // Err contains the error return value of the plugin. It is nil for calls that are in progress or succeeded. Err error }
type Resources ¶
type Resources struct { DriverName string DontSetReservedFor bool NodeLocal bool // Nodes is a fixed list of node names on which resources are // available. Mutually exclusive with NodeLabels. Nodes []string // NodeLabels are labels which determine on which nodes resources are // available. Mutually exclusive with Nodes. NodeLabels labels.Set // Number of devices called "device-000", "device-001", ... on each node or in the cluster. MaxAllocations int // AllocateWrapper, if set, gets called for each Allocate call. AllocateWrapper AllocateWrapperType }