k8s.io/kubernetes@v1.29.3/pkg/scheduler/apis/config/types_pluginargs.go (about) 1 /* 2 Copyright 2020 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package config 18 19 import ( 20 v1 "k8s.io/api/core/v1" 21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 ) 23 24 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 25 26 // DefaultPreemptionArgs holds arguments used to configure the 27 // DefaultPreemption plugin. 28 type DefaultPreemptionArgs struct { 29 metav1.TypeMeta 30 31 // MinCandidateNodesPercentage is the minimum number of candidates to 32 // shortlist when dry running preemption as a percentage of number of nodes. 33 // Must be in the range [0, 100]. Defaults to 10% of the cluster size if 34 // unspecified. 35 MinCandidateNodesPercentage int32 36 // MinCandidateNodesAbsolute is the absolute minimum number of candidates to 37 // shortlist. The likely number of candidates enumerated for dry running 38 // preemption is given by the formula: 39 // numCandidates = max(numNodes * minCandidateNodesPercentage, minCandidateNodesAbsolute) 40 // We say "likely" because there are other factors such as PDB violations 41 // that play a role in the number of candidates shortlisted. Must be at least 42 // 0 nodes. Defaults to 100 nodes if unspecified. 43 MinCandidateNodesAbsolute int32 44 } 45 46 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 47 48 // InterPodAffinityArgs holds arguments used to configure the InterPodAffinity plugin. 49 type InterPodAffinityArgs struct { 50 metav1.TypeMeta 51 52 // HardPodAffinityWeight is the scoring weight for existing pods with a 53 // matching hard affinity to the incoming pod. 54 HardPodAffinityWeight int32 55 56 // IgnorePreferredTermsOfExistingPods configures the scheduler to ignore existing pods' preferred affinity 57 // rules when scoring candidate nodes, unless the incoming pod has inter-pod affinities. 58 IgnorePreferredTermsOfExistingPods bool 59 } 60 61 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 62 63 // NodeResourcesFitArgs holds arguments used to configure the NodeResourcesFit plugin. 64 type NodeResourcesFitArgs struct { 65 metav1.TypeMeta 66 67 // IgnoredResources is the list of resources that NodeResources fit filter 68 // should ignore. 69 IgnoredResources []string 70 // IgnoredResourceGroups defines the list of resource groups that NodeResources fit filter should ignore. 71 // e.g. if group is ["example.com"], it will ignore all resource names that begin 72 // with "example.com", such as "example.com/aaa" and "example.com/bbb". 73 // A resource group name can't contain '/'. 74 IgnoredResourceGroups []string 75 76 // ScoringStrategy selects the node resource scoring strategy. 77 ScoringStrategy *ScoringStrategy 78 } 79 80 // PodTopologySpreadConstraintsDefaulting defines how to set default constraints 81 // for the PodTopologySpread plugin. 82 type PodTopologySpreadConstraintsDefaulting string 83 84 const ( 85 // SystemDefaulting instructs to use the kubernetes defined default. 86 SystemDefaulting PodTopologySpreadConstraintsDefaulting = "System" 87 // ListDefaulting instructs to use the config provided default. 88 ListDefaulting PodTopologySpreadConstraintsDefaulting = "List" 89 ) 90 91 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 92 93 // PodTopologySpreadArgs holds arguments used to configure the PodTopologySpread plugin. 94 type PodTopologySpreadArgs struct { 95 metav1.TypeMeta 96 97 // DefaultConstraints defines topology spread constraints to be applied to 98 // Pods that don't define any in `pod.spec.topologySpreadConstraints`. 99 // `.defaultConstraints[*].labelSelectors` must be empty, as they are 100 // deduced from the Pod's membership to Services, ReplicationControllers, 101 // ReplicaSets or StatefulSets. 102 // When not empty, .defaultingType must be "List". 103 DefaultConstraints []v1.TopologySpreadConstraint 104 105 // DefaultingType determines how .defaultConstraints are deduced. Can be one 106 // of "System" or "List". 107 // 108 // - "System": Use kubernetes defined constraints that spread Pods among 109 // Nodes and Zones. 110 // - "List": Use constraints defined in .defaultConstraints. 111 // 112 // Defaults to "System". 113 // +optional 114 DefaultingType PodTopologySpreadConstraintsDefaulting 115 } 116 117 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 118 119 // NodeResourcesBalancedAllocationArgs holds arguments used to configure NodeResourcesBalancedAllocation plugin. 120 type NodeResourcesBalancedAllocationArgs struct { 121 metav1.TypeMeta 122 123 // Resources to be considered when scoring. 124 // The default resource set includes "cpu" and "memory", only valid weight is 1. 125 Resources []ResourceSpec 126 } 127 128 // UtilizationShapePoint represents a single point of a priority function shape. 129 type UtilizationShapePoint struct { 130 // Utilization (x axis). Valid values are 0 to 100. Fully utilized node maps to 100. 131 Utilization int32 132 // Score assigned to a given utilization (y axis). Valid values are 0 to 10. 133 Score int32 134 } 135 136 // ResourceSpec represents single resource. 137 type ResourceSpec struct { 138 // Name of the resource. 139 Name string 140 // Weight of the resource. 141 Weight int64 142 } 143 144 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 145 146 // VolumeBindingArgs holds arguments used to configure the VolumeBinding plugin. 147 type VolumeBindingArgs struct { 148 metav1.TypeMeta 149 150 // BindTimeoutSeconds is the timeout in seconds in volume binding operation. 151 // Value must be non-negative integer. The value zero indicates no waiting. 152 // If this value is nil, the default value will be used. 153 BindTimeoutSeconds int64 154 155 // Shape specifies the points defining the score function shape, which is 156 // used to score nodes based on the utilization of statically provisioned 157 // PVs. The utilization is calculated by dividing the total requested 158 // storage of the pod by the total capacity of feasible PVs on each node. 159 // Each point contains utilization (ranges from 0 to 100) and its 160 // associated score (ranges from 0 to 10). You can turn the priority by 161 // specifying different scores for different utilization numbers. 162 // The default shape points are: 163 // 1) 0 for 0 utilization 164 // 2) 10 for 100 utilization 165 // All points must be sorted in increasing order by utilization. 166 // +featureGate=VolumeCapacityPriority 167 // +optional 168 Shape []UtilizationShapePoint 169 } 170 171 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 172 173 // NodeAffinityArgs holds arguments to configure the NodeAffinity plugin. 174 type NodeAffinityArgs struct { 175 metav1.TypeMeta 176 177 // AddedAffinity is applied to all Pods additionally to the NodeAffinity 178 // specified in the PodSpec. That is, Nodes need to satisfy AddedAffinity 179 // AND .spec.NodeAffinity. AddedAffinity is empty by default (all Nodes 180 // match). 181 // When AddedAffinity is used, some Pods with affinity requirements that match 182 // a specific Node (such as Daemonset Pods) might remain unschedulable. 183 AddedAffinity *v1.NodeAffinity 184 } 185 186 // ScoringStrategyType the type of scoring strategy used in NodeResourcesFit plugin. 187 type ScoringStrategyType string 188 189 const ( 190 // LeastAllocated strategy prioritizes nodes with least allocated resources. 191 LeastAllocated ScoringStrategyType = "LeastAllocated" 192 // MostAllocated strategy prioritizes nodes with most allocated resources. 193 MostAllocated ScoringStrategyType = "MostAllocated" 194 // RequestedToCapacityRatio strategy allows specifying a custom shape function 195 // to score nodes based on the request to capacity ratio. 196 RequestedToCapacityRatio ScoringStrategyType = "RequestedToCapacityRatio" 197 ) 198 199 // ScoringStrategy define ScoringStrategyType for node resource plugin 200 type ScoringStrategy struct { 201 // Type selects which strategy to run. 202 Type ScoringStrategyType 203 204 // Resources to consider when scoring. 205 // The default resource set includes "cpu" and "memory" with an equal weight. 206 // Allowed weights go from 1 to 100. 207 // Weight defaults to 1 if not specified or explicitly set to 0. 208 Resources []ResourceSpec 209 210 // Arguments specific to RequestedToCapacityRatio strategy. 211 RequestedToCapacityRatio *RequestedToCapacityRatioParam 212 } 213 214 // RequestedToCapacityRatioParam define RequestedToCapacityRatio parameters 215 type RequestedToCapacityRatioParam struct { 216 // Shape is a list of points defining the scoring function shape. 217 Shape []UtilizationShapePoint 218 }