Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/unreleased/Changed-20260726-120000.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: Changed
body: Move Usage section from README to USAGE.md and bump install snippet to v0.1.1.
custom:
Issue: "12"
Author: SiorMeir
60 changes: 6 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@


# KAI Scheduler API

> [!WARNING]
> 🚧 **Work in progress** 🚧
>
> This module is still under active development 🛠️.
>
> APIs may change without notice, and it is not yet recommended for direct production use ⚠️.
>
> 🚧 **Work in progress** 🚧
>
> This module is still under active development. APIs may change without notice and direct production use is not yet recommended.
>
> For now, consume it through KAI Scheduler unless you are prepared to track breaking changes closely.


Kubernetes API types and utilities for GPU-aware batch scheduling with KAI Scheduler.

## Overview
Expand All @@ -26,56 +22,12 @@ This module provides the API definitions, generated clients, and utilities for w
## Installation

```bash
go get github.com/kai-scheduler/api@v0.1.0
go get github.com/kai-scheduler/api@v0.1.1
```

## Usage

### Working with Queue Resources

```go
import (
queuev2 "github.com/kai-scheduler/api/scheduling/v2"
"github.com/kai-scheduler/api/client/clientset/versioned"
)

// Create a clientset
config, _ := rest.InClusterConfig()
client, _ := versioned.NewForConfig(config)

// List queues
queues, _ := client.SchedulingV2().Queues().List(context.TODO(), metav1.ListOptions{})
```

### Working with PodGroups

```go
import (
podgroupv2alpha2 "github.com/kai-scheduler/api/scheduling/v2alpha2"
"github.com/kai-scheduler/api/utilities/podgroup"
)

// Calculate preemptibility from priority
preemptibility := podgroup.CalculatePreemptibility("", int32(50))
// Returns v2alpha2.Preemptible (priority < 100 = preemptible)
```

### GPU Resource Utilities

```go
import (
"github.com/kai-scheduler/api/utilities/resources"
)

// Check if pod requests GPU fractions
if resources.RequestsGPUFraction(pod) {
fraction := resources.GetGPUFraction(pod)
memory := resources.GetGPUMemory(pod)
}

// Extract DRA GPU resources
gpuResources, _ := resources.ExtractDRAGPUResources(ctx, pod, k8sClient)
```
See [USAGE.md](USAGE.md) for code examples covering Queue resources, PodGroups, and GPU utilities.

## CRD Manifests

Expand Down
47 changes: 47 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Usage

## Working with Queue Resources

```go
import (
queuev2 "github.com/kai-scheduler/api/scheduling/v2"
"github.com/kai-scheduler/api/client/clientset/versioned"
)

// Create a clientset
config, _ := rest.InClusterConfig()
client, _ := versioned.NewForConfig(config)

// List queues
queues, _ := client.SchedulingV2().Queues().List(context.TODO(), metav1.ListOptions{})
```

## Working with PodGroups

```go
import (
podgroupv2alpha2 "github.com/kai-scheduler/api/scheduling/v2alpha2"
"github.com/kai-scheduler/api/utilities/podgroup"
)

// Calculate preemptibility from priority
preemptibility := podgroup.CalculatePreemptibility("", int32(50))
// Returns v2alpha2.Preemptible (priority < 100 = preemptible)
```

## GPU Resource Utilities

```go
import (
"github.com/kai-scheduler/api/utilities/resources"
)

// Check if pod requests GPU fractions
if resources.RequestsGPUFraction(pod) {
fraction := resources.GetGPUFraction(pod)
memory := resources.GetGPUMemory(pod)
}

// Extract DRA GPU resources
gpuResources, _ := resources.ExtractDRAGPUResources(ctx, pod, k8sClient)
```
Loading