Documentation
¶
Index ¶
- Constants
- Variables
- func AddUnsetLabelsToMap(aL map[string]string, labelsToAdd []string, labelSet labels.Set)
- func CreateSelectorFromLabels(aL map[string]string) labels.Selector
- func FilterPodsByNamespace(pods []*v1.Pod, ns string) []*v1.Pod
- func FindLabelsInSet(labelsToKeep []string, selector labels.Set) map[string]string
- func GetPodAffinityTerms(podAffinity *v1.PodAffinity) (terms []v1.PodAffinityTerm)
- func GetPodAntiAffinityTerms(podAntiAffinity *v1.PodAntiAffinity) (terms []v1.PodAffinityTerm)
- func GetResourceRequest(pod *v1.Pod) *schedulernodeinfo.Resource
- func GetVolumeLimitKey(filterType string) v1.ResourceName
- func NodeLabelsMatchSpreadConstraints(nodeLabels map[string]string, constraints []v1.TopologySpreadConstraint) bool
- func Ordering() []string
- func PodMatchesNodeSelectorAndAffinityTerms(pod *v1.Pod, node *v1.Node) bool
- func PodMatchesSpreadConstraint(podLabelSet labels.Set, constraint v1.TopologySpreadConstraint) (bool, error)
- func RegisterPredicateMetadataProducer(predicateName string, precomp predicateMetadataProducer)
- func RegisterPredicateMetadataProducerWithExtendedResourceOptions(ignoredExtendedResources sets.String)
- func SetPredicatesOrderingDuringTest(value []string) func()
- type CSIMaxVolumeLimitChecker
- type CSINodeInfo
- type CachedCSINodeInfo
- type CachedPersistentVolumeClaimInfo
- type CachedPersistentVolumeInfo
- type CachedStorageClassInfo
- type FailureReason
- type FakeCSINodeInfo
- type FakeNodeInfo
- type FakeNodeListInfo
- type FakePersistentVolumeClaimInfo
- type FakePersistentVolumeInfo
- type FakeStorageClassInfo
- type FitPredicate
- func NewCSIMaxVolumeLimitPredicate(csiNodeInfo CSINodeInfo, pvInfo PersistentVolumeInfo, ...) FitPredicate
- func NewMaxPDVolumeCountPredicate(filterName string, csiNodeInfo CSINodeInfo, scInfo StorageClassInfo, ...) FitPredicate
- func NewNodeLabelPredicate(labels []string, presence bool) FitPredicate
- func NewPodAffinityPredicate(info NodeInfo, podLister algorithm.PodLister) FitPredicate
- func NewServiceAffinityPredicate(podLister algorithm.PodLister, serviceLister corelisters.ServiceLister, ...) (FitPredicate, predicateMetadataProducer)
- func NewVolumeBindingPredicate(binder *volumebinder.VolumeBinder) FitPredicate
- func NewVolumeZonePredicate(pvInfo PersistentVolumeInfo, pvcInfo PersistentVolumeClaimInfo, ...) FitPredicate
- type InTreeToCSITranslator
- type InsufficientResourceError
- type MaxPDVolumeCountChecker
- type NodeInfo
- type NodeLabelChecker
- type PersistentVolumeClaimInfo
- type PersistentVolumeInfo
- type PodAffinityChecker
- type PredicateFailureError
- type PredicateFailureReason
- func CheckNodeUnschedulablePredicate(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
- func EssentialPredicates(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
- func EvenPodsSpreadPredicate(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
- func GeneralPredicates(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
- func NoDiskConflict(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
- func PodFitsHost(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
- func PodFitsHostPorts(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
- func PodFitsResources(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
- func PodMatchNodeSelector(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
- func PodToleratesNodeNoExecuteTaints(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
- func PodToleratesNodeTaints(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
- func UnresolvablePredicateExists(reasons []PredicateFailureReason) PredicateFailureReason
- type PredicateMetadata
- type PredicateMetadataProducer
- type ServiceAffinity
- type StorageClassInfo
- type VolumeBindingChecker
- type VolumeFilter
- type VolumeZoneChecker
Examples ¶
Constants ¶
const ( // MatchInterPodAffinityPred defines the name of predicate MatchInterPodAffinity. MatchInterPodAffinityPred = "MatchInterPodAffinity" // CheckVolumeBindingPred defines the name of predicate CheckVolumeBinding. CheckVolumeBindingPred = "CheckVolumeBinding" // GeneralPred defines the name of predicate GeneralPredicates. GeneralPred = "GeneralPredicates" // HostNamePred defines the name of predicate HostName. HostNamePred = "HostName" // PodFitsHostPortsPred defines the name of predicate PodFitsHostPorts. PodFitsHostPortsPred = "PodFitsHostPorts" // MatchNodeSelectorPred defines the name of predicate MatchNodeSelector. MatchNodeSelectorPred = "MatchNodeSelector" // PodFitsResourcesPred defines the name of predicate PodFitsResources. PodFitsResourcesPred = "PodFitsResources" // NoDiskConflictPred defines the name of predicate NoDiskConflict. NoDiskConflictPred = "NoDiskConflict" // PodToleratesNodeTaintsPred defines the name of predicate PodToleratesNodeTaints. PodToleratesNodeTaintsPred = "PodToleratesNodeTaints" // CheckNodeUnschedulablePred defines the name of predicate CheckNodeUnschedulablePredicate. CheckNodeUnschedulablePred = "CheckNodeUnschedulable" // PodToleratesNodeNoExecuteTaintsPred defines the name of predicate PodToleratesNodeNoExecuteTaints. PodToleratesNodeNoExecuteTaintsPred = "PodToleratesNodeNoExecuteTaints" // CheckNodeLabelPresencePred defines the name of predicate CheckNodeLabelPresence. CheckNodeLabelPresencePred = "CheckNodeLabelPresence" // CheckServiceAffinityPred defines the name of predicate checkServiceAffinity. CheckServiceAffinityPred = "CheckServiceAffinity" // MaxEBSVolumeCountPred defines the name of predicate MaxEBSVolumeCount. // DEPRECATED // All cloudprovider specific predicates are deprecated in favour of MaxCSIVolumeCountPred. MaxEBSVolumeCountPred = "MaxEBSVolumeCount" // MaxGCEPDVolumeCountPred defines the name of predicate MaxGCEPDVolumeCount. // DEPRECATED // All cloudprovider specific predicates are deprecated in favour of MaxCSIVolumeCountPred. MaxGCEPDVolumeCountPred = "MaxGCEPDVolumeCount" // MaxAzureDiskVolumeCountPred defines the name of predicate MaxAzureDiskVolumeCount. // DEPRECATED // All cloudprovider specific predicates are deprecated in favour of MaxCSIVolumeCountPred. MaxAzureDiskVolumeCountPred = "MaxAzureDiskVolumeCount" // MaxCinderVolumeCountPred defines the name of predicate MaxCinderDiskVolumeCount. // DEPRECATED // All cloudprovider specific predicates are deprecated in favour of MaxCSIVolumeCountPred. MaxCinderVolumeCountPred = "MaxCinderVolumeCount" // MaxCSIVolumeCountPred defines the predicate that decides how many CSI volumes should be attached. MaxCSIVolumeCountPred = "MaxCSIVolumeCountPred" // NoVolumeZoneConflictPred defines the name of predicate NoVolumeZoneConflict. NoVolumeZoneConflictPred = "NoVolumeZoneConflict" // EvenPodsSpreadPred defines the name of predicate EvenPodsSpread. EvenPodsSpreadPred = "EvenPodsSpread" // DefaultMaxGCEPDVolumes defines the maximum number of PD Volumes for GCE. // GCE instances can have up to 16 PD volumes attached. DefaultMaxGCEPDVolumes = 16 // DefaultMaxAzureDiskVolumes defines the maximum number of PD Volumes for Azure. // Larger Azure VMs can actually have much more disks attached. // TODO We should determine the max based on VM size DefaultMaxAzureDiskVolumes = 16 // KubeMaxPDVols defines the maximum number of PD Volumes per kubelet. KubeMaxPDVols = "KUBE_MAX_PD_VOLS" // EBSVolumeFilterType defines the filter name for EBSVolumeFilter. EBSVolumeFilterType = "EBS" // GCEPDVolumeFilterType defines the filter name for GCEPDVolumeFilter. GCEPDVolumeFilterType = "GCE" // AzureDiskVolumeFilterType defines the filter name for AzureDiskVolumeFilter. AzureDiskVolumeFilterType = "AzureDisk" // CinderVolumeFilterType defines the filter name for CinderVolumeFilter. CinderVolumeFilterType = "Cinder" )
Variables ¶
var ( // ErrDiskConflict is used for NoDiskConflict predicate error. ErrDiskConflict = newPredicateFailureError("NoDiskConflict", "node(s) had no available disk") // ErrVolumeZoneConflict is used for NoVolumeZoneConflict predicate error. ErrVolumeZoneConflict = newPredicateFailureError("NoVolumeZoneConflict", "node(s) had no available volume zone") // ErrNodeSelectorNotMatch is used for MatchNodeSelector predicate error. ErrNodeSelectorNotMatch = newPredicateFailureError("MatchNodeSelector", "node(s) didn't match node selector") // ErrPodAffinityNotMatch is used for MatchInterPodAffinity predicate error. ErrPodAffinityNotMatch = newPredicateFailureError("MatchInterPodAffinity", "node(s) didn't match pod affinity/anti-affinity") // ErrPodAffinityRulesNotMatch is used for PodAffinityRulesNotMatch predicate error. ErrPodAffinityRulesNotMatch = newPredicateFailureError("PodAffinityRulesNotMatch", "node(s) didn't match pod affinity rules") // ErrPodAntiAffinityRulesNotMatch is used for PodAntiAffinityRulesNotMatch predicate error. ErrPodAntiAffinityRulesNotMatch = newPredicateFailureError("PodAntiAffinityRulesNotMatch", "node(s) didn't match pod anti-affinity rules") // ErrExistingPodsAntiAffinityRulesNotMatch is used for ExistingPodsAntiAffinityRulesNotMatch predicate error. ErrExistingPodsAntiAffinityRulesNotMatch = newPredicateFailureError("ExistingPodsAntiAffinityRulesNotMatch", "node(s) didn't satisfy existing pods anti-affinity rules") // ErrTaintsTolerationsNotMatch is used for PodToleratesNodeTaints predicate error. ErrTaintsTolerationsNotMatch = newPredicateFailureError("PodToleratesNodeTaints", "node(s) had taints that the pod didn't tolerate") // ErrPodNotMatchHostName is used for HostName predicate error. ErrPodNotMatchHostName = newPredicateFailureError("HostName", "node(s) didn't match the requested hostname") // ErrPodNotFitsHostPorts is used for PodFitsHostPorts predicate error. ErrPodNotFitsHostPorts = newPredicateFailureError("PodFitsHostPorts", "node(s) didn't have free ports for the requested pod ports") // ErrNodeLabelPresenceViolated is used for CheckNodeLabelPresence predicate error. ErrNodeLabelPresenceViolated = newPredicateFailureError("CheckNodeLabelPresence", "node(s) didn't have the requested labels") // ErrServiceAffinityViolated is used for CheckServiceAffinity predicate error. ErrServiceAffinityViolated = newPredicateFailureError("CheckServiceAffinity", "node(s) didn't match service affinity") // ErrMaxVolumeCountExceeded is used for MaxVolumeCount predicate error. ErrMaxVolumeCountExceeded = newPredicateFailureError("MaxVolumeCount", "node(s) exceed max volume count") // ErrNodeUnderMemoryPressure is used for NodeUnderMemoryPressure predicate error. ErrNodeUnderMemoryPressure = newPredicateFailureError("NodeUnderMemoryPressure", "node(s) had memory pressure") // ErrNodeUnderDiskPressure is used for NodeUnderDiskPressure predicate error. ErrNodeUnderDiskPressure = newPredicateFailureError("NodeUnderDiskPressure", "node(s) had disk pressure") // ErrNodeUnderPIDPressure is used for NodeUnderPIDPressure predicate error. ErrNodeUnderPIDPressure = newPredicateFailureError("NodeUnderPIDPressure", "node(s) had pid pressure") // ErrNodeNotReady is used for NodeNotReady predicate error. ErrNodeNotReady = newPredicateFailureError("NodeNotReady", "node(s) were not ready") ErrNodeNetworkUnavailable = newPredicateFailureError("NodeNetworkUnavailable", "node(s) had unavailable network") // ErrNodeUnschedulable is used for NodeUnschedulable predicate error. ErrNodeUnschedulable = newPredicateFailureError("NodeUnschedulable", "node(s) were unschedulable") // ErrNodeUnknownCondition is used for NodeUnknownCondition predicate error. ErrNodeUnknownCondition = newPredicateFailureError("NodeUnknownCondition", "node(s) had unknown conditions") // ErrVolumeNodeConflict is used for VolumeNodeAffinityConflict predicate error. ErrVolumeNodeConflict = newPredicateFailureError("VolumeNodeAffinityConflict", "node(s) had volume node affinity conflict") // ErrVolumeBindConflict is used for VolumeBindingNoMatch predicate error. ErrVolumeBindConflict = newPredicateFailureError("VolumeBindingNoMatch", "node(s) didn't find available persistent volumes to bind") // ErrTopologySpreadConstraintsNotMatch is used for EvenPodsSpread predicate error. ErrTopologySpreadConstraintsNotMatch = newPredicateFailureError("EvenPodsSpreadNotMatch", "node(s) didn't match pod topology spread constraints") // ErrFakePredicate is used for test only. The fake predicates returning false also returns error // as ErrFakePredicate. ErrFakePredicate = newPredicateFailureError("FakePredicateError", "Nodes failed the fake predicate") )
var AzureDiskVolumeFilter = 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 }, MatchProvisioner: func(sc *storage.StorageClass) (relevant bool) { if sc.Provisioner == csilibplugins.AzureDiskInTreePluginName { return true } return false }, IsMigrated: func(csiNode *v1beta1storage.CSINode) bool { return isCSIMigrationOn(csiNode, csilibplugins.AzureDiskInTreePluginName) }, }
AzureDiskVolumeFilter is a VolumeFilter for filtering Azure Disk Volumes.
var CinderVolumeFilter = VolumeFilter{ FilterVolume: func(vol *v1.Volume) (string, bool) { if vol.Cinder != nil { return vol.Cinder.VolumeID, true } return "", false }, FilterPersistentVolume: func(pv *v1.PersistentVolume) (string, bool) { if pv.Spec.Cinder != nil { return pv.Spec.Cinder.VolumeID, true } return "", false }, MatchProvisioner: func(sc *storage.StorageClass) (relevant bool) { if sc.Provisioner == csilibplugins.CinderInTreePluginName { return true } return false }, IsMigrated: func(csiNode *v1beta1storage.CSINode) bool { return isCSIMigrationOn(csiNode, csilibplugins.CinderInTreePluginName) }, }
CinderVolumeFilter is a VolumeFilter for filtering Cinder Volumes. It will be deprecated once Openstack cloudprovider has been removed from in-tree.
var EBSVolumeFilter = VolumeFilter{ FilterVolume: func(vol *v1.Volume) (string, bool) { if vol.AWSElasticBlockStore != nil { return vol.AWSElasticBlockStore.VolumeID, true } return "", false }, FilterPersistentVolume: func(pv *v1.PersistentVolume) (string, bool) { if pv.Spec.AWSElasticBlockStore != nil { return pv.Spec.AWSElasticBlockStore.VolumeID, true } return "", false }, MatchProvisioner: func(sc *storage.StorageClass) (relevant bool) { if sc.Provisioner == csilibplugins.AWSEBSInTreePluginName { return true } return false }, IsMigrated: func(csiNode *v1beta1storage.CSINode) bool { return isCSIMigrationOn(csiNode, csilibplugins.AWSEBSInTreePluginName) }, }
EBSVolumeFilter is a VolumeFilter for filtering AWS ElasticBlockStore Volumes.
var GCEPDVolumeFilter = VolumeFilter{ FilterVolume: func(vol *v1.Volume) (string, bool) { if vol.GCEPersistentDisk != nil { return vol.GCEPersistentDisk.PDName, true } return "", false }, FilterPersistentVolume: func(pv *v1.PersistentVolume) (string, bool) { if pv.Spec.GCEPersistentDisk != nil { return pv.Spec.GCEPersistentDisk.PDName, true } return "", false }, MatchProvisioner: func(sc *storage.StorageClass) (relevant bool) { if sc.Provisioner == csilibplugins.GCEPDInTreePluginName { return true } return false }, IsMigrated: func(csiNode *v1beta1storage.CSINode) bool { return isCSIMigrationOn(csiNode, csilibplugins.GCEPDInTreePluginName) }, }
GCEPDVolumeFilter is a VolumeFilter for filtering GCE PersistentDisk Volumes.
Functions ¶
func AddUnsetLabelsToMap ¶
AddUnsetLabelsToMap backfills missing values with values we find in a map.
func CreateSelectorFromLabels ¶
CreateSelectorFromLabels is used to define a selector that corresponds to the keys in a map.
func FilterPodsByNamespace ¶
FilterPodsByNamespace filters pods outside a namespace from the given list.
func FindLabelsInSet ¶
FindLabelsInSet gets as many key/value pairs as possible out of a label set.
Example ¶
ExampleUtils is a https://blog.golang.org/examples styled unit test.
labelSubset := labels.Set{} labelSubset["label1"] = "value1" labelSubset["label2"] = "value2" // Lets make believe that these pods are on the cluster. // Utility functions will inspect their labels, filter them, and so on. nsPods := []*v1.Pod{ { ObjectMeta: metav1.ObjectMeta{ Name: "pod1", Namespace: "ns1", Labels: map[string]string{ "label1": "wontSeeThis", "label2": "wontSeeThis", "label3": "will_see_this", }, }, }, // first pod which will be used via the utilities { ObjectMeta: metav1.ObjectMeta{ Name: "pod2", Namespace: "ns1", }, }, { ObjectMeta: metav1.ObjectMeta{ Name: "pod3ThatWeWontSee", }, }, } fmt.Println(FindLabelsInSet([]string{"label1", "label2", "label3"}, nsPods[0].ObjectMeta.Labels)["label3"]) AddUnsetLabelsToMap(labelSubset, []string{"label1", "label2", "label3"}, nsPods[0].ObjectMeta.Labels) fmt.Println(labelSubset) for _, pod := range FilterPodsByNamespace(nsPods, "ns1") { fmt.Print(pod.Name, ",") }
Output: will_see_this label1=value1,label2=value2,label3=will_see_this pod1,pod2,
func GetPodAffinityTerms ¶
func GetPodAffinityTerms(podAffinity *v1.PodAffinity) (terms []v1.PodAffinityTerm)
GetPodAffinityTerms gets pod affinity terms by a pod affinity object.
func GetPodAntiAffinityTerms ¶
func GetPodAntiAffinityTerms(podAntiAffinity *v1.PodAntiAffinity) (terms []v1.PodAffinityTerm)
GetPodAntiAffinityTerms gets pod affinity terms by a pod anti-affinity.
func GetResourceRequest ¶
func GetResourceRequest(pod *v1.Pod) *schedulernodeinfo.Resource
GetResourceRequest returns a *schedulernodeinfo.Resource that covers the largest width in each resource dimension. Because init-containers run sequentially, we collect the max in each dimension iteratively. In contrast, we sum the resource vectors for regular containers since they run simultaneously.
If Pod Overhead is specified and the feature gate is set, the resources defined for Overhead are added to the calculated Resource request sum
Example:
Pod:
InitContainers IC1: CPU: 2 Memory: 1G IC2: CPU: 2 Memory: 3G Containers C1: CPU: 2 Memory: 1G C2: CPU: 1 Memory: 1G
Result: CPU: 3, Memory: 3G
func GetVolumeLimitKey ¶
func GetVolumeLimitKey(filterType string) v1.ResourceName
GetVolumeLimitKey returns a ResourceName by filter type
func NodeLabelsMatchSpreadConstraints ¶ added in v1.16.0
func NodeLabelsMatchSpreadConstraints(nodeLabels map[string]string, constraints []v1.TopologySpreadConstraint) bool
NodeLabelsMatchSpreadConstraints checks if ALL topology keys in spread constraints are present in node labels.
func PodMatchesNodeSelectorAndAffinityTerms ¶ added in v1.16.0
PodMatchesNodeSelectorAndAffinityTerms checks whether the pod is schedulable onto nodes according to the requirements in both NodeAffinity and nodeSelector.
func PodMatchesSpreadConstraint ¶ added in v1.16.0
func PodMatchesSpreadConstraint(podLabelSet labels.Set, constraint v1.TopologySpreadConstraint) (bool, error)
PodMatchesSpreadConstraint verifies if <constraint.LabelSelector> matches <podLabelSet>. Some corner cases: 1. podLabelSet = nil => returns (false, nil) 2. constraint.LabelSelector = nil => returns (false, nil)
func RegisterPredicateMetadataProducer ¶
func RegisterPredicateMetadataProducer(predicateName string, precomp predicateMetadataProducer)
RegisterPredicateMetadataProducer registers a PredicateMetadataProducer.
func RegisterPredicateMetadataProducerWithExtendedResourceOptions ¶
func RegisterPredicateMetadataProducerWithExtendedResourceOptions(ignoredExtendedResources sets.String)
RegisterPredicateMetadataProducerWithExtendedResourceOptions registers a PredicateMetadataProducer that creates predicate metadata with the provided options for extended resources.
See the comments in "predicateMetadata" for the explanation of the options.
func SetPredicatesOrderingDuringTest ¶ added in v1.15.0
func SetPredicatesOrderingDuringTest(value []string) func()
SetPredicatesOrderingDuringTest sets the predicatesOrdering to the specified value, and returns a function that restores the original value.
Types ¶
type CSIMaxVolumeLimitChecker ¶ added in v1.12.0
type CSIMaxVolumeLimitChecker struct {
// contains filtered or unexported fields
}
CSIMaxVolumeLimitChecker defines predicate needed for counting CSI volumes
type CSINodeInfo ¶ added in v1.16.0
type CSINodeInfo interface {
GetCSINodeInfo(nodeName string) (*v1beta1storage.CSINode, error)
}
CSINodeInfo interface represents anything that can get CSINode object from node name.
type CachedCSINodeInfo ¶
type CachedCSINodeInfo struct {
v1beta1storagelisters.CSINodeLister
}
CachedCSINodeInfo implements CSINodeInfoInfo
func (*CachedCSINodeInfo) GetCSINodeInfo ¶
func (c *CachedCSINodeInfo) GetCSINodeInfo(nodeName string) (*v1beta1storage.CSINode, error)
GetCSINodeInfo returns a persistent volume object by PV ID.
type CachedPersistentVolumeClaimInfo ¶
type CachedPersistentVolumeClaimInfo struct {
corelisters.PersistentVolumeClaimLister
}
CachedPersistentVolumeClaimInfo implements PersistentVolumeClaimInfo
func (*CachedPersistentVolumeClaimInfo) GetPersistentVolumeClaimInfo ¶
func (c *CachedPersistentVolumeClaimInfo) GetPersistentVolumeClaimInfo(namespace string, name string) (*v1.PersistentVolumeClaim, error)
GetPersistentVolumeClaimInfo fetches the claim in specified namespace with specified name.
type CachedPersistentVolumeInfo ¶
type CachedPersistentVolumeInfo struct {
corelisters.PersistentVolumeLister
}
CachedPersistentVolumeInfo implements PersistentVolumeInfo
func (*CachedPersistentVolumeInfo) GetPersistentVolumeInfo ¶
func (c *CachedPersistentVolumeInfo) GetPersistentVolumeInfo(pvID string) (*v1.PersistentVolume, error)
GetPersistentVolumeInfo returns a persistent volume object by PV ID.
type CachedStorageClassInfo ¶
type CachedStorageClassInfo struct {
storagelisters.StorageClassLister
}
CachedStorageClassInfo implements StorageClassInfo
func (*CachedStorageClassInfo) GetStorageClassInfo ¶
func (c *CachedStorageClassInfo) GetStorageClassInfo(className string) (*storage.StorageClass, error)
GetStorageClassInfo get StorageClass by class name.
type FailureReason ¶
type FailureReason struct {
// contains filtered or unexported fields
}
FailureReason describes a failure reason.
func NewFailureReason ¶
func NewFailureReason(msg string) *FailureReason
NewFailureReason creates a FailureReason with message.
func (*FailureReason) GetReason ¶
func (e *FailureReason) GetReason() string
GetReason returns the reason of the FailureReason.
type FakeCSINodeInfo ¶ added in v1.16.0
type FakeCSINodeInfo storagev1beta1.CSINode
FakeCSINodeInfo declares a storagev1beta1.CSINode type for testing.
func (FakeCSINodeInfo) GetCSINodeInfo ¶ added in v1.16.0
func (n FakeCSINodeInfo) GetCSINodeInfo(name string) (*storagev1beta1.CSINode, error)
GetCSINodeInfo returns a fake CSINode object.
type FakeNodeInfo ¶
FakeNodeInfo declares a v1.Node type for testing.
func (FakeNodeInfo) GetNodeInfo ¶
func (n FakeNodeInfo) GetNodeInfo(nodeName string) (*v1.Node, error)
GetNodeInfo return a fake node info object.
type FakeNodeListInfo ¶
FakeNodeListInfo declares a []v1.Node type for testing.
func (FakeNodeListInfo) GetNodeInfo ¶
func (nodes FakeNodeListInfo) GetNodeInfo(nodeName string) (*v1.Node, error)
GetNodeInfo returns a fake node object in the fake nodes.
type FakePersistentVolumeClaimInfo ¶
type FakePersistentVolumeClaimInfo []v1.PersistentVolumeClaim
FakePersistentVolumeClaimInfo declares a []v1.PersistentVolumeClaim type for testing.
func (FakePersistentVolumeClaimInfo) GetPersistentVolumeClaimInfo ¶
func (pvcs FakePersistentVolumeClaimInfo) GetPersistentVolumeClaimInfo(namespace string, pvcID string) (*v1.PersistentVolumeClaim, error)
GetPersistentVolumeClaimInfo gets PVC matching the namespace and PVC ID.
type FakePersistentVolumeInfo ¶
type FakePersistentVolumeInfo []v1.PersistentVolume
FakePersistentVolumeInfo declares a []v1.PersistentVolume type for testing.
func (FakePersistentVolumeInfo) GetPersistentVolumeInfo ¶
func (pvs FakePersistentVolumeInfo) GetPersistentVolumeInfo(pvID string) (*v1.PersistentVolume, error)
GetPersistentVolumeInfo returns a fake PV object in the fake PVs by PV ID.
type FakeStorageClassInfo ¶
type FakeStorageClassInfo []storagev1.StorageClass
FakeStorageClassInfo declares a []storagev1.StorageClass type for testing.
func (FakeStorageClassInfo) GetStorageClassInfo ¶
func (classes FakeStorageClassInfo) GetStorageClassInfo(name string) (*storagev1.StorageClass, error)
GetStorageClassInfo returns a fake storage class object in the fake storage classes by name.
type FitPredicate ¶ added in v1.14.0
type FitPredicate func(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
FitPredicate is a function that indicates if a pod fits into an existing node. The failure information is given by the error.
func NewCSIMaxVolumeLimitPredicate ¶ added in v1.12.0
func NewCSIMaxVolumeLimitPredicate( csiNodeInfo CSINodeInfo, pvInfo PersistentVolumeInfo, pvcInfo PersistentVolumeClaimInfo, scInfo StorageClassInfo) FitPredicate
NewCSIMaxVolumeLimitPredicate returns a predicate for counting CSI volumes
func NewMaxPDVolumeCountPredicate ¶
func NewMaxPDVolumeCountPredicate(filterName string, csiNodeInfo CSINodeInfo, scInfo StorageClassInfo, pvInfo PersistentVolumeInfo, pvcInfo PersistentVolumeClaimInfo) FitPredicate
NewMaxPDVolumeCountPredicate creates a predicate which evaluates whether a pod can fit based on the number of volumes which match a filter that it requests, and those that are already present.
DEPRECATED All cloudprovider specific predicates defined here are deprecated in favour of CSI volume limit predicate - MaxCSIVolumeCountPred.
The predicate looks for both volumes used directly, as well as PVC volumes that are backed by relevant volume types, counts the number of unique volumes, and rejects the new pod if it would place the total count over the maximum.
func NewNodeLabelPredicate ¶
func NewNodeLabelPredicate(labels []string, presence bool) FitPredicate
NewNodeLabelPredicate creates a predicate which evaluates whether a pod can fit based on the node labels which match a filter that it requests.
func NewPodAffinityPredicate ¶
func NewPodAffinityPredicate(info NodeInfo, podLister algorithm.PodLister) FitPredicate
NewPodAffinityPredicate creates a PodAffinityChecker.
func NewServiceAffinityPredicate ¶
func NewServiceAffinityPredicate(podLister algorithm.PodLister, serviceLister corelisters.ServiceLister, nodeInfo NodeInfo, labels []string) (FitPredicate, predicateMetadataProducer)
NewServiceAffinityPredicate creates a ServiceAffinity.
func NewVolumeBindingPredicate ¶
func NewVolumeBindingPredicate(binder *volumebinder.VolumeBinder) FitPredicate
NewVolumeBindingPredicate evaluates if a pod can fit due to the volumes it requests, for both bound and unbound PVCs.
For PVCs that are bound, then it checks that the corresponding PV's node affinity is satisfied by the given node.
For PVCs that are unbound, it tries to find available PVs that can satisfy the PVC requirements and that the PV node affinity is satisfied by the given node.
The predicate returns true if all bound PVCs have compatible PVs with the node, and if all unbound PVCs can be matched with an available and node-compatible PV.
func NewVolumeZonePredicate ¶
func NewVolumeZonePredicate(pvInfo PersistentVolumeInfo, pvcInfo PersistentVolumeClaimInfo, classInfo StorageClassInfo) FitPredicate
NewVolumeZonePredicate evaluates if a pod can fit due to the volumes it requests, given that some volumes may have zone scheduling constraints. The requirement is that any volume zone-labels must match the equivalent zone-labels on the node. It is OK for the node to have more zone-label constraints (for example, a hypothetical replicated volume might allow region-wide access)
Currently this is only supported with PersistentVolumeClaims, and looks to the labels only on the bound PersistentVolume.
Working with volumes declared inline in the pod specification (i.e. not using a PersistentVolume) is likely to be harder, as it would require determining the zone of a volume during scheduling, and that is likely to require calling out to the cloud provider. It seems that we are moving away from inline volume declarations anyway.
type InTreeToCSITranslator ¶ added in v1.17.0
type InTreeToCSITranslator interface { IsPVMigratable(pv *v1.PersistentVolume) bool IsMigratableIntreePluginByName(inTreePluginName string) bool GetInTreePluginNameFromSpec(pv *v1.PersistentVolume, vol *v1.Volume) (string, error) GetCSINameFromInTreeName(pluginName string) (string, error) TranslateInTreePVToCSI(pv *v1.PersistentVolume) (*v1.PersistentVolume, error) }
InTreeToCSITranslator contains methods required to check migratable status and perform translations from InTree PV's to CSI
type InsufficientResourceError ¶
type InsufficientResourceError struct { // resourceName is the name of the resource that is insufficient ResourceName v1.ResourceName // contains filtered or unexported fields }
InsufficientResourceError is an error type that indicates what kind of resource limit is hit and caused the unfitting failure.
func NewInsufficientResourceError ¶
func NewInsufficientResourceError(resourceName v1.ResourceName, requested, used, capacity int64) *InsufficientResourceError
NewInsufficientResourceError returns an InsufficientResourceError.
func (*InsufficientResourceError) Error ¶
func (e *InsufficientResourceError) Error() string
func (*InsufficientResourceError) GetInsufficientAmount ¶
func (e *InsufficientResourceError) GetInsufficientAmount() int64
GetInsufficientAmount returns the amount of the insufficient resource of the error.
func (*InsufficientResourceError) GetReason ¶
func (e *InsufficientResourceError) GetReason() string
GetReason returns the reason of the InsufficientResourceError.
type MaxPDVolumeCountChecker ¶
type MaxPDVolumeCountChecker struct {
// contains filtered or unexported fields
}
MaxPDVolumeCountChecker contains information to check the max number of volumes for a predicate.
type NodeLabelChecker ¶
type NodeLabelChecker struct {
// contains filtered or unexported fields
}
NodeLabelChecker contains information to check node labels for a predicate.
func (*NodeLabelChecker) CheckNodeLabelPresence ¶
func (n *NodeLabelChecker) CheckNodeLabelPresence(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
CheckNodeLabelPresence checks whether all of the specified labels exists on a node or not, regardless of their value If "presence" is false, then returns false if any of the requested labels matches any of the node's labels, otherwise returns true. If "presence" is true, then returns false if any of the requested labels does not match any of the node's labels, otherwise returns true.
Consider the cases where the nodes are placed in regions/zones/racks and these are identified by labels In some cases, it is required that only nodes that are part of ANY of the defined regions/zones/racks be selected
Alternately, eliminating nodes that have a certain label, regardless of value, is also useful A node may have a label with "retiring" as key and the date as the value and it may be desirable to avoid scheduling new pods on this node.
type PersistentVolumeClaimInfo ¶
type PersistentVolumeClaimInfo interface {
GetPersistentVolumeClaimInfo(namespace string, name string) (*v1.PersistentVolumeClaim, error)
}
PersistentVolumeClaimInfo interface represents anything that can get a PVC object in specified namespace with specified name.
type PersistentVolumeInfo ¶
type PersistentVolumeInfo interface {
GetPersistentVolumeInfo(pvID string) (*v1.PersistentVolume, error)
}
PersistentVolumeInfo interface represents anything that can get persistent volume object by PV ID.
type PodAffinityChecker ¶
type PodAffinityChecker struct {
// contains filtered or unexported fields
}
PodAffinityChecker contains information to check pod affinity.
func (*PodAffinityChecker) InterPodAffinityMatches ¶
func (c *PodAffinityChecker) InterPodAffinityMatches(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
InterPodAffinityMatches checks if a pod can be scheduled on the specified node with pod affinity/anti-affinity configuration. First return value indicates whether a pod can be scheduled on the specified node while the second return value indicates the predicate failure reasons if the pod cannot be scheduled on the specified node.
type PredicateFailureError ¶
PredicateFailureError describes a failure error of predicate.
func (*PredicateFailureError) Error ¶
func (e *PredicateFailureError) Error() string
func (*PredicateFailureError) GetReason ¶
func (e *PredicateFailureError) GetReason() string
GetReason returns the reason of the PredicateFailureError.
type PredicateFailureReason ¶ added in v1.14.0
type PredicateFailureReason interface {
GetReason() string
}
PredicateFailureReason interface represents the failure reason of a predicate.
func CheckNodeUnschedulablePredicate ¶
func CheckNodeUnschedulablePredicate(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
CheckNodeUnschedulablePredicate checks if a pod can be scheduled on a node with Unschedulable spec.
func EssentialPredicates ¶
func EssentialPredicates(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
EssentialPredicates are the predicates that all pods, including critical pods, need.
func EvenPodsSpreadPredicate ¶ added in v1.16.0
func EvenPodsSpreadPredicate(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
EvenPodsSpreadPredicate checks if a pod can be scheduled on a node which satisfies its topologySpreadConstraints.
func GeneralPredicates ¶
func GeneralPredicates(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
GeneralPredicates checks whether noncriticalPredicates and EssentialPredicates pass. noncriticalPredicates are the predicates that only non-critical pods need and EssentialPredicates are the predicates that all pods, including critical pods, need.
func NoDiskConflict ¶
func NoDiskConflict(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
NoDiskConflict evaluates if a pod can fit due to the volumes it requests, and those that are already mounted. If there is already a volume mounted on that node, another pod that uses the same volume can't be scheduled there. This is GCE, Amazon EBS, ISCSI and Ceph RBD specific for now: - GCE PD allows multiple mounts as long as they're all read-only - AWS EBS forbids any two pods mounting the same volume ID - Ceph RBD forbids if any two pods share at least same monitor, and match pool and image, and the image is read-only - ISCSI forbids if any two pods share at least same IQN and ISCSI volume is read-only TODO: migrate this into some per-volume specific code?
func PodFitsHost ¶
func PodFitsHost(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
PodFitsHost checks if a pod spec node name matches the current node.
func PodFitsHostPorts ¶
func PodFitsHostPorts(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
PodFitsHostPorts checks if a node has free ports for the requested pod ports.
func PodFitsResources ¶
func PodFitsResources(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
PodFitsResources checks if a node has sufficient resources, such as cpu, memory, gpu, opaque int resources etc to run a pod. First return value indicates whether a node has sufficient resources to run a pod while the second return value indicates the predicate failure reasons if the node has insufficient resources to run the pod.
func PodMatchNodeSelector ¶
func PodMatchNodeSelector(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
PodMatchNodeSelector checks if a pod node selector matches the node label.
func PodToleratesNodeNoExecuteTaints ¶
func PodToleratesNodeNoExecuteTaints(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
PodToleratesNodeNoExecuteTaints checks if a pod tolerations can tolerate the node's NoExecute taints.
func PodToleratesNodeTaints ¶
func PodToleratesNodeTaints(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
PodToleratesNodeTaints checks if a pod tolerations can tolerate the node taints.
func UnresolvablePredicateExists ¶ added in v1.17.0
func UnresolvablePredicateExists(reasons []PredicateFailureReason) PredicateFailureReason
UnresolvablePredicateExists checks if there is at least one unresolvable predicate failure reason, if true returns the first one in the list.
type PredicateMetadata ¶ added in v1.14.0
type PredicateMetadata interface { ShallowCopy() PredicateMetadata AddPod(addedPod *v1.Pod, node *v1.Node) error RemovePod(deletedPod *v1.Pod, node *v1.Node) error }
PredicateMetadata interface represents anything that can access a predicate metadata.
func EmptyPredicateMetadataProducer ¶ added in v1.14.0
func EmptyPredicateMetadataProducer(pod *v1.Pod, nodeNameToInfo map[string]*schedulernodeinfo.NodeInfo) PredicateMetadata
EmptyPredicateMetadataProducer returns a no-op MetadataProducer type.
func GetPredicateMetadata ¶
func GetPredicateMetadata(pod *v1.Pod, nodeNameToInfoMap map[string]*schedulernodeinfo.NodeInfo) PredicateMetadata
GetPredicateMetadata returns the predicateMetadata which will be used by various predicates.
type PredicateMetadataProducer ¶
type PredicateMetadataProducer func(pod *v1.Pod, nodeNameToInfo map[string]*schedulernodeinfo.NodeInfo) PredicateMetadata
PredicateMetadataProducer is a function that computes predicate metadata for a given pod.
type ServiceAffinity ¶
type ServiceAffinity struct {
// contains filtered or unexported fields
}
ServiceAffinity defines a struct used for creating service affinity predicates.
type StorageClassInfo ¶
type StorageClassInfo interface {
GetStorageClassInfo(className string) (*storage.StorageClass, error)
}
StorageClassInfo interface represents anything that can get a storage class object by class name.
type VolumeBindingChecker ¶
type VolumeBindingChecker struct {
// contains filtered or unexported fields
}
VolumeBindingChecker contains information to check a volume binding.
type VolumeFilter ¶
type VolumeFilter struct { // Filter normal volumes FilterVolume func(vol *v1.Volume) (id string, relevant bool) FilterPersistentVolume func(pv *v1.PersistentVolume) (id string, relevant bool) // MatchProvisioner evaluates if the StorageClass provisioner matches the running predicate MatchProvisioner func(sc *storage.StorageClass) (relevant bool) // IsMigrated returns a boolean specifying whether the plugin is migrated to a CSI driver IsMigrated func(csiNode *v1beta1storage.CSINode) bool }
VolumeFilter contains information on how to filter PD Volumes when checking PD Volume caps.
type VolumeZoneChecker ¶
type VolumeZoneChecker struct {
// contains filtered or unexported fields
}
VolumeZoneChecker contains information to check the volume zone for a predicate.