diff --git a/.changes/unreleased/Changed-20260726-120000.yaml b/.changes/unreleased/Changed-20260726-120000.yaml new file mode 100644 index 0000000..ce74790 --- /dev/null +++ b/.changes/unreleased/Changed-20260726-120000.yaml @@ -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 diff --git a/README.md b/README.md index 213fb45..4ddb422 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/USAGE.md b/USAGE.md new file mode 100644 index 0000000..8faf893 --- /dev/null +++ b/USAGE.md @@ -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) +```