implement Node affinity and NodeSelector
This commit is contained in:
@@ -1043,6 +1043,93 @@ const (
|
||||
DNSDefault DNSPolicy = "Default"
|
||||
)
|
||||
|
||||
// A node selector represents the union of the results of one or more label queries
|
||||
// over a set of nodes; that is, it represents the OR of the selectors represented
|
||||
// by the node selector terms.
|
||||
type NodeSelector struct {
|
||||
//Required. A list of node selector terms. The terms are ORed.
|
||||
NodeSelectorTerms []NodeSelectorTerm `json:"nodeSelectorTerms"`
|
||||
}
|
||||
|
||||
// A null or empty node selector term matches no objects.
|
||||
type NodeSelectorTerm struct {
|
||||
//Required. A list of node selector requirements. The requirements are ANDed.
|
||||
MatchExpressions []NodeSelectorRequirement `json:"matchExpressions"`
|
||||
}
|
||||
|
||||
// A node selector requirement is a selector that contains values, a key, and an operator
|
||||
// that relates the key and values.
|
||||
type NodeSelectorRequirement struct {
|
||||
// The label key that the selector applies to.
|
||||
Key string `json:"key" patchStrategy:"merge" patchMergeKey:"key"`
|
||||
// Represents a key's relationship to a set of values.
|
||||
// Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.
|
||||
Operator NodeSelectorOperator `json:"operator"`
|
||||
// An array of string values. If the operator is In or NotIn,
|
||||
// the values array must be non-empty. If the operator is Exists or DoesNotExist,
|
||||
// the values array must be empty. If the operator is Gt or Lt, the values
|
||||
// array must have a single element, which will be interpreted as an integer.
|
||||
// This array is replaced during a strategic merge patch.
|
||||
Values []string `json:"values,omitempty"`
|
||||
}
|
||||
|
||||
// A node selector operator is the set of operators that can be used in
|
||||
// a node selector requirement.
|
||||
type NodeSelectorOperator string
|
||||
|
||||
const (
|
||||
NodeSelectorOpIn NodeSelectorOperator = "In"
|
||||
NodeSelectorOpNotIn NodeSelectorOperator = "NotIn"
|
||||
NodeSelectorOpExists NodeSelectorOperator = "Exists"
|
||||
NodeSelectorOpDoesNotExist NodeSelectorOperator = "DoesNotExist"
|
||||
NodeSelectorOpGt NodeSelectorOperator = "Gt"
|
||||
NodeSelectorOpLt NodeSelectorOperator = "Lt"
|
||||
)
|
||||
|
||||
// Affinity is a group of affinity scheduling requirements.
|
||||
type Affinity struct {
|
||||
// Describes node affinity scheduling requirements for the pod.
|
||||
NodeAffinity *NodeAffinity `json:"nodeAffinity,omitempty"`
|
||||
}
|
||||
|
||||
// Node affinity is a group of node affinity scheduling requirements.
|
||||
// If RequiredDuringSchedulingRequiredDuringExecution and
|
||||
// RequiredDuringSchedulingIgnoredDuringExecution are both set,
|
||||
// then both node selectors must be satisfied.
|
||||
type NodeAffinity struct {
|
||||
// If the affinity requirements specified by this field are not met at
|
||||
// scheduling time, the pod will not be scheduled onto the node.
|
||||
// If the affinity requirements specified by this field cease to be met
|
||||
// at some point during pod execution (e.g. due to an update), the system
|
||||
// will try to eventually evict the pod from its node.
|
||||
RequiredDuringSchedulingRequiredDuringExecution *NodeSelector `json:"requiredDuringSchedulingRequiredDuringExecution,omitempty"`
|
||||
// If the affinity requirements specified by this field are not met at
|
||||
// scheduling time, the pod will not be scheduled onto the node.
|
||||
// If the affinity requirements specified by this field cease to be met
|
||||
// at some point during pod execution (e.g. due to an update), the system
|
||||
// may or may not try to eventually evict the pod from its node.
|
||||
RequiredDuringSchedulingIgnoredDuringExecution *NodeSelector `json:"requiredDuringSchedulingIgnoredDuringExecution,omitempty"`
|
||||
// The scheduler will prefer to schedule pods to nodes that satisfy
|
||||
// the affinity expressions specified by this field, but it may choose
|
||||
// a node that violates one or more of the expressions. The node that is
|
||||
// most preferred is the one with the greatest sum of weights, i.e.
|
||||
// for each node that meets all of the scheduling requirements (resource
|
||||
// request, requiredDuringScheduling affinity expressions, etc.),
|
||||
// compute a sum by iterating through the elements of this field and adding
|
||||
// "weight" to the sum if the node matches the corresponding matchExpressions; the
|
||||
// node(s) with the highest sum are the most preferred.
|
||||
PreferredDuringSchedulingIgnoredDuringExecution []PreferredSchedulingTerm `json:"preferredDuringSchedulingIgnoredDuringExecution,omitempty"`
|
||||
}
|
||||
|
||||
// An empty preferred scheduling term matches all objects with implicit weight 0
|
||||
// (i.e. it's a no-op). A null preferred scheduling term matches no objects (i.e. is also a no-op).
|
||||
type PreferredSchedulingTerm struct {
|
||||
// Weight associated with matching the corresponding nodeSelectorTerm, in the range 1-100.
|
||||
Weight int `json:"weight"`
|
||||
// A node selector term, associated with the corresponding weight.
|
||||
Preference NodeSelectorTerm `json:"preference"`
|
||||
}
|
||||
|
||||
// PodSpec is a description of a pod
|
||||
type PodSpec struct {
|
||||
Volumes []Volume `json:"volumes"`
|
||||
|
Reference in New Issue
Block a user