Skip to content

Commit 372fa45

Browse files
support NodeAffinity filter (#230)
* support NodeAffinity * use original affinity * fix(filter): fetch Node via cache client in NodeAffinityFilter and update tests --------- Co-authored-by: 0x5457 <[email protected]>
1 parent 5eefc6d commit 372fa45

10 files changed

+1254
-0
lines changed

api/v1/workloadprofile_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1
1818

1919
import (
20+
v1 "k8s.io/api/core/v1"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122
)
2223

@@ -67,6 +68,10 @@ type WorkloadProfileSpec struct {
6768
// This field can not be fully supported in annotation, if user want to enable auto-scaling in annotation,
6869
// user can set tensor-fusion.ai/auto-limits|requests|replicas: 'true'
6970
AutoScalingConfig AutoScalingConfig `json:"autoScalingConfig,omitempty"`
71+
72+
// +optional
73+
// NodeAffinity specifies the node affinity requirements for the workload
74+
NodeAffinity *v1.NodeAffinity `json:"nodeAffinity,omitempty"`
7075
}
7176

7277
// WorkloadProfileStatus defines the observed state of WorkloadProfile.

api/v1/zz_generated.deepcopy.go

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

charts/tensor-fusion/crds/tensor-fusion.ai_tensorfusionworkloads.yaml

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,205 @@ spec:
183183
description: Schedule the workload to the same GPU server that runs
184184
vGPU worker for best performance, default to false
185185
type: boolean
186+
nodeAffinity:
187+
description: NodeAffinity specifies the node affinity requirements
188+
for the workload
189+
properties:
190+
preferredDuringSchedulingIgnoredDuringExecution:
191+
description: |-
192+
The scheduler will prefer to schedule pods to nodes that satisfy
193+
the affinity expressions specified by this field, but it may choose
194+
a node that violates one or more of the expressions. The node that is
195+
most preferred is the one with the greatest sum of weights, i.e.
196+
for each node that meets all of the scheduling requirements (resource
197+
request, requiredDuringScheduling affinity expressions, etc.),
198+
compute a sum by iterating through the elements of this field and adding
199+
"weight" to the sum if the node matches the corresponding matchExpressions; the
200+
node(s) with the highest sum are the most preferred.
201+
items:
202+
description: |-
203+
An empty preferred scheduling term matches all objects with implicit weight 0
204+
(i.e. it's a no-op). A null preferred scheduling term matches no objects (i.e. is also a no-op).
205+
properties:
206+
preference:
207+
description: A node selector term, associated with the corresponding
208+
weight.
209+
properties:
210+
matchExpressions:
211+
description: A list of node selector requirements by
212+
node's labels.
213+
items:
214+
description: |-
215+
A node selector requirement is a selector that contains values, a key, and an operator
216+
that relates the key and values.
217+
properties:
218+
key:
219+
description: The label key that the selector applies
220+
to.
221+
type: string
222+
operator:
223+
description: |-
224+
Represents a key's relationship to a set of values.
225+
Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.
226+
type: string
227+
values:
228+
description: |-
229+
An array of string values. If the operator is In or NotIn,
230+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
231+
the values array must be empty. If the operator is Gt or Lt, the values
232+
array must have a single element, which will be interpreted as an integer.
233+
This array is replaced during a strategic merge patch.
234+
items:
235+
type: string
236+
type: array
237+
x-kubernetes-list-type: atomic
238+
required:
239+
- key
240+
- operator
241+
type: object
242+
type: array
243+
x-kubernetes-list-type: atomic
244+
matchFields:
245+
description: A list of node selector requirements by
246+
node's fields.
247+
items:
248+
description: |-
249+
A node selector requirement is a selector that contains values, a key, and an operator
250+
that relates the key and values.
251+
properties:
252+
key:
253+
description: The label key that the selector applies
254+
to.
255+
type: string
256+
operator:
257+
description: |-
258+
Represents a key's relationship to a set of values.
259+
Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.
260+
type: string
261+
values:
262+
description: |-
263+
An array of string values. If the operator is In or NotIn,
264+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
265+
the values array must be empty. If the operator is Gt or Lt, the values
266+
array must have a single element, which will be interpreted as an integer.
267+
This array is replaced during a strategic merge patch.
268+
items:
269+
type: string
270+
type: array
271+
x-kubernetes-list-type: atomic
272+
required:
273+
- key
274+
- operator
275+
type: object
276+
type: array
277+
x-kubernetes-list-type: atomic
278+
type: object
279+
x-kubernetes-map-type: atomic
280+
weight:
281+
description: Weight associated with matching the corresponding
282+
nodeSelectorTerm, in the range 1-100.
283+
format: int32
284+
type: integer
285+
required:
286+
- preference
287+
- weight
288+
type: object
289+
type: array
290+
x-kubernetes-list-type: atomic
291+
requiredDuringSchedulingIgnoredDuringExecution:
292+
description: |-
293+
If the affinity requirements specified by this field are not met at
294+
scheduling time, the pod will not be scheduled onto the node.
295+
If the affinity requirements specified by this field cease to be met
296+
at some point during pod execution (e.g. due to an update), the system
297+
may or may not try to eventually evict the pod from its node.
298+
properties:
299+
nodeSelectorTerms:
300+
description: Required. A list of node selector terms. The
301+
terms are ORed.
302+
items:
303+
description: |-
304+
A null or empty node selector term matches no objects. The requirements of
305+
them are ANDed.
306+
The TopologySelectorTerm type implements a subset of the NodeSelectorTerm.
307+
properties:
308+
matchExpressions:
309+
description: A list of node selector requirements by
310+
node's labels.
311+
items:
312+
description: |-
313+
A node selector requirement is a selector that contains values, a key, and an operator
314+
that relates the key and values.
315+
properties:
316+
key:
317+
description: The label key that the selector applies
318+
to.
319+
type: string
320+
operator:
321+
description: |-
322+
Represents a key's relationship to a set of values.
323+
Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.
324+
type: string
325+
values:
326+
description: |-
327+
An array of string values. If the operator is In or NotIn,
328+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
329+
the values array must be empty. If the operator is Gt or Lt, the values
330+
array must have a single element, which will be interpreted as an integer.
331+
This array is replaced during a strategic merge patch.
332+
items:
333+
type: string
334+
type: array
335+
x-kubernetes-list-type: atomic
336+
required:
337+
- key
338+
- operator
339+
type: object
340+
type: array
341+
x-kubernetes-list-type: atomic
342+
matchFields:
343+
description: A list of node selector requirements by
344+
node's fields.
345+
items:
346+
description: |-
347+
A node selector requirement is a selector that contains values, a key, and an operator
348+
that relates the key and values.
349+
properties:
350+
key:
351+
description: The label key that the selector applies
352+
to.
353+
type: string
354+
operator:
355+
description: |-
356+
Represents a key's relationship to a set of values.
357+
Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt.
358+
type: string
359+
values:
360+
description: |-
361+
An array of string values. If the operator is In or NotIn,
362+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
363+
the values array must be empty. If the operator is Gt or Lt, the values
364+
array must have a single element, which will be interpreted as an integer.
365+
This array is replaced during a strategic merge patch.
366+
items:
367+
type: string
368+
type: array
369+
x-kubernetes-list-type: atomic
370+
required:
371+
- key
372+
- operator
373+
type: object
374+
type: array
375+
x-kubernetes-list-type: atomic
376+
type: object
377+
x-kubernetes-map-type: atomic
378+
type: array
379+
x-kubernetes-list-type: atomic
380+
required:
381+
- nodeSelectorTerms
382+
type: object
383+
x-kubernetes-map-type: atomic
384+
type: object
186385
poolName:
187386
type: string
188387
qos:

0 commit comments

Comments
 (0)