A lightweight SkyPilot-compatible Kubernetes task launcher that uses the SkyPilot YAML specification.
- API Server (
src/k8s_cli/api/): FastAPI server that handles task operationsmain.py: Application initialization and configurationtasks.py: Task-related endpointsvolumes.py: Volume-related endpoints
- CLI (
src/k8s_cli/cli.py): Command-line interface for interacting with the API server - Kubernetes Executor (
src/k8s_cli/k8s_executor.py): Executes tasks on Kubernetes using kr8s - Task Models (
src/k8s_cli/task_models.py): Pydantic models for task definitions and responses
uv syncuv run python -m k8s_cli.api.mainThe server will start on http://localhost:8000.
Create a task YAML file (e.g., example_task.yaml):
name: my-training-job
num_nodes: 1
resources:
cpus: "2"
memory: "4Gi"
accelerators: "1"
envs:
BATCH_SIZE: "32"
EPOCHS: "10"
setup: |
pip install numpy pandas torch
run: |
python train.pySubmit the task:
uv run k8s-cli submit example_task.yamluv run k8s-cli listWith details:
uv run k8s-cli list --detailsuv run k8s-cli status <task-id>uv run k8s-cli stop <task-id>SKY_K8S_API_URL: API server URL (default:http://localhost:8000)
POST /tasks/submit- Submit a new taskGET /tasks- List all tasksGET /tasks/{task_id}- Get task statusPOST /tasks/{task_id}/stop- Stop a task
Supported fields:
name- Task name (optional)num_nodes- Number of nodes (default: 1)workdir- Working directoryresources- Resource requirementscpus- CPU requirementsmemory- Memory requirementsaccelerators- GPU requirementsimage_id- Container image (default: python:3.11-slim)
envs- Environment variablessetup- Setup commands (run before main command)run- Main command to execute (required)
name: data-processing
resources:
cpus: "4"
memory: "8Gi"
image_id: "python:3.11"
envs:
DATA_PATH: "/data/input"
OUTPUT_PATH: "/data/output"
setup: |
pip install pandas scikit-learn
run: |
python process_data.py --input $DATA_PATH --output $OUTPUT_PATH- Kubernetes cluster access
- Python 3.11+
- kr8s configured with cluster credentials