mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Add scheduler predicate to filter for max Azure disks attached
This commit is contained in:
parent
b3d627c2e2
commit
73a0083a84
@ -349,6 +349,23 @@ var GCEPDVolumeFilter VolumeFilter = VolumeFilter{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AzureDiskVolumeFilter is a VolumeFilter for filtering Azure Disk Volumes
|
||||||
|
var AzureDiskVolumeFilter VolumeFilter = VolumeFilter{
|
||||||
|
FilterVolume: func(vol *v1.Volume) (string, bool) {
|
||||||
|
if vol.AzureDisk != nil {
|
||||||
|
return vol.AzureDisk.DiskName, true
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
},
|
||||||
|
|
||||||
|
FilterPersistentVolume: func(pv *v1.PersistentVolume) (string, bool) {
|
||||||
|
if pv.Spec.AzureDisk != nil {
|
||||||
|
return pv.Spec.AzureDisk.DiskName, true
|
||||||
|
}
|
||||||
|
return "", false
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
type VolumeZoneChecker struct {
|
type VolumeZoneChecker struct {
|
||||||
pvInfo PersistentVolumeInfo
|
pvInfo PersistentVolumeInfo
|
||||||
pvcInfo PersistentVolumeClaimInfo
|
pvcInfo PersistentVolumeClaimInfo
|
||||||
|
@ -138,6 +138,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
|
|||||||
{"name": "NoVolumeZoneConflict"},
|
{"name": "NoVolumeZoneConflict"},
|
||||||
{"name": "MaxEBSVolumeCount"},
|
{"name": "MaxEBSVolumeCount"},
|
||||||
{"name": "MaxGCEPDVolumeCount"},
|
{"name": "MaxGCEPDVolumeCount"},
|
||||||
|
{"name": "MaxAzureDiskVolumeCount"},
|
||||||
{"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
|
{"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
|
||||||
{"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
|
{"name": "TestLabelsPresence", "argument": {"labelsPresence" : {"labels" : ["foo"], "presence":true}}}
|
||||||
],"priorities": [
|
],"priorities": [
|
||||||
@ -161,6 +162,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
|
|||||||
{Name: "NoVolumeZoneConflict"},
|
{Name: "NoVolumeZoneConflict"},
|
||||||
{Name: "MaxEBSVolumeCount"},
|
{Name: "MaxEBSVolumeCount"},
|
||||||
{Name: "MaxGCEPDVolumeCount"},
|
{Name: "MaxGCEPDVolumeCount"},
|
||||||
|
{Name: "MaxAzureDiskVolumeCount"},
|
||||||
{Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
|
{Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
|
||||||
{Name: "TestLabelsPresence", Argument: &schedulerapi.PredicateArgument{LabelsPresence: &schedulerapi.LabelsPresence{Labels: []string{"foo"}, Presence: true}}},
|
{Name: "TestLabelsPresence", Argument: &schedulerapi.PredicateArgument{LabelsPresence: &schedulerapi.LabelsPresence{Labels: []string{"foo"}, Presence: true}}},
|
||||||
},
|
},
|
||||||
@ -194,6 +196,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
|
|||||||
{"name": "CheckNodeMemoryPressure"},
|
{"name": "CheckNodeMemoryPressure"},
|
||||||
{"name": "MaxEBSVolumeCount"},
|
{"name": "MaxEBSVolumeCount"},
|
||||||
{"name": "MaxGCEPDVolumeCount"},
|
{"name": "MaxGCEPDVolumeCount"},
|
||||||
|
{"name": "MaxAzureDiskVolumeCount"},
|
||||||
{"name": "MatchInterPodAffinity"},
|
{"name": "MatchInterPodAffinity"},
|
||||||
{"name": "GeneralPredicates"},
|
{"name": "GeneralPredicates"},
|
||||||
{"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
|
{"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
|
||||||
@ -221,6 +224,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
|
|||||||
{Name: "CheckNodeMemoryPressure"},
|
{Name: "CheckNodeMemoryPressure"},
|
||||||
{Name: "MaxEBSVolumeCount"},
|
{Name: "MaxEBSVolumeCount"},
|
||||||
{Name: "MaxGCEPDVolumeCount"},
|
{Name: "MaxGCEPDVolumeCount"},
|
||||||
|
{Name: "MaxAzureDiskVolumeCount"},
|
||||||
{Name: "MatchInterPodAffinity"},
|
{Name: "MatchInterPodAffinity"},
|
||||||
{Name: "GeneralPredicates"},
|
{Name: "GeneralPredicates"},
|
||||||
{Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
|
{Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
|
||||||
@ -257,6 +261,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
|
|||||||
{"name": "CheckNodeDiskPressure"},
|
{"name": "CheckNodeDiskPressure"},
|
||||||
{"name": "MaxEBSVolumeCount"},
|
{"name": "MaxEBSVolumeCount"},
|
||||||
{"name": "MaxGCEPDVolumeCount"},
|
{"name": "MaxGCEPDVolumeCount"},
|
||||||
|
{"name": "MaxAzureDiskVolumeCount"},
|
||||||
{"name": "MatchInterPodAffinity"},
|
{"name": "MatchInterPodAffinity"},
|
||||||
{"name": "GeneralPredicates"},
|
{"name": "GeneralPredicates"},
|
||||||
{"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
|
{"name": "TestServiceAffinity", "argument": {"serviceAffinity" : {"labels" : ["region"]}}},
|
||||||
@ -287,6 +292,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
|
|||||||
{Name: "CheckNodeDiskPressure"},
|
{Name: "CheckNodeDiskPressure"},
|
||||||
{Name: "MaxEBSVolumeCount"},
|
{Name: "MaxEBSVolumeCount"},
|
||||||
{Name: "MaxGCEPDVolumeCount"},
|
{Name: "MaxGCEPDVolumeCount"},
|
||||||
|
{Name: "MaxAzureDiskVolumeCount"},
|
||||||
{Name: "MatchInterPodAffinity"},
|
{Name: "MatchInterPodAffinity"},
|
||||||
{Name: "GeneralPredicates"},
|
{Name: "GeneralPredicates"},
|
||||||
{Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
|
{Name: "TestServiceAffinity", Argument: &schedulerapi.PredicateArgument{ServiceAffinity: &schedulerapi.ServiceAffinity{Labels: []string{"region"}}}},
|
||||||
|
@ -37,6 +37,8 @@ import (
|
|||||||
const (
|
const (
|
||||||
// GCE instances can have up to 16 PD volumes attached.
|
// GCE instances can have up to 16 PD volumes attached.
|
||||||
DefaultMaxGCEPDVolumes = 16
|
DefaultMaxGCEPDVolumes = 16
|
||||||
|
// Larger Azure VMs can actually have much more disks attached. TODO We should determine the max based on VM size
|
||||||
|
DefaultMaxAzureDiskVolumes = 16
|
||||||
ClusterAutoscalerProvider = "ClusterAutoscalerProvider"
|
ClusterAutoscalerProvider = "ClusterAutoscalerProvider"
|
||||||
StatefulSetKind = "StatefulSet"
|
StatefulSetKind = "StatefulSet"
|
||||||
)
|
)
|
||||||
@ -136,6 +138,15 @@ func defaultPredicates() sets.String {
|
|||||||
return predicates.NewMaxPDVolumeCountPredicate(predicates.GCEPDVolumeFilter, maxVols, args.PVInfo, args.PVCInfo)
|
return predicates.NewMaxPDVolumeCountPredicate(predicates.GCEPDVolumeFilter, maxVols, args.PVInfo, args.PVCInfo)
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
// Fit is determined by whether or not there would be too many Azure Disk volumes attached to the node
|
||||||
|
factory.RegisterFitPredicateFactory(
|
||||||
|
"MaxAzureDiskVolumeCount",
|
||||||
|
func(args factory.PluginFactoryArgs) algorithm.FitPredicate {
|
||||||
|
// TODO: allow for generically parameterized scheduler predicates, because this is a bit ugly
|
||||||
|
maxVols := getMaxVols(DefaultMaxAzureDiskVolumes)
|
||||||
|
return predicates.NewMaxPDVolumeCountPredicate(predicates.AzureDiskVolumeFilter, maxVols, args.PVInfo, args.PVCInfo)
|
||||||
|
},
|
||||||
|
),
|
||||||
// Fit is determined by inter-pod affinity.
|
// Fit is determined by inter-pod affinity.
|
||||||
factory.RegisterFitPredicateFactory(
|
factory.RegisterFitPredicateFactory(
|
||||||
"MatchInterPodAffinity",
|
"MatchInterPodAffinity",
|
||||||
|
Loading…
Reference in New Issue
Block a user