Skip to content

Commit 1aad555

Browse files
committed
Sync API repo with latest KAI-Scheduler main branch
This commit syncs the API repository with the latest changes from the KAI-Scheduler main branch to ensure the API types, clients, and utilities are up to date. Changes: - Updated all scheduling API types (v2alpha2, v2, v1alpha2) with latest changes including MinSubGroup field and validation updates - Added kai/v1 and kai/v1alpha1 API types for KAI component configuration - Added constants/priorities.go for client-facing priority constants - Created config/usagedb package for usage database configuration types - Updated all import paths to use github.com/kai-scheduler/api - Removed scheduler-specific webhook files from v2alpha2 - Synced generated clients (clientset, informers, listers) with latest APIs - Updated go.mod dependencies to match latest Kubernetes versions This sync resolves build errors in kai-scheduler migration that were caused by missing MinSubGroup field and other recent API changes.
1 parent 7f6408d commit 1aad555

65 files changed

Lines changed: 4686 additions & 36 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/kai/v1/admission/admission.go

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// Copyright 2025 NVIDIA CORPORATION
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
// +kubebuilder:object:generate:=true
5+
package admission
6+
7+
import (
8+
"k8s.io/utils/ptr"
9+
10+
"github.com/kai-scheduler/api/api/kai/v1/common"
11+
"github.com/kai-scheduler/api/constants"
12+
)
13+
14+
const (
15+
imageName = "admission"
16+
defaultValidatingWebhookName = "validating-kai-admission"
17+
defaultMutatingWebhookName = "mutating-kai-admission"
18+
)
19+
20+
type Admission struct {
21+
Service *common.Service `json:"service,omitempty"`
22+
23+
// Webhook defines configuration for the admission service
24+
// +kubebuilder:validation:Optional
25+
Webhook *Webhook `json:"webhook,omitempty"`
26+
27+
// Replicas specifies the number of replicas of the admission controller
28+
// +kubebuilder:validation:Optional
29+
Replicas *int32 `json:"replicas,omitempty"`
30+
31+
// GPUSharing enables GPU sharing functionality for the admission service
32+
// +kubebuilder:validation:Optional
33+
GPUSharing *bool `json:"gpuSharing,omitempty"`
34+
35+
// QueueLabelSelector enables the queue label MatchExpression in webhooks
36+
// +kubebuilder:validation:Optional
37+
QueueLabelSelector *bool `json:"queueLabelSelector,omitempty"`
38+
39+
// ValidatingWebhookConfigurationName is the name of the ValidatingWebhookConfiguration for the admission service
40+
// +kubebuilder:validation:Optional
41+
ValidatingWebhookConfigurationName *string `json:"validatingWebhookConfigurationName,omitempty"`
42+
43+
// MutatingWebhookConfigurationName is the name of the MutatingWebhookConfiguration for the admission service
44+
// +kubebuilder:validation:Optional
45+
MutatingWebhookConfigurationName *string `json:"mutatingWebhookConfigurationName,omitempty"`
46+
47+
// GPUPodRuntimeClassName specifies the runtime class to be set for GPU pods
48+
// set to empty string to disable
49+
// +kubebuilder:validation:Optional
50+
GPUPodRuntimeClassName *string `json:"gpuPodRuntimeClassName,omitempty"`
51+
52+
// VPA specifies Vertical Pod Autoscaler configuration for the admission service
53+
// +kubebuilder:validation:Optional
54+
VPA *common.VPASpec `json:"vpa,omitempty"`
55+
}
56+
57+
func (b *Admission) SetDefaultsWhereNeeded(replicaCount *int32, globalVPA *common.VPASpec) {
58+
b.Service = common.SetDefault(b.Service, &common.Service{})
59+
b.Service.SetDefaultsWhereNeeded(imageName)
60+
61+
b.Service.Resources = common.SetDefault(b.Service.Resources, &common.Resources{})
62+
b.Service.Resources.SetDefaultsWhereNeeded()
63+
64+
b.Webhook = common.SetDefault(b.Webhook, &Webhook{})
65+
b.Webhook.SetDefaultsWhereNeeded()
66+
67+
b.Replicas = common.SetDefault(b.Replicas, ptr.To(ptr.Deref(replicaCount, 1)))
68+
b.GPUSharing = common.SetDefault(b.GPUSharing, ptr.To(false))
69+
b.QueueLabelSelector = common.SetDefault(b.QueueLabelSelector, ptr.To(false))
70+
71+
b.ValidatingWebhookConfigurationName = common.SetDefault(b.ValidatingWebhookConfigurationName, ptr.To(defaultValidatingWebhookName))
72+
b.MutatingWebhookConfigurationName = common.SetDefault(b.MutatingWebhookConfigurationName, ptr.To(defaultMutatingWebhookName))
73+
74+
b.GPUPodRuntimeClassName = common.SetDefault(b.GPUPodRuntimeClassName, ptr.To(constants.DefaultRuntimeClassName))
75+
76+
if b.VPA == nil {
77+
b.VPA = globalVPA
78+
}
79+
}
80+
81+
// Webhook defines configuration for the admission webhook
82+
type Webhook struct {
83+
// Port specifies the webhook service port
84+
// +kubebuilder:validation:Optional
85+
Port *int `json:"port,omitempty"`
86+
87+
// TargetPort specifies the webhook service container port
88+
// +kubebuilder:validation:Optional
89+
TargetPort *int `json:"targetPort,omitempty"`
90+
91+
// ProbePort specifies the health and readiness probe port
92+
ProbePort *int `json:"probePort,omitempty"`
93+
94+
// MetricsPort specifies the metrics service port
95+
MetricsPort *int `json:"metricsPort,omitempty"`
96+
}
97+
98+
// SetDefaultsWhereNeeded sets default fields for unset fields
99+
func (w *Webhook) SetDefaultsWhereNeeded() {
100+
w.Port = common.SetDefault(w.Port, ptr.To(443))
101+
w.TargetPort = common.SetDefault(w.TargetPort, ptr.To(9443))
102+
w.ProbePort = common.SetDefault(w.ProbePort, ptr.To(8081))
103+
w.MetricsPort = common.SetDefault(w.MetricsPort, ptr.To(8080))
104+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2025 NVIDIA CORPORATION
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package admission
5+
6+
import (
7+
"context"
8+
"testing"
9+
10+
"github.com/kai-scheduler/api/constants"
11+
. "github.com/onsi/ginkgo/v2"
12+
. "github.com/onsi/gomega"
13+
)
14+
15+
func TestAdmission(t *testing.T) {
16+
RegisterFailHandler(Fail)
17+
RunSpecs(t, "Admission type suite")
18+
}
19+
20+
var _ = Describe("Admission", func() {
21+
It("Set Defaults", func(ctx context.Context) {
22+
Admission := &Admission{}
23+
var replicaCount int32
24+
replicaCount = 1
25+
Admission.SetDefaultsWhereNeeded(&replicaCount, nil)
26+
Expect(*Admission.Service.Enabled).To(Equal(true))
27+
Expect(*Admission.Service.Image.Name).To(Equal("admission"))
28+
Expect(*Admission.Replicas).To(Equal(int32(1)))
29+
Expect(*Admission.GPUPodRuntimeClassName).To(Equal(constants.DefaultRuntimeClassName))
30+
})
31+
It("Set Defaults with replica count", func(ctx context.Context) {
32+
Admission := &Admission{}
33+
var replicaCount int32
34+
replicaCount = 3
35+
Admission.SetDefaultsWhereNeeded(&replicaCount, nil)
36+
Expect(*Admission.Replicas).To(Equal(int32(3)))
37+
})
38+
})

api/kai/v1/admission/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)