Skip to content

Commit

Permalink
Improve samples
Browse files Browse the repository at this point in the history
  + Add README to highlight podSet inference
  + Add LeaderWorkerSet example
  • Loading branch information
dgrove-oss committed Jan 15, 2025
1 parent 640b4c0 commit 2940e13
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
28 changes: 28 additions & 0 deletions samples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Sample AppWrappers

This directory contains a number of example yamls showing how to wrap
different Pod-creating Kubernetes resources in an AppWrapper.
AppWrappers can be used to wrap any Kubernetes Kind that uses `PodSpecTemplate`
to express its Pods.

An AppWrapper contains a `component` array of `AppWrapperComponents`.
Each component has two main pieces: a `template` that defines the wrapped resource
and a `podSets` array that gives the `replicas` and `path` within the template
for each `PodSpecTemplate`. For correct operation of the AppWrapper, it is
required that the provided `path` and `replicas` information correctly represent
the Pod creating behavior of the wrapped resource.

To simplify the user experience, for a selection of commonly-used Kubernetes
resource Kinds, the AppWrapper controller can automatically infer the `podSets`
array if it is not provided. For these same kinds, the AppWrapper controller
will validate that any explicitly provided `podSet` entries match the definitions in
`template`. The current set of automatically inferred Kinds is:
+ v1 Pod
+ apps/v1 Deployment
+ apps/v1 StatefulSet
+ batch/v1 Job
+ kubeflow.org/v1 PyTorchJob
+ ray.io/v1 RayCluster
+ ray.io/v1 RayJob
In all the examples, if the Kind supports automatic inference the `podSets`
are elided.
44 changes: 44 additions & 0 deletions samples/wrapped-leader-worker-set.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: workload.codeflare.dev/v1beta2
kind: AppWrapper
metadata:
name: sample-lws
labels:
kueue.x-k8s.io/queue-name: default-queue
spec:
components:
- podSets:
- path: "template.spec.leaderWorkerTemplate.leaderTemplate"
replicas: 2
- path: "template.spec.leaderWorkerTemplate.workerTemplate"
replicas: 3
template:
apiVersion: leaderworkerset.x-k8s.io/v1
kind: LeaderWorkerSet
metadata:
name: nginx-leaderworkerset
labels:
app: nginx
spec:
replicas: 2
leaderWorkerTemplate:
leaderTemplate:
spec:
containers:
- name: nginx-leader
image: registry.k8s.io/nginx-slim:0.27
resources:
requests:
cpu: "100m"
ports:
- containerPort: 80
size: 3
workerTemplate:
spec:
containers:
- name: nginx-worker
image: nginx:1.14.2
resources:
requests:
cpu: "200m"
ports:
- containerPort: 80

0 comments on commit 2940e13

Please sign in to comment.