11# api Development Guide
22
3- api is a standalone Go module providing Kubernetes API types, generated clients, and utilities for GPU-aware batch scheduling with KAI Scheduler.
3+ ` github.com/kai-scheduler/ api` is a standalone Go module providing Kubernetes API types, generated clients, and utilities for GPU-aware batch scheduling with KAI Scheduler.
44
55## Repository Structure
66
77```
88api/
9- ├── api/scheduling/ # API type definitions (Queue, PodGroup, BindRequest)
10- ├── client/ # Generated clientset, informers, listers
11- ├── config/crd/ # CRD YAML manifests
12- ├── constants/ # Public API constants (GPU annotations, labels)
9+ ├── scheduling/ # scheduling.run.ai types
10+ │ ├── v1alpha2/ # BindRequest, NumaPlacementRequest
11+ │ ├── v2/ # Queue
12+ │ └── v2alpha2/ # PodGroup (+ validating webhook)
13+ ├── kai/
14+ │ └── v1alpha1/ # Topology
15+ ├── client/ # Generated clientset, informers, listers (both groups)
16+ ├── config/crd/ # Generated CRD YAML manifests
17+ ├── constants/ # Public API constants (GPU annotations, labels, priorities)
1318├── utilities/ # Client-facing utilities
1419│ ├── resources/ # GPU sharing, DRA extraction, resource helpers
1520│ └── podgroup/ # PodGroup business logic (preemptibility)
21+ ├── hack/ # Codegen boilerplate + update-client.sh
22+ ├── Makefile
1623├── go.mod
1724├── README.md
1825├── CHANGELOG.md
@@ -21,138 +28,61 @@ api/
2128
2229## What Belongs in This Repository
2330
24- ** Include (Client-Facing API Contracts ):**
25- - API type definitions (Queue, PodGroup, BindRequest)
31+ ** Include (client-facing API contracts ):**
32+ - CRD type definitions with a generated client — the ` scheduling.run.ai ` group and ` kai.scheduler/v1alpha1 ` Topology
2633- Generated Kubernetes clients (clientset, informers, listers)
27- - CRD manifests (YAML definitions)
28- - Constants that are part of the public API (annotations, labels)
29- - Utilities for working with API types (GPU request inspection, DRA support)
30- - Business logic directly referenced in API documentation (preemptibility calculation)
31-
32- ** Exclude (Scheduler Implementation Details):**
33- - Scheduler plugin implementations
34- - Framework handles and infrastructure
35- - Webhook wiring code (operator-specific)
36- - Feature gates (runtime behavior, not API contracts)
37- - Scheduler-specific internal utilities
34+ - CRD manifests (YAML)
35+ - Public-API constants (annotations, labels, priorities)
36+ - Utilities for working with API types (GPU request inspection, DRA support, preemptibility)
37+ - The PodGroup validating webhook (ships with its ` v2alpha2 ` type)
3838
39- ## Building and Testing
40-
41- ### Build
42- ``` bash
43- go build ./...
44- ```
39+ ** Exclude (stays in kai-scheduler):**
40+ - ` kai.scheduler/v1 ` config types (Config, SchedulingShard) — operator-internal, controller-runtime only
41+ - Scheduler-framework glue (` k8s_utils ` ) — pulls ` k8s.io/kubernetes ` ; imports feature gates (would cycle)
42+ - Feature gates and flags (runtime behavior, not API contract)
43+ - Scheduler plugins and infrastructure
4544
46- ### Run Tests
47- ``` bash
48- go test ./...
49- ```
45+ ## Building and Testing
5046
51- ### Linting
52- Use the same linter configuration as kai-scheduler:
5347``` bash
54- golangci-lint run
48+ make build # go build ./...
49+ make test # go test ./...
50+ make lint # gofmt + go vet
5551```
5652
5753## Code Generation
5854
59- Generated clients are created from API types using kubernetes code-generator tools.
60-
61- ** When to regenerate:**
62- - API types are modified (new fields, new versions)
63- - After bumping Kubernetes dependencies
64-
65- ** How to regenerate:**
6655``` bash
67- # TODO: Add code generation scripts when SDK CI/CD is set up
56+ make generate # DeepCopy methods (controller-gen object)
57+ make manifests # CRD manifests into config/crd/ (controller-gen crd)
58+ make clients # clientset, informers, listers (k8s.io/code-generator)
6859```
6960
70- ## Versioning
71-
72- This SDK follows [ Semantic Versioning] ( https://semver.org/ ) :
61+ Regenerate when API types change or after bumping Kubernetes dependencies. ` make manifests ` prepends the
62+ Kubernetes copyright header to ` kai.scheduler_topologies.yaml ` (derived from Kubernetes projects).
7363
74- - ** MAJOR** (v1.x.x → v2.x.x): Breaking API changes
75- - Field removals
76- - Type changes
77- - Renamed resources
64+ ## Versioning & Release
7865
79- - ** MINOR** (v1.0.x → v1.1.x): Backward-compatible additions
80- - New API fields (with defaults)
81- - New utility functions
82- - New CRD versions (with conversion)
66+ Semantic Versioning; ` v0.x ` until the contract is declared stable.
8367
84- - ** PATCH** (v1.0.0 → v1.0.1): Bug fixes and documentation
85- - Bug fixes in utilities
86- - Documentation improvements
87- - Non-breaking dependency updates
88-
89- ## Release Process
90-
91- 1 . Update API types/utilities as needed
92- 2 . Update ` CHANGELOG.md ` with changes
93- 3 . Run tests: ` go test ./... `
94- 4 . Run build: ` go build ./... `
95- 5 . Commit changes
96- 6 . Tag release: ` git tag v0.x.y `
97- 7 . Push tag: ` git push origin v0.x.y `
68+ 1 . Update API types/utilities
69+ 2 . Regenerate (` make generate manifests clients ` )
70+ 3 . Update ` CHANGELOG.md `
71+ 4 . ` make build && make test `
72+ 5 . Commit, tag ` vX.Y.Z ` , push the tag
9873
9974## Local Development with kai-scheduler
10075
101- When making changes to both SDK and kai-scheduler simultaneously:
102-
103- 1 . ** Make SDK changes first** in this repository
104- 2 . ** Test locally** using replace directive in kai-scheduler:
105- ``` go
106- // kai-scheduler/go.mod
107- replace github.com /kai-scheduler/api => ../api
108- ```
109- 3 . ** Run kai-scheduler tests** with local SDK
110- 4 . ** Release SDK** when ready (tag version)
111- 5 . ** Update kai-scheduler** to use released SDK version:
112- ``` bash
113- cd kai-scheduler
114- go get github.com/kai-scheduler/api@v0.x.y
115- # Remove replace directive
116- ```
117-
118- ## Code Style
119-
120- Follow the same conventions as kai-scheduler:
121-
122- ** Imports** : Three groups (stdlib, external, internal)
12376``` go
124- import (
125- " context"
126- " fmt"
127-
128- v1 " k8s.io/api/core/v1"
129- metav1 " k8s.io/apimachinery/pkg/apis/meta/v1"
130-
131- " github.com/kai-scheduler/api/constants"
132- )
77+ // kai-scheduler/go.mod (local only — not committed to release branches)
78+ replace github.com /kai-scheduler/api => ../api
13379```
13480
135- ** Naming** :
136- - Files: snake_case (` gpu_sharing.go ` , ` podgroup.go ` )
137- - Types: PascalCase (` Queue ` , ` PodGroup ` )
138- - Functions: PascalCase exported, camelCase unexported
139- - Boolean functions: ` Is ` /` Has ` /` Should ` prefix
140-
141- ** Comments** :
142- - Apache 2.0 + NVIDIA copyright headers on all files
143- - GoDoc-style for exported functions/types
144- - Avoid obvious comments; explain "why" not "what"
81+ Make API changes here first, test against kai-scheduler via the ` replace ` directive, then release and bump
82+ kai-scheduler with ` go get github.com/kai-scheduler/api@vX.Y.Z ` .
14583
146- ## Contributing
147-
148- Changes to API types should be made in this repository first, then consumed by kai-scheduler.
149-
150- For questions or contributions to the main scheduler, see [ kai-scheduler repository] ( https://github.com/kai-scheduler/KAI-Scheduler ) .
151-
152- ## Known Issues
153-
154- ### Operator API in Generated Clients
155-
156- Generated clients currently include references to ` kai/v1alpha1 ` (Topology CRD), which is operator-specific and should remain in kai-scheduler. This creates a dependency on the kai-scheduler module.
84+ ## Code Style
15785
158- ** Resolution** : Will be addressed when SDK client generation is set up independently. For now, the dependency exists but doesn't affect SDK users who only work with scheduling APIs.
86+ Follow kai-scheduler conventions: three import groups (stdlib, external, internal); snake_case files;
87+ PascalCase exported / camelCase unexported; ` Is ` /` Has ` /` Should ` boolean prefixes; Apache 2.0 + NVIDIA
88+ copyright headers on all files; GoDoc on exported symbols; explain "why" not "what".
0 commit comments