Skip to content

Commit 2431898

Browse files
committed
Add scheduler deployment
1 parent 3c59bac commit 2431898

File tree

9 files changed

+257
-3
lines changed

9 files changed

+257
-3
lines changed

cmd/scheduler/app/options/options.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ const (
2020
defaultProfilerApiPort = "8182"
2121
defaultVerbosityLevel = 3
2222
defaultMaxConsolidationPreemptees = 16
23-
DefaultDetailedFitError = false
23+
defaultDetailedFitError = false
2424
DefaultPyroscopeMutexProfilerRate = 5
2525
DefaultPyroscopeBlockProfilerRate = 5
2626
defaultNumOfStatusRecordingWorkers = 5
27+
defaultNodePoolLabelKey = "runai/node-pool"
2728
)
2829

2930
// ServerOption is the main context object for the controller manager.
@@ -69,7 +70,7 @@ func (s *ServerOption) AddFlags(fs *pflag.FlagSet) {
6970
// kai-scheduler will ignore pods with scheduler names other than specified with the option
7071
fs.StringVar(&s.SchedulerName, "scheduler-name", defaultSchedulerName, "kai-scheduler will handle pods with the scheduler-name")
7172
fs.BoolVar(&s.RestrictSchedulingNodes, "restrict-node-scheduling", false, "kai-scheduler will allocate jobs only to restricted nodes")
72-
fs.StringVar(&s.NodePoolLabelKey, "nodepool-label-key", "", "The label key by which to filter scheduling nodepool")
73+
fs.StringVar(&s.NodePoolLabelKey, "nodepool-label-key", defaultNodePoolLabelKey, "The label key by which to filter scheduling nodepool")
7374
fs.StringVar(&s.NodePoolLabelValue, "partition-label-value", "", "The label value by which to filter scheduling partition")
7475
fs.StringVar(&s.SchedulerConf, "scheduler-conf", "", "The absolute path of scheduler configuration file")
7576
fs.DurationVar(&s.SchedulePeriod, "schedule-period", defaultSchedulerPeriod, "The period between each scheduling cycle")
@@ -88,7 +89,7 @@ func (s *ServerOption) AddFlags(fs *pflag.FlagSet) {
8889
fs.IntVar(&s.MaxNumberConsolidationPreemptees, "max-consolidation-preemptees", defaultMaxConsolidationPreemptees, "Maximum number of consolidation preemptees. Defaults to 16")
8990
fs.IntVar(&s.QPS, "qps", 50, "Queries per second to the K8s API server")
9091
fs.IntVar(&s.Burst, "burst", 300, "Burst to the K8s API server")
91-
fs.BoolVar(&s.DetailedFitErrors, "detailed-fit-errors", DefaultDetailedFitError, "Write detailed fit errors for every node on every podgroup")
92+
fs.BoolVar(&s.DetailedFitErrors, "detailed-fit-errors", defaultDetailedFitError, "Write detailed fit errors for every node on every podgroup")
9293
fs.BoolVar(&s.ScheduleCSIStorage, "schedule-csi-storage", false, "Enables advanced scheduling (preempt, reclaim) for csi storage objects")
9394
fs.BoolVar(&s.UseSchedulingSignatures, "use-scheduling-signatures", true, "Use scheduling signatures to avoid duplicate scheduling attempts for identical jobs")
9495
fs.BoolVar(&s.FullHierarchyFairness, "full-hierarchy-fairness", true, "Fairness across project and department levels")

cmd/scheduler/app/options/options_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func TestAddFlags(t *testing.T) {
4545
PyroscopeMutexProfilerRate: DefaultPyroscopeMutexProfilerRate,
4646
GlobalDefaultStalenessGracePeriod: defaultStalenessGracePeriod,
4747
NumOfStatusRecordingWorkers: defaultNumOfStatusRecordingWorkers,
48+
NodePoolLabelKey: defaultNodePoolLabelKey,
4849
}
4950

5051
if !reflect.DeepEqual(expected, s) {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2025 NVIDIA CORPORATION
2+
# SPDX-License-Identifier: Apache-2.0
3+
---
4+
apiVersion: rbac.authorization.k8s.io/v1
5+
kind: ClusterRoleBinding
6+
metadata:
7+
name: scheduler
8+
subjects:
9+
- kind: ServiceAccount
10+
name: scheduler
11+
namespace: {{ .Release.Namespace }}
12+
roleRef:
13+
kind: ClusterRole
14+
name: scheduler
15+
apiGroup: rbac.authorization.k8s.io
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Copyright 2025 NVIDIA CORPORATION
2+
# SPDX-License-Identifier: Apache-2.0
3+
---
4+
apiVersion: rbac.authorization.k8s.io/v1
5+
kind: ClusterRole
6+
metadata:
7+
name: scheduler
8+
rules:
9+
- apiGroups:
10+
- ""
11+
resources:
12+
- configmaps
13+
- events
14+
- persistentvolumeclaims
15+
- pods
16+
- pods/status
17+
- pods/binding
18+
- services
19+
- persistentvolumes
20+
- namespaces
21+
verbs:
22+
- get
23+
- list
24+
- watch
25+
- apiGroups:
26+
- scheduling.run.ai
27+
resources:
28+
- bindrequests
29+
- podgroups
30+
- podgroups/status
31+
- queues
32+
verbs:
33+
- get
34+
- list
35+
- watch
36+
- apiGroups:
37+
- ""
38+
resources:
39+
- nodes
40+
verbs:
41+
- get
42+
- list
43+
- watch
44+
- patch
45+
- apiGroups:
46+
- storage.k8s.io
47+
resources:
48+
- storageclasses
49+
- csinodes
50+
- csidrivers
51+
- csistoragecapacities
52+
verbs:
53+
- get
54+
- list
55+
- watch
56+
- apiGroups:
57+
- policy
58+
resources:
59+
- poddisruptionbudgets
60+
verbs:
61+
- get
62+
- list
63+
- watch
64+
- apiGroups:
65+
- scheduling.k8s.io
66+
resources:
67+
- priorityclasses
68+
verbs:
69+
- get
70+
- list
71+
- watch
72+
- apiGroups:
73+
- resource.k8s.io
74+
resources:
75+
- deviceclasses
76+
- resourceslices
77+
- resourceclaims
78+
verbs:
79+
- get
80+
- list
81+
- watch
82+
- apiGroups:
83+
- ""
84+
resources:
85+
- configmaps
86+
- events
87+
- persistentvolumeclaims
88+
- pods
89+
- pods/status
90+
- pods/binding
91+
- pods/finalizers
92+
- services
93+
- services/finalizers
94+
verbs:
95+
- create
96+
- delete
97+
- get
98+
- list
99+
- patch
100+
- update
101+
- apiGroups:
102+
- scheduling.run.ai
103+
resources:
104+
- bindrequests
105+
- podgroups
106+
- podgroups/status
107+
verbs:
108+
- create
109+
- delete
110+
- get
111+
- list
112+
- patch
113+
- update
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2025 NVIDIA CORPORATION
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: v1
5+
data:
6+
config.yaml: |
7+
actions: allocate, consolidation, reclaim, preempt, stalegangeviction
8+
tiers:
9+
- plugins:
10+
- name: predicates
11+
- name: proportion
12+
- name: priority
13+
- name: nodeavailability
14+
- name: resourcetype
15+
- name: podaffinity
16+
- name: elastic
17+
- name: kubeflow
18+
- name: ray
19+
- name: taskorder
20+
- name: nominatednode
21+
- name: dynamicresources
22+
- name: gpupack
23+
- name: gpusharingorder
24+
- name: nodeplacement
25+
arguments:
26+
cpu: {{ .Values.scheduler.placementStrategy }}
27+
gpu: {{ .Values.scheduler.placementStrategy }}
28+
kind: ConfigMap
29+
metadata:
30+
labels:
31+
app: scheduler
32+
name: scheduler-config
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2025 NVIDIA CORPORATION
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: v1
5+
kind: Service
6+
metadata:
7+
name: scheduler
8+
spec:
9+
selector:
10+
app: scheduler
11+
ports:
12+
- name: http-metrics
13+
protocol: TCP
14+
port: {{ .Values.scheduler.ports.metricsPort }}
15+
targetPort: {{ .Values.scheduler.ports.metricsPort }}
16+
sessionAffinity: None
17+
type: ClusterIP
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright 2025 NVIDIA CORPORATION
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: v1
5+
kind: ServiceAccount
6+
metadata:
7+
name: scheduler
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2025 NVIDIA CORPORATION
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
apiVersion: apps/v1
5+
kind: Deployment
6+
metadata:
7+
name: scheduler
8+
spec:
9+
replicas: 1
10+
strategy:
11+
type: Recreate
12+
selector:
13+
matchLabels:
14+
app: scheduler
15+
template:
16+
metadata:
17+
labels:
18+
app: scheduler
19+
spec:
20+
serviceAccountName: scheduler
21+
containers:
22+
- name: scheduler
23+
image: "{{ .Values.global.registry }}/{{ .Values.scheduler.image.name }}:{{ .Chart.Version }}"
24+
imagePullPolicy: {{ .Values.scheduler.image.pullPolicy }}
25+
args:
26+
- --scheduler-conf=/etc/config/config.yaml
27+
{{- if .Values.scheduler.additionalArgs }}
28+
{{- toYaml .Values.scheduler.additionalArgs | nindent 12 }}
29+
{{- end }}
30+
{{- if .Values.scheduler.resources }}
31+
resources:
32+
{{- toYaml .Values.scheduler.resources | nindent 12 }}
33+
{{- end }}
34+
{{- if .Values.global.securityContext }}
35+
securityContext:
36+
{{- toYaml .Values.global.securityContext | nindent 12 }}
37+
{{- end }}
38+
ports:
39+
- name: metrics
40+
containerPort: {{ .Values.scheduler.ports.metricsPort }}
41+
volumeMounts:
42+
- name: config
43+
subPath: "config.yaml"
44+
mountPath: "/etc/config/config.yaml"
45+
{{- if .Values.global.imagePullSecrets }}
46+
imagePullSecrets:
47+
{{- toYaml .Values.global.imagePullSecrets | nindent 8 }}
48+
{{- end }}
49+
volumes:
50+
- name: config
51+
configMap:
52+
name: scheduler-config

deployments/kai-scheduler/values.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@ binder:
4343
cpu: "250m"
4444
memory: "128Mi"
4545

46+
scheduler:
47+
image:
48+
name: scheduler
49+
pullPolicy: IfNotPresent
50+
additionalArgs: []
51+
placementStrategy: binpack
52+
ports:
53+
metricsPort: 8080
54+
resources:
55+
limits:
56+
cpu: "500m"
57+
memory: "256Mi"
58+
requests:
59+
cpu: "250m"
60+
memory: "128Mi"
61+
4662
webhookmanager:
4763
image:
4864
name: webhookmanager

0 commit comments

Comments
 (0)