Prioritizing nodes based on volume capacity

This commit is contained in:
Yecheng Fu
2020-11-08 23:00:25 +08:00
parent 61a44d0dbe
commit 21a43586e7
7 changed files with 210 additions and 44 deletions

View File

@@ -82,6 +82,28 @@ type BindingInfo struct {
pv *v1.PersistentVolume
}
// StorageClassName returns the name of the storage class.
func (b *BindingInfo) StorageClassName() string {
return b.pv.Spec.StorageClassName
}
// VolumeResource represents volume resource.
type VolumeResource struct {
Requested int64
Capacity int64
}
// VolumeResource returns volume resource.
func (b *BindingInfo) VolumeResource() *VolumeResource {
// both fields are mandatory
requestedQty := b.pvc.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)]
capacitQty := b.pv.Spec.Capacity[v1.ResourceName(v1.ResourceStorage)]
return &VolumeResource{
Requested: requestedQty.Value(),
Capacity: capacitQty.Value(),
}
}
// PodVolumes holds pod's volumes information used in volume scheduling.
type PodVolumes struct {
// StaticBindings are binding decisions for PVCs which can be bound to