Chakra is a highly customizable Kubernetes scheduler that makes Kubernetes schedule jobs as you want them to be scheduled.
The goal of Chakra is ease of use and flexibility. It is not designed for performance, and is not suitable for production use.
Currently supported policies:
- Random
- Best Fit Binpacking
Chakra runs as a deployment inside your Kubernetes cluster. It watches all pod that have pod.spec.schedulerName set to chakra
, and schedules them according to the chosen policy.
To use Chakra:
- Launch the Chakra deployment
# Setup permissions
kubectl apply -f chakra_admin.yaml
# You can configure the policy being deployed by editing chakra.yaml
kubectl apply -f chakra.yaml
- Submit pods with
pod.spec.schedulerName
set tochakra
and make sure resource limits and requests are the same. For example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
template:
spec:
schedulerName: chakra # <--- This is critical! This is how the pod is assigned to Chakra for scheduling.
containers:
resources:
requests:
cpu: 1
nvidia.com/gpu: 1
limits: # Must be same as requests
cpu: 1
nvidia.com/gpu: 1
...
- Check logs with
kubectl logs -f chakra-<pod-id>
cd tests
# Create a 3 node kind cluster
kind create cluster --config kind-cluster.yaml
# Add fake GPU resources to these nodes:
# Before running this script, run `kubectl proxy` in a separate terminal.
python add_gpus_kind.py
# Now you can experimeent with this cluster by submitting nginx pods with schedulerName set to chakra. This yaml also uses the fake GPUs.
kubectl apply -f nginx.yaml
You can also run Chakra outside of Kubernetes using --kubeconfig
flag to point to a kubeconfig file. This is useful for development and debugging.
# Random policy
python3 -m chakra.main --policy random --kubeconfig ~/.kube/config
# Binpacking policy
python3 -m chakra.main --policy binpack --policy-args '{"binpacking_resource": "cpu"}' --kubeconfig ~/.kube/config
Take a look at chakra/policies.py. You'll need to inherit from BaseClass
and implement the get_allocation
method.
- Please report!