Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClaimAllocation ¶
type ClaimAllocation struct {
PodClaimName string
Claim *resourcev1alpha2.ResourceClaim
Class *resourcev1alpha2.ResourceClass
ClaimParameters interface{}
ClassParameters interface{}
// UnsuitableNodes needs to be filled in by the driver when
// Driver.UnsuitableNodes gets called.
UnsuitableNodes []string
}
ClaimAllocation represents information about one particular pod.Spec.ResourceClaim entry.
type Controller ¶
type Controller interface {
// Run starts the controller.
Run(workers int)
}
Controller watches ResourceClaims and triggers allocation and deallocation as needed.
func New ¶
func New( ctx context.Context, name string, driver Driver, kubeClient kubernetes.Interface, informerFactory informers.SharedInformerFactory) Controller
New creates a new controller.
type Driver ¶
type Driver interface {
// GetClassParameters gets called to retrieve the parameter object
// referenced by a class. The content should be validated now if
// possible. class.Parameters may be nil.
//
// The caller will wrap the error to include the parameter reference.
GetClassParameters(ctx context.Context, class *resourcev1alpha2.ResourceClass) (interface{}, error)
// GetClaimParameters gets called to retrieve the parameter object
// referenced by a claim. The content should be validated now if
// possible. claim.Spec.Parameters may be nil.
//
// The caller will wrap the error to include the parameter reference.
GetClaimParameters(ctx context.Context, claim *resourcev1alpha2.ResourceClaim, class *resourcev1alpha2.ResourceClass, classParameters interface{}) (interface{}, error)
// Allocate gets called when a ResourceClaim is ready to be allocated.
// The selectedNode is empty for ResourceClaims with immediate
// allocation, in which case the resource driver decides itself where
// to allocate. If there is already an on-going allocation, the driver
// may finish it and ignore the new parameters or abort the on-going
// allocation and try again with the new parameters.
//
// Parameters have been retrieved earlier.
//
// If selectedNode is set, the driver must attempt to allocate for that
// node. If that is not possible, it must return an error. The
// controller will call UnsuitableNodes and pass the new information to
// the scheduler, which then will lead to selecting a diffent node
// if the current one is not suitable.
//
// The objects are read-only and must not be modified. This call
// must be idempotent.
Allocate(ctx context.Context, claim *resourcev1alpha2.ResourceClaim, claimParameters interface{}, class *resourcev1alpha2.ResourceClass, classParameters interface{}, selectedNode string) (*resourcev1alpha2.AllocationResult, error)
// Deallocate gets called when a ResourceClaim is ready to be
// freed.
//
// The claim is read-only and must not be modified. This call must be
// idempotent. In particular it must not return an error when the claim
// is currently not allocated.
//
// Deallocate may get called when a previous allocation got
// interrupted. Deallocate must then stop any on-going allocation
// activity and free resources before returning without an error.
Deallocate(ctx context.Context, claim *resourcev1alpha2.ResourceClaim) error
// UnsuitableNodes checks all pending claims with delayed allocation
// for a pod. All claims are ready for allocation by the driver
// and parameters have been retrieved.
//
// The driver may consider each claim in isolation, but it's better
// to mark nodes as unsuitable for all claims if it not all claims
// can be allocated for it (for example, two GPUs requested but
// the node only has one).
//
// The result of the check is in ClaimAllocation.UnsuitableNodes.
// An error indicates that the entire check must be repeated.
UnsuitableNodes(ctx context.Context, pod *v1.Pod, claims []*ClaimAllocation, potentialNodes []string) error
}
Driver provides the actual allocation and deallocation operations.
Click to show internal directories.
Click to hide internal directories.