|
1 |
| -# scheduler |
| 1 | +# aida-scheduler |
| 2 | + |
| 3 | +[](https://github.com/aida-dos/aida-scheduler/actions/workflows/test.yml) |
| 4 | + |
| 5 | +## Deployment |
| 6 | + |
| 7 | +```shell |
| 8 | +kubectl apply -f examples/release_scheduler_crd.yaml |
| 9 | +``` |
| 10 | + |
| 11 | +### Build custom docker image |
| 12 | +```shell |
| 13 | +docker build -t aida-scheduler . |
| 14 | +``` |
| 15 | + |
| 16 | +## Development |
| 17 | + |
| 18 | +### Run the aida-controller |
| 19 | + |
| 20 | +First, make sure you have deployed or are running the aida-controller in the cluster by following the instructions in |
| 21 | +the [project repository](https://github.com/aida-dos/aida-controller). |
| 22 | + |
| 23 | +This controller is responsible for the management and reconciliation of the AIDA EdgeDeployments, which are the |
| 24 | +the resource type of our workloads. |
| 25 | + |
| 26 | +### Run the aida-scheduler |
| 27 | + |
| 28 | +To develop aida-scheduler in a Kubernetes cluster we use [ksync](https://github.com/ksync/ksync) |
| 29 | +to sync files between our local system, and the cluster. |
| 30 | + |
| 31 | +1. Install ksync. You can follow ksync installation steps [here](https://github.com/ksync/ksync#installation). |
| 32 | + |
| 33 | +2. Create a deployment where we will run the scheduler by applying the |
| 34 | + [example/dev_scheduler_crd.yaml](example/dev_scheduler_crd.yaml). |
| 35 | + ```shell |
| 36 | + kubectl apply -f example/dev_scheduler_crd.yaml |
| 37 | + ``` |
| 38 | + |
| 39 | +3. If not done before then create a ksync configuration for the current folder. |
| 40 | + ```shell |
| 41 | + ksync create --selector=component=aida-scheduler --reload=false --local-read-only=true $(pwd) /code |
| 42 | + ``` |
| 43 | + |
| 44 | +4. Start ksync update system |
| 45 | + ```shell |
| 46 | + ksync watch |
| 47 | + ``` |
| 48 | + |
| 49 | +5. Run the scheduler in the cluster pod |
| 50 | + ```shell |
| 51 | + kubectl exec -it $(kubectl get pod -n kube-system | grep aida-scheduler | awk '{print $1}') -- sh |
| 52 | + cd /code |
| 53 | + go run main.go |
| 54 | + ``` |
| 55 | + |
| 56 | +### Manage nodes |
| 57 | + |
| 58 | +The aida-scheduler only manages Edge nodes, because the main purpose is to allow application workload to be deployed |
| 59 | +near the source of data to be processed. Therefore, the node controller filters nodes by 'node-role.kubernetes.io/edge' |
| 60 | +labels. |
| 61 | + |
| 62 | +- To add the label |
| 63 | + ```shell |
| 64 | + kubectl label node node0 --overwrite node-role.kubernetes.io/edge= |
| 65 | + ``` |
| 66 | + |
| 67 | +- To remove the label |
| 68 | + ```shell |
| 69 | + kubectl label node node0 --overwrite node-role.kubernetes.io/edge- |
| 70 | + ``` |
| 71 | + |
| 72 | +### Deploy workloads |
| 73 | + |
| 74 | +Apply any of the workload [examples](examples) |
| 75 | + |
| 76 | +- No location set |
| 77 | + ```shell |
| 78 | + kubectl apply -f examples/workload_no_set_location.yaml |
| 79 | + ``` |
| 80 | + |
| 81 | +- Required location |
| 82 | + ```shell |
| 83 | + kubectl apply -f examples/workload_required_location.yaml |
| 84 | + ``` |
| 85 | + |
| 86 | +- Preferred location |
| 87 | + ```shell |
| 88 | + kubectl apply -f examples/workload_preferred_location.yaml |
| 89 | + ``` |
| 90 | + |
| 91 | +### Lint |
| 92 | +```shell |
| 93 | +go install github.com/golangci/golangci-lint/cmd/[email protected] |
| 94 | +golangci-lint ./... |
| 95 | +``` |
| 96 | + |
| 97 | +### Testing and Coverage |
| 98 | +```shell |
| 99 | +go test --coverprofile=coverage.out ./... |
| 100 | +go tool cover -html=coverage.out |
| 101 | +``` |
| 102 | + |
| 103 | +### Format |
| 104 | + |
| 105 | +```shell |
| 106 | +go fmt ./... |
| 107 | +``` |
0 commit comments