Skip to content

Commit 71ffc72

Browse files
authored
feat: support deployment toleration and affinity (Mellanox#1584)
Fixes Mellanox#1172
2 parents a73ddba + af1cf15 commit 71ffc72

File tree

15 files changed

+1229
-26
lines changed

15 files changed

+1229
-26
lines changed

api/v1alpha1/nicclusterpolicy_types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,11 @@ type NicClusterPolicySpec struct {
382382
NodeAffinity *v1.NodeAffinity `json:"nodeAffinity,omitempty"`
383383
// Tolerations to inject to the DaemonSets objects that are managed by the operator
384384
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
385+
// NodeAffinity rules to inject to the Deployments objects that are managed by the operator
386+
DeploymentNodeAffinity *v1.NodeAffinity `json:"deploymentNodeAffinity,omitempty"`
387+
// Tolerations to inject to the Deployments objects that are managed by the operator
388+
DeploymentTolerations []v1.Toleration `json:"deploymentTolerations,omitempty"`
385389
// Configuration options for OFED driver
386-
387390
}
388391

389392
// AppliedState defines a finer-grained view of the observed state of NicClusterPolicy

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/mellanox.com_nicclusterpolicies.yaml

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,245 @@ spec:
4848
spec:
4949
description: Defines the desired state of NicClusterPolicy
5050
properties:
51+
deploymentNodeAffinity:
52+
description: NodeAffinity rules to inject to the Deployments objects
53+
that are managed by the operator
54+
properties:
55+
preferredDuringSchedulingIgnoredDuringExecution:
56+
description: |-
57+
The scheduler will prefer to schedule pods to nodes that satisfy
58+
the affinity expressions specified by this field, but it may choose
59+
a node that violates one or more of the expressions. The node that is
60+
most preferred is the one with the greatest sum of weights, i.e.
61+
for each node that meets all of the scheduling requirements (resource
62+
request, requiredDuringScheduling affinity expressions, etc.),
63+
compute a sum by iterating through the elements of this field and adding
64+
"weight" to the sum if the node matches the corresponding matchExpressions; the
65+
node(s) with the highest sum are the most preferred.
66+
items:
67+
description: |-
68+
An empty preferred scheduling term matches all objects with implicit weight 0
69+
(i.e. it's a no-op). A null preferred scheduling term matches no objects (i.e. is also a no-op).
70+
properties:
71+
preference:
72+
description: A node selector term, associated with the corresponding
73+
weight.
74+
properties:
75+
matchExpressions:
76+
description: A list of node selector requirements by
77+
node's labels.
78+
items:
79+
description: |-
80+
A node selector requirement is a selector that contains values, a key, and an operator
81+
that relates the key and values.
82+
properties:
83+
key:
84+
description: The label key that the selector applies
85+
to.
86+
type: string
87+
operator:
88+
description: |-
89+
Represents a key's relationship to a set of values.
90+
Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.
91+
type: string
92+
values:
93+
description: |-
94+
An array of string values. If the operator is In or NotIn,
95+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
96+
the values array must be empty. If the operator is Gt or Lt, the values
97+
array must have a single element, which will be interpreted as an integer.
98+
This array is replaced during a strategic merge patch.
99+
items:
100+
type: string
101+
type: array
102+
x-kubernetes-list-type: atomic
103+
required:
104+
- key
105+
- operator
106+
type: object
107+
type: array
108+
x-kubernetes-list-type: atomic
109+
matchFields:
110+
description: A list of node selector requirements by
111+
node's fields.
112+
items:
113+
description: |-
114+
A node selector requirement is a selector that contains values, a key, and an operator
115+
that relates the key and values.
116+
properties:
117+
key:
118+
description: The label key that the selector applies
119+
to.
120+
type: string
121+
operator:
122+
description: |-
123+
Represents a key's relationship to a set of values.
124+
Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.
125+
type: string
126+
values:
127+
description: |-
128+
An array of string values. If the operator is In or NotIn,
129+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
130+
the values array must be empty. If the operator is Gt or Lt, the values
131+
array must have a single element, which will be interpreted as an integer.
132+
This array is replaced during a strategic merge patch.
133+
items:
134+
type: string
135+
type: array
136+
x-kubernetes-list-type: atomic
137+
required:
138+
- key
139+
- operator
140+
type: object
141+
type: array
142+
x-kubernetes-list-type: atomic
143+
type: object
144+
x-kubernetes-map-type: atomic
145+
weight:
146+
description: Weight associated with matching the corresponding
147+
nodeSelectorTerm, in the range 1-100.
148+
format: int32
149+
type: integer
150+
required:
151+
- preference
152+
- weight
153+
type: object
154+
type: array
155+
x-kubernetes-list-type: atomic
156+
requiredDuringSchedulingIgnoredDuringExecution:
157+
description: |-
158+
If the affinity requirements specified by this field are not met at
159+
scheduling time, the pod will not be scheduled onto the node.
160+
If the affinity requirements specified by this field cease to be met
161+
at some point during pod execution (e.g. due to an update), the system
162+
may or may not try to eventually evict the pod from its node.
163+
properties:
164+
nodeSelectorTerms:
165+
description: Required. A list of node selector terms. The
166+
terms are ORed.
167+
items:
168+
description: |-
169+
A null or empty node selector term matches no objects. The requirements of
170+
them are ANDed.
171+
The TopologySelectorTerm type implements a subset of the NodeSelectorTerm.
172+
properties:
173+
matchExpressions:
174+
description: A list of node selector requirements by
175+
node's labels.
176+
items:
177+
description: |-
178+
A node selector requirement is a selector that contains values, a key, and an operator
179+
that relates the key and values.
180+
properties:
181+
key:
182+
description: The label key that the selector applies
183+
to.
184+
type: string
185+
operator:
186+
description: |-
187+
Represents a key's relationship to a set of values.
188+
Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.
189+
type: string
190+
values:
191+
description: |-
192+
An array of string values. If the operator is In or NotIn,
193+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
194+
the values array must be empty. If the operator is Gt or Lt, the values
195+
array must have a single element, which will be interpreted as an integer.
196+
This array is replaced during a strategic merge patch.
197+
items:
198+
type: string
199+
type: array
200+
x-kubernetes-list-type: atomic
201+
required:
202+
- key
203+
- operator
204+
type: object
205+
type: array
206+
x-kubernetes-list-type: atomic
207+
matchFields:
208+
description: A list of node selector requirements by
209+
node's fields.
210+
items:
211+
description: |-
212+
A node selector requirement is a selector that contains values, a key, and an operator
213+
that relates the key and values.
214+
properties:
215+
key:
216+
description: The label key that the selector applies
217+
to.
218+
type: string
219+
operator:
220+
description: |-
221+
Represents a key's relationship to a set of values.
222+
Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.
223+
type: string
224+
values:
225+
description: |-
226+
An array of string values. If the operator is In or NotIn,
227+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
228+
the values array must be empty. If the operator is Gt or Lt, the values
229+
array must have a single element, which will be interpreted as an integer.
230+
This array is replaced during a strategic merge patch.
231+
items:
232+
type: string
233+
type: array
234+
x-kubernetes-list-type: atomic
235+
required:
236+
- key
237+
- operator
238+
type: object
239+
type: array
240+
x-kubernetes-list-type: atomic
241+
type: object
242+
x-kubernetes-map-type: atomic
243+
type: array
244+
x-kubernetes-list-type: atomic
245+
required:
246+
- nodeSelectorTerms
247+
type: object
248+
x-kubernetes-map-type: atomic
249+
type: object
250+
deploymentTolerations:
251+
description: Tolerations to inject to the Deployments objects that
252+
are managed by the operator
253+
items:
254+
description: |-
255+
The pod this Toleration is attached to tolerates any taint that matches
256+
the triple <key,value,effect> using the matching operator <operator>.
257+
properties:
258+
effect:
259+
description: |-
260+
Effect indicates the taint effect to match. Empty means match all taint effects.
261+
When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute.
262+
type: string
263+
key:
264+
description: |-
265+
Key is the taint key that the toleration applies to. Empty means match all taint keys.
266+
If the key is empty, operator must be Exists; this combination means to match all values and all keys.
267+
type: string
268+
operator:
269+
description: |-
270+
Operator represents a key's relationship to the value.
271+
Valid operators are Exists and Equal. Defaults to Equal.
272+
Exists is equivalent to wildcard for value, so that a pod can
273+
tolerate all taints of a particular category.
274+
type: string
275+
tolerationSeconds:
276+
description: |-
277+
TolerationSeconds represents the period of time the toleration (which must be
278+
of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default,
279+
it is not set, which means tolerate the taint forever (do not evict). Zero and
280+
negative values will be treated as 0 (evict immediately) by the system.
281+
format: int64
282+
type: integer
283+
value:
284+
description: |-
285+
Value is the taint value the toleration matches to.
286+
If the operator is Exists, the value should be empty, otherwise just a regular string.
287+
type: string
288+
type: object
289+
type: array
51290
docaTelemetryService:
52291
description: |-
53292
DOCATelemetryService exposes telemetry from NVIDIA networking components to prometheus.

0 commit comments

Comments
 (0)