{"modulePath":"github.com/GoogleCloudPlatform/kubernetes","version":"v1.9.11","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package predicates\n\n## Constants\n\n```go\nconst (\n\tMatchInterPodAffinity = \"MatchInterPodAffinity\"\n\tCheckVolumeBinding    = \"CheckVolumeBinding\"\n\n\t// DefaultMaxGCEPDVolumes defines the maximum number of PD Volumes for GCE\n\t// GCE instances can have up to 16 PD volumes attached.\n\tDefaultMaxGCEPDVolumes = 16\n\t// DefaultMaxAzureDiskVolumes defines the maximum number of PD Volumes for Azure\n\t// Larger Azure VMs can actually have much more disks attached.\n\t// TODO We should determine the max based on VM size\n\tDefaultMaxAzureDiskVolumes = 16\n\n\t// KubeMaxPDVols defines the maximum number of PD Volumes per kubelet\n\tKubeMaxPDVols = \"KUBE_MAX_PD_VOLS\"\n\n\t// for EBSVolumeFilter\n\tEBSVolumeFilterType = \"EBS\"\n\t// for GCEPDVolumeFilter\n\tGCEPDVolumeFilterType = \"GCE\"\n\t// for AzureDiskVolumeFilter\n\tAzureDiskVolumeFilterType = \"AzureDisk\"\n)\n```\n\n## Variables\n\n```go\nvar (\n\n\t// NOTE: If you add a new predicate failure error for a predicate that can never\n\t// be made to pass by removing pods, or you change an existing predicate so that\n\t// it can never be made to pass by removing pods, you need to add the predicate\n\t// failure error in nodesWherePreemptionMightHelp() in scheduler/core/generic_scheduler.go\n\tErrDiskConflict                          = newPredicateFailureError(\"NoDiskConflict\")\n\tErrVolumeZoneConflict                    = newPredicateFailureError(\"NoVolumeZoneConflict\")\n\tErrNodeSelectorNotMatch                  = newPredicateFailureError(\"MatchNodeSelector\")\n\tErrPodAffinityNotMatch                   = newPredicateFailureError(\"MatchInterPodAffinity\")\n\tErrPodAffinityRulesNotMatch              = newPredicateFailureError(\"PodAffinityRulesNotMatch\")\n\tErrPodAntiAffinityRulesNotMatch          = newPredicateFailureError(\"PodAntiAffinityRulesNotMatch\")\n\tErrExistingPodsAntiAffinityRulesNotMatch = newPredicateFailureError(\"ExistingPodsAntiAffinityRulesNotMatch\")\n\tErrTaintsTolerationsNotMatch             = newPredicateFailureError(\"PodToleratesNodeTaints\")\n\tErrPodNotMatchHostName                   = newPredicateFailureError(\"HostName\")\n\tErrPodNotFitsHostPorts                   = newPredicateFailureError(\"PodFitsHostPorts\")\n\tErrNodeLabelPresenceViolated             = newPredicateFailureError(\"CheckNodeLabelPresence\")\n\tErrServiceAffinityViolated               = newPredicateFailureError(\"CheckServiceAffinity\")\n\tErrMaxVolumeCountExceeded                = newPredicateFailureError(\"MaxVolumeCount\")\n\tErrNodeUnderMemoryPressure               = newPredicateFailureError(\"NodeUnderMemoryPressure\")\n\tErrNodeUnderDiskPressure                 = newPredicateFailureError(\"NodeUnderDiskPressure\")\n\tErrNodeOutOfDisk                         = newPredicateFailureError(\"NodeOutOfDisk\")\n\tErrNodeNotReady                          = newPredicateFailureError(\"NodeNotReady\")\n\tErrNodeNetworkUnavailable                = newPredicateFailureError(\"NodeNetworkUnavailable\")\n\tErrNodeUnschedulable                     = newPredicateFailureError(\"NodeUnschedulable\")\n\tErrNodeUnknownCondition                  = newPredicateFailureError(\"NodeUnknownCondition\")\n\tErrVolumeNodeConflict                    = newPredicateFailureError(\"VolumeNodeAffinityConflict\")\n\tErrVolumeBindConflict                    = newPredicateFailureError(\"VolumeBindingNoMatch\")\n\t// ErrFakePredicate is used for test only. The fake predicates returning false also returns error\n\t// as ErrFakePredicate.\n\tErrFakePredicate = newPredicateFailureError(\"FakePredicateError\")\n)\n```\n\n## Functions\n\n```go\nfunc AddUnsetLabelsToMap(aL map[string]string, labelsToAdd []string, labelSet labels.Set)\n```\nAddUnsetLabelsToMap backfills missing values with values we find in a map.\n\n```go\nfunc CheckNodeConditionPredicate(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error)\n```\nCheckNodeConditionPredicate checks if a pod can be scheduled on a node reporting out of disk, network unavailable and not ready condition. Only node conditions are accounted in this predicate.\n\n```go\nfunc CheckNodeDiskPressurePredicate(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error)\n```\nCheckNodeDiskPressurePredicate checks if a pod can be scheduled on a node reporting disk pressure condition.\n\n```go\nfunc CheckNodeMemoryPressurePredicate(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error)\n```\nCheckNodeMemoryPressurePredicate checks if a pod can be scheduled on a node reporting memory pressure condition.\n\n```go\nfunc CreateSelectorFromLabels(aL map[string]string) labels.Selector\n```\nCreateSelectorFromLabels is used to define a selector that corresponds to the keys in a map.\n\n```go\nfunc EssentialPredicates(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error)\n```\nEssentialPredicates are the predicates that all pods, including critical pods, need\n\n```go\nfunc FilterPodsByNamespace(pods []*v1.Pod, ns string) []*v1.Pod\n```\nFilterPodsByNamespace filters pods outside a namespace from the given list.\n\n```go\nfunc FindLabelsInSet(labelsToKeep []string, selector labels.Set) map[string]string\n```\nFindLabelsInSet gets as many key/value pairs as possible out of a label set.\n\n```go\nfunc GeneralPredicates(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error)\n```\nGeneralPredicates 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\n\n```go\nfunc GetPodAffinityTerms(podAffinity *v1.PodAffinity) (terms []v1.PodAffinityTerm)\n```\n\n```go\nfunc GetPodAntiAffinityTerms(podAntiAffinity *v1.PodAntiAffinity) (terms []v1.PodAffinityTerm)\n```\n\n```go\nfunc GetResourceRequest(pod *v1.Pod) *schedulercache.Resource\n```\nGetResourceRequest returns a \\*schedulercache.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.\n\nExample:\n\nPod:\n\n\tInitContainers\n\t  IC1:\n\t    CPU: 2\n\t    Memory: 1G\n\t  IC2:\n\t    CPU: 2\n\t    Memory: 3G\n\tContainers\n\t  C1:\n\t    CPU: 2\n\t    Memory: 1G\n\t  C2:\n\t    CPU: 1\n\t    Memory: 1G\n\nResult: CPU: 3, Memory: 3G\n\n```go\nfunc NewEquivalencePodGenerator(pvcInfo PersistentVolumeClaimInfo) algorithm.GetEquivalencePodFunc\n```\nNewEquivalencePodGenerator returns a getEquivalencePod method with consideration of PVC info.\n\n```go\nfunc NewMaxPDVolumeCountPredicate(filterName string, 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.\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(labels []string, presence bool) algorithm.FitPredicate\n```\n\n```go\nfunc NewPodAffinityPredicate(info NodeInfo, podLister algorithm.PodLister) algorithm.FitPredicate\n```\n\n```go\nfunc NewPredicateMetadataFactory(podLister algorithm.PodLister) algorithm.PredicateMetadataProducer\n```\n\n```go\nfunc NewVolumeBindingPredicate(binder *volumebinder.VolumeBinder) algorithm.FitPredicate\n```\nNewVolumeBindingPredicate evaluates if a pod can fit due to the volumes it requests, for both bound and unbound PVCs.\n\nFor PVCs that are bound, then it checks that the corresponding PV's node affinity is satisfied by the given node.\n\nFor 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.\n\nThe 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.\n\n```go\nfunc NewVolumeZonePredicate(pvInfo PersistentVolumeInfo, pvcInfo PersistentVolumeClaimInfo, classInfo StorageClassInfo) algorithm.FitPredicate\n```\nNewVolumeZonePredicate 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 *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, 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. - ISCSI forbids if any two pods share at least same IQN, LUN and Target TODO: migrate this into some per-volume specific code?\n\n```go\nfunc PodFitsHost(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error)\n```\nPodFitsHost checks if a pod spec node name matches the current node.\n\n```go\nfunc PodFitsHostPorts(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error)\n```\nPodFitsHostPorts checks if a node has free ports for the requested pod ports.\n\n```go\nfunc PodFitsResources(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error)\n```\nPodFitsResources 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.\n\n```go\nfunc PodMatchNodeSelector(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error)\n```\nPodMatchNodeSelector checks if a pod node selector matches the node label.\n\n```go\nfunc PodToleratesNodeNoExecuteTaints(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error)\n```\nPodToleratesNodeNoExecuteTaints checks if a pod tolerations can tolerate the node's NoExecute taints\n\n```go\nfunc PodToleratesNodeTaints(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error)\n```\nPodToleratesNodeTaints checks if a pod tolerations can tolerate the node taints\n\n```go\nfunc RegisterPredicateMetadataProducer(predicateName string, precomp PredicateMetadataProducer)\n```\n\n## Types\n\n```go\ntype CachedNodeInfo struct {\n\tcorelisters.NodeLister\n}\n```\n\n```go\nfunc (c *CachedNodeInfo) GetNodeInfo(id string) (*v1.Node, error)\n```\nGetNodeInfo returns cached data for the node 'id'.\n\n```go\ntype CachedPersistentVolumeClaimInfo struct {\n\tcorelisters.PersistentVolumeClaimLister\n}\n```\nCachedPersistentVolumeClaimInfo implements PersistentVolumeClaimInfo\n\n```go\nfunc (c *CachedPersistentVolumeClaimInfo) GetPersistentVolumeClaimInfo(namespace string, name string) (*v1.PersistentVolumeClaim, error)\n```\nGetPersistentVolumeClaimInfo fetches the claim in specified namespace with specified name\n\n```go\ntype CachedPersistentVolumeInfo struct {\n\tcorelisters.PersistentVolumeLister\n}\n```\nCachedPersistentVolumeInfo implements PersistentVolumeInfo\n\n```go\nfunc (c *CachedPersistentVolumeInfo) GetPersistentVolumeInfo(pvID string) (*v1.PersistentVolume, error)\n```\n\n```go\ntype CachedStorageClassInfo struct {\n\tstoragelisters.StorageClassLister\n}\n```\nCachedStorageClassInfo implements StorageClassInfo\n\n```go\nfunc (c *CachedStorageClassInfo) GetStorageClassInfo(className string) (*storagev1.StorageClass, error)\n```\n\n```go\ntype EquivalencePod struct {\n\tControllerRef metav1.OwnerReference\n\tPVCSet        sets.String\n}\n```\nEquivalencePod is a group of pod attributes which can be reused as equivalence to schedule other pods.\n\n```go\ntype EquivalencePodGenerator struct {\n\t// contains filtered or unexported fields\n}\n```\nEquivalencePodGenerator is a generator of equivalence class for pod with consideration of PVC info.\n\n```go\ntype FailureReason struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewFailureReason(msg string) *FailureReason\n```\n\n```go\nfunc (e *FailureReason) GetReason() string\n```\n\n```go\ntype FakeNodeInfo v1.Node\n```\n\n```go\nfunc (n FakeNodeInfo) GetNodeInfo(nodeName string) (*v1.Node, error)\n```\n\n```go\ntype FakeNodeListInfo []v1.Node\n```\n\n```go\nfunc (nodes FakeNodeListInfo) GetNodeInfo(nodeName string) (*v1.Node, error)\n```\n\n```go\ntype FakePersistentVolumeClaimInfo []v1.PersistentVolumeClaim\n```\n\n```go\nfunc (pvcs FakePersistentVolumeClaimInfo) GetPersistentVolumeClaimInfo(namespace string, pvcID string) (*v1.PersistentVolumeClaim, error)\n```\n\n```go\ntype FakePersistentVolumeInfo []v1.PersistentVolume\n```\n\n```go\nfunc (pvs FakePersistentVolumeInfo) GetPersistentVolumeInfo(pvID string) (*v1.PersistentVolume, error)\n```\n\n```go\ntype FakeStorageClassInfo []storagev1.StorageClass\n```\n\n```go\nfunc (classes FakeStorageClassInfo) GetStorageClassInfo(name string) (*storagev1.StorageClass, error)\n```\n\n```go\ntype InsufficientResourceError struct {\n\t// resourceName is the name of the resource that is insufficient\n\tResourceName v1.ResourceName\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 NewInsufficientResourceError(resourceName v1.ResourceName, requested, used, capacity int64) *InsufficientResourceError\n```\n\n```go\nfunc (e *InsufficientResourceError) Error() string\n```\n\n```go\nfunc (e *InsufficientResourceError) GetInsufficientAmount() int64\n```\n\n```go\nfunc (e *InsufficientResourceError) GetReason() 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) (*v1.Node, error)\n}\n```\nNodeInfo: Other types for predicate functions...\n\n```go\ntype NodeLabelChecker struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (n *NodeLabelChecker) CheckNodeLabelPresence(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, 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 PersistentVolumeClaimInfo interface {\n\tGetPersistentVolumeClaimInfo(namespace string, name string) (*v1.PersistentVolumeClaim, error)\n}\n```\n\n```go\ntype PersistentVolumeInfo interface {\n\tGetPersistentVolumeInfo(pvID string) (*v1.PersistentVolume, error)\n}\n```\n\n```go\ntype PodAffinityChecker struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (c *PodAffinityChecker) InterPodAffinityMatches(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error)\n```\nInterPodAffinityMatches 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.\n\n```go\ntype PredicateFailureError struct {\n\tPredicateName string\n}\n```\n\n```go\nfunc (e *PredicateFailureError) Error() string\n```\n\n```go\nfunc (e *PredicateFailureError) GetReason() string\n```\n\n```go\ntype PredicateMetadataFactory struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (pfactory *PredicateMetadataFactory) GetMetadata(pod *v1.Pod, nodeNameToInfoMap map[string]*schedulercache.NodeInfo) algorithm.PredicateMetadata\n```\nGetMetadata returns the predicateMetadata used which will be used by various predicates.\n\n```go\ntype PredicateMetadataProducer func(pm *predicateMetadata)\n```\nPredicateMetadataProducer: Helper types/variables...\n\n```go\nfunc NewServiceAffinityPredicate(podLister algorithm.PodLister, serviceLister algorithm.ServiceLister, nodeInfo NodeInfo, labels []string) (algorithm.FitPredicate, PredicateMetadataProducer)\n```\n\n```go\ntype ServiceAffinity struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype StorageClassInfo interface {\n\tGetStorageClassInfo(className string) (*storagev1.StorageClass, error)\n}\n```\n\n```go\ntype VolumeBindingChecker struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype VolumeFilter struct {\n\t// Filter normal volumes\n\tFilterVolume           func(vol *v1.Volume) (id string, relevant bool)\n\tFilterPersistentVolume func(pv *v1.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 AzureDiskVolumeFilter VolumeFilter = VolumeFilter{\n\tFilterVolume: func(vol *v1.Volume) (string, bool) {\n\t\tif vol.AzureDisk != nil {\n\t\t\treturn vol.AzureDisk.DiskName, true\n\t\t}\n\t\treturn \"\", false\n\t},\n\n\tFilterPersistentVolume: func(pv *v1.PersistentVolume) (string, bool) {\n\t\tif pv.Spec.AzureDisk != nil {\n\t\t\treturn pv.Spec.AzureDisk.DiskName, true\n\t\t}\n\t\treturn \"\", false\n\t},\n}\n```\nAzureDiskVolumeFilter is a VolumeFilter for filtering Azure Disk Volumes\n\n```go\nvar EBSVolumeFilter VolumeFilter = VolumeFilter{\n\tFilterVolume: func(vol *v1.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 *v1.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 *v1.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 *v1.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/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler/algorithm/predicates","name":"predicates","synopsis":"","isRedistributable":true}
