{"modulePath":"github.com/foolusion/kubernetes","version":"v1.2.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package predicates\n\n## Functions\n\n```go\nfunc CheckPodsExceedingFreeResources(pods []*api.Pod, allocatable api.ResourceList) (fitting []*api.Pod, notFittingCPU, notFittingMemory []*api.Pod)\n```\n\n```go\nfunc NewMaxPDVolumeCountPredicate(filter VolumeFilter, maxVolumes int, pvInfo PersistentVolumeInfo, pvcInfo PersistentVolumeClaimInfo) algorithm.FitPredicate\n```\nNewMaxPDVolumeCountPredicate 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.  The maximum number is configurable to accommodate different systems.\n\nThe 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.\n\n```go\nfunc NewNodeLabelPredicate(info NodeInfo, labels []string, presence bool) algorithm.FitPredicate\n```\n\n```go\nfunc NewResourceFitPredicate(info NodeInfo) algorithm.FitPredicate\n```\n\n```go\nfunc NewSelectorMatchPredicate(info NodeInfo) algorithm.FitPredicate\n```\n\n```go\nfunc NewServiceAffinityPredicate(podLister algorithm.PodLister, serviceLister algorithm.ServiceLister, nodeInfo NodeInfo, labels []string) algorithm.FitPredicate\n```\n\n```go\nfunc NewVolumeZonePredicate(nodeInfo NodeInfo, pvInfo PersistentVolumeInfo, pvcInfo PersistentVolumeClaimInfo) algorithm.FitPredicate\n```\nVolumeZonePredicate 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)\n\nCurrently this is only supported with PersistentVolumeClaims, and looks to the labels only on the bound PersistentVolume.\n\nWorking 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.\n\n```go\nfunc NoDiskConflict(pod *api.Pod, nodeName string, nodeInfo *schedulercache.NodeInfo) (bool, error)\n```\nNoDiskConflict 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, 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. TODO: migrate this into some per-volume specific code?\n\n```go\nfunc PodFitsHost(pod *api.Pod, nodeName string, nodeInfo *schedulercache.NodeInfo) (bool, error)\n```\n\n```go\nfunc PodFitsHostPorts(pod *api.Pod, nodeName string, nodeInfo *schedulercache.NodeInfo) (bool, error)\n```\n\n```go\nfunc PodMatchesNodeLabels(pod *api.Pod, node *api.Node) bool\n```\nThe pod can only schedule onto nodes that satisfy requirements in both NodeAffinity and nodeSelector.\n\n## Types\n\n```go\ntype CachedNodeInfo struct {\n\t*cache.StoreToNodeLister\n}\n```\n\n```go\nfunc (c *CachedNodeInfo) GetNodeInfo(id string) (*api.Node, error)\n```\nGetNodeInfo returns cached data for the node 'id'.\n\n```go\ntype ClientNodeInfo struct {\n\t*client.Client\n}\n```\n\n```go\nfunc (nodes ClientNodeInfo) GetNodeInfo(nodeID string) (*api.Node, error)\n```\n\n```go\ntype InsufficientResourceError struct {\n\t// contains filtered or unexported fields\n}\n```\nInsufficientResourceError is an error type that indicates what kind of resource limit is hit and caused the unfitting failure.\n\n```go\nfunc (e *InsufficientResourceError) Error() string\n```\n\n```go\ntype MaxPDVolumeCountChecker struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype NodeInfo interface {\n\tGetNodeInfo(nodeID string) (*api.Node, error)\n}\n```\n\n```go\ntype NodeLabelChecker struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (n *NodeLabelChecker) CheckNodeLabelPresence(pod *api.Pod, nodeName string, nodeInfo *schedulercache.NodeInfo) (bool, error)\n```\nCheckNodeLabelPresence 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.\n\nConsider 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\n\nAlternately, 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\n\n```go\ntype NodeSelector struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (n *NodeSelector) PodSelectorMatches(pod *api.Pod, nodeName string, nodeInfo *schedulercache.NodeInfo) (bool, error)\n```\n\n```go\ntype PersistentVolumeClaimInfo interface {\n\tGetPersistentVolumeClaimInfo(namespace string, pvcID string) (*api.PersistentVolumeClaim, error)\n}\n```\n\n```go\ntype PersistentVolumeInfo interface {\n\tGetPersistentVolumeInfo(pvID string) (*api.PersistentVolume, error)\n}\n```\n\n```go\ntype ResourceFit struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *ResourceFit) PodFitsResources(pod *api.Pod, nodeName string, nodeInfo *schedulercache.NodeInfo) (bool, error)\n```\nPodFitsResources calculates fit based on requested, rather than used resources\n\n```go\ntype ServiceAffinity struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (s *ServiceAffinity) CheckServiceAffinity(pod *api.Pod, nodeName string, nodeInfo *schedulercache.NodeInfo) (bool, error)\n```\nCheckServiceAffinity ensures that only the nodes that match the specified labels are considered for scheduling. The set of labels to be considered are provided to the struct (ServiceAffinity). The pod is checked for the labels and any missing labels are then checked in the node that hosts the service pods (peers) for the given pod.\n\nWe add an implicit selector requiring some particular value V for label L to a pod, if: - L is listed in the ServiceAffinity object that is passed into the function - the pod does not have any NodeSelector for L - some other pod from the same service is already scheduled onto a node that has value V for label L\n\n```go\ntype StaticNodeInfo struct {\n\t*api.NodeList\n}\n```\n\n```go\nfunc (nodes StaticNodeInfo) GetNodeInfo(nodeID string) (*api.Node, error)\n```\n\n```go\ntype VolumeFilter struct {\n\t// Filter normal volumes\n\tFilterVolume           func(vol *api.Volume) (id string, relevant bool)\n\tFilterPersistentVolume func(pv *api.PersistentVolume) (id string, relevant bool)\n}\n```\nVolumeFilter contains information on how to filter PD Volumes when checking PD Volume caps\n\n```go\nvar EBSVolumeFilter VolumeFilter = VolumeFilter{\n\tFilterVolume: func(vol *api.Volume) (string, bool) {\n\t\tif vol.AWSElasticBlockStore != nil {\n\t\t\treturn vol.AWSElasticBlockStore.VolumeID, true\n\t\t}\n\t\treturn \"\", false\n\t},\n\n\tFilterPersistentVolume: func(pv *api.PersistentVolume) (string, bool) {\n\t\tif pv.Spec.AWSElasticBlockStore != nil {\n\t\t\treturn pv.Spec.AWSElasticBlockStore.VolumeID, true\n\t\t}\n\t\treturn \"\", false\n\t},\n}\n```\nEBSVolumeFilter is a VolumeFilter for filtering AWS ElasticBlockStore Volumes\n\n```go\nvar GCEPDVolumeFilter VolumeFilter = VolumeFilter{\n\tFilterVolume: func(vol *api.Volume) (string, bool) {\n\t\tif vol.GCEPersistentDisk != nil {\n\t\t\treturn vol.GCEPersistentDisk.PDName, true\n\t\t}\n\t\treturn \"\", false\n\t},\n\n\tFilterPersistentVolume: func(pv *api.PersistentVolume) (string, bool) {\n\t\tif pv.Spec.GCEPersistentDisk != nil {\n\t\t\treturn pv.Spec.GCEPersistentDisk.PDName, true\n\t\t}\n\t\treturn \"\", false\n\t},\n}\n```\nGCEPDVolumeFilter is a VolumeFilter for filtering GCE PersistentDisk Volumes\n\n```go\ntype VolumeZoneChecker struct {\n\t// contains filtered or unexported fields\n}\n```\n\n","path":"github.com/foolusion/kubernetes/plugin/pkg/scheduler/algorithm/predicates","name":"predicates","synopsis":"","isRedistributable":true}
