|
1 | | -# nautikus |
2 | | -// TODO: |
| 1 | +# Nautikus |
| 2 | + |
| 3 | +A Kubernetes-native workflow engine built with the Operator pattern, similar to Apache Airflow. Define DAGs (Directed Acyclic Graphs) as code and let Kubernetes orchestrate your workflows. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- 📝 **Define DAGs in Code**: Write workflows in Go or Python |
| 8 | +- 🔄 **Automatic Compilation**: Convert code to Kubernetes manifests (YAML) |
| 9 | +- 🎯 **Dependency Management**: Define task dependencies with ease |
| 10 | +- 🚀 **Native Kubernetes**: Runs as a Kubernetes controller |
| 11 | +- 🔧 **Multiple Task Types**: Support for Bash, Python, and Go tasks |
3 | 12 |
|
4 | 13 | ## Getting Started |
5 | 14 |
|
6 | 15 | ### Prerequisites |
7 | | -- go (version v1.24.6+). |
8 | | -- docker (version 17.03+). |
9 | | -- kubectl (version v1.11.3+). |
| 16 | +- Go (version v1.24.6+) |
| 17 | +- Docker (version 17.03+) |
| 18 | +- kubectl (version v1.11.3+) |
| 19 | +- kind (for local testing) |
10 | 20 |
|
11 | | -### To Deploy on cluster |
12 | | -1. Build & push your image to location specified by `IMG`: |
| 21 | +## Quick Start: Local Development |
13 | 22 |
|
| 23 | +### 1. Create a local cluster |
14 | 24 | ```sh |
15 | | -make docker-build docker-push IMG=<some-registry>/nautikus:tag |
| 25 | +kind create cluster --name nautikus |
16 | 26 | ``` |
17 | 27 |
|
18 | | -2. Install the CRDs into the cluster: |
| 28 | +### 2. Build and load image |
| 29 | +```sh |
| 30 | +make docker-build IMG=nautikus:v1 |
| 31 | +kind load docker-image nautikus:v1 --name nautikus |
| 32 | +``` |
19 | 33 |
|
| 34 | +### 3. Install CRDs and deploy controller |
20 | 35 | ```sh |
21 | 36 | make install |
| 37 | +make deploy IMG=nautikus:v1 |
22 | 38 | ``` |
23 | 39 |
|
24 | | -3. Deploy the Manager to the cluster with image specified by `IMG`: |
| 40 | +### 4. Verify deployment |
| 41 | +```sh |
| 42 | +kubectl get pods -n nautikus-system |
| 43 | +``` |
25 | 44 |
|
| 45 | +### 5. Compile and run a DAG |
| 46 | + |
| 47 | +**Option A: Use pre-defined YAML** |
26 | 48 | ```sh |
27 | | -make deploy IMG=<some-registry>/nautikus:tag |
| 49 | +kubectl apply -f config/samples/workflow_v1_dag_test.yaml |
28 | 50 | ``` |
29 | 51 |
|
30 | | -> If you encounter RBAC errors, you may need to grant yourself cluster-admin privileges or be logged in as admin. |
| 52 | +**Option B: Define DAG in code and compile** |
| 53 | +```sh |
| 54 | +# Using go run |
| 55 | +go run cmd/dag-cli/main.go compile |
| 56 | + |
| 57 | +# Or build the CLI first |
| 58 | +make build-cli |
| 59 | +./bin/dag-cli compile |
31 | 60 |
|
32 | | -4. Create instances of your solution. |
33 | | -You can apply samples from config/sample: |
| 61 | +# Or use make target |
| 62 | +make compile-dags |
| 63 | + |
| 64 | +# Apply the generated YAML |
| 65 | +kubectl apply -f dist/go_dag.yaml |
| 66 | +``` |
34 | 67 |
|
| 68 | +### CLI Options |
35 | 69 | ```sh |
36 | | -kubectl apply -k config/samples/ |
| 70 | +# View all available commands |
| 71 | +./bin/dag-cli --help |
| 72 | + |
| 73 | +# View compile command options |
| 74 | +./bin/dag-cli compile --help |
| 75 | + |
| 76 | +# Compile with custom config and output directory |
| 77 | +./bin/dag-cli compile --config my-config.yaml --out output/ |
| 78 | + |
| 79 | +# Short flags |
| 80 | +./bin/dag-cli compile -c my-config.yaml -o output/ |
| 81 | + |
| 82 | +# Check version |
| 83 | +./bin/dag-cli version |
37 | 84 | ``` |
38 | 85 |
|
39 | | -> Ensure that samples has default values to test it out. |
| 86 | +### 6. Monitor DAG execution |
| 87 | +```sh |
| 88 | +# Check DAG status |
| 89 | +kubectl get dags |
| 90 | + |
| 91 | +# View detailed status |
| 92 | +kubectl describe dag go-generated-dag |
| 93 | + |
| 94 | +# Check task pods |
| 95 | +kubectl get pods |
40 | 96 |
|
41 | | -### To Uninstall |
42 | | -1. Delete the instances (CRs) from cluster: |
| 97 | +# View controller logs |
| 98 | +kubectl logs -n nautikus-system -l control-plane=controller-manager -f |
| 99 | +``` |
43 | 100 |
|
| 101 | +### 7. Cleanup |
44 | 102 | ```sh |
45 | | -kubectl delete -k config/samples/ |
| 103 | +kubectl delete dags --all |
| 104 | +make undeploy |
| 105 | +make uninstall |
| 106 | +kind delete cluster --name nautikus |
46 | 107 | ``` |
47 | 108 |
|
48 | | -2. Delete the APIs(CRDs) from cluster: |
| 109 | +## Writing DAGs in Code |
| 110 | + |
| 111 | +### Go Example (`test/dags/my_workflow.go`) |
| 112 | + |
| 113 | +```go |
| 114 | +package main |
| 115 | + |
| 116 | +import ( |
| 117 | + "encoding/json" |
| 118 | + "fmt" |
| 119 | + workflowv1 "github.com/kination/nautikus/api/v1" |
| 120 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 121 | +) |
| 122 | + |
| 123 | +func main() { |
| 124 | + dag := workflowv1.Dag{ |
| 125 | + TypeMeta: metav1.TypeMeta{ |
| 126 | + APIVersion: "workflow.nautikus.io/v1", |
| 127 | + Kind: "Dag", |
| 128 | + }, |
| 129 | + ObjectMeta: metav1.ObjectMeta{ |
| 130 | + Name: "my-workflow", |
| 131 | + }, |
| 132 | + Spec: workflowv1.DagSpec{ |
| 133 | + Tasks: []workflowv1.TaskSpec{ |
| 134 | + { |
| 135 | + Name: "task-1", |
| 136 | + Type: workflowv1.TaskTypeBash, |
| 137 | + Command: "echo 'Hello from Task 1'", |
| 138 | + }, |
| 139 | + { |
| 140 | + Name: "task-2", |
| 141 | + Type: workflowv1.TaskTypePython, |
| 142 | + Dependencies: []string{"task-1"}, |
| 143 | + Script: "print('Hello from Task 2')", |
| 144 | + }, |
| 145 | + }, |
| 146 | + }, |
| 147 | + } |
| 148 | + |
| 149 | + output, _ := json.MarshalIndent(dag, "", " ") |
| 150 | + fmt.Println(string(output)) |
| 151 | +} |
| 152 | +``` |
49 | 153 |
|
| 154 | +Then compile and apply: |
50 | 155 | ```sh |
51 | | -make uninstall |
| 156 | +# Using the CLI binary |
| 157 | +make build-cli |
| 158 | +./bin/dag-cli compile |
| 159 | + |
| 160 | +# Or using go run |
| 161 | +go run cmd/dag-cli/main.go compile |
| 162 | + |
| 163 | +# Or using make target |
| 164 | +make compile-dags |
| 165 | + |
| 166 | +# Apply the generated manifest |
| 167 | +kubectl apply -f dist/my_workflow.yaml |
52 | 168 | ``` |
53 | 169 |
|
54 | | -3. UnDeploy the controller from cluster: |
| 170 | +## Production Deployment |
55 | 171 |
|
| 172 | +### 1. Build & push your image |
56 | 173 | ```sh |
57 | | -make undeploy |
| 174 | +make docker-build docker-push IMG=<your-registry>/nautikus:tag |
58 | 175 | ``` |
59 | 176 |
|
60 | | -## How to test in local |
| 177 | +### 2. Install CRDs |
| 178 | +```sh |
| 179 | +make install |
| 180 | +``` |
61 | 181 |
|
62 | | -1. **Create a local cluster** |
| 182 | +### 3. Deploy controller |
63 | 183 | ```sh |
64 | | -kind create cluster --name nautikus |
| 184 | +make deploy IMG=<your-registry>/nautikus:tag |
65 | 185 | ``` |
66 | 186 |
|
67 | | -2. **Build and load image** |
| 187 | +### 4. Create DAG instances |
68 | 188 | ```sh |
69 | | -make docker-build IMG=nautikus:v1 |
70 | | -kind load docker-image nautikus:v1 --name nautikus |
| 189 | +kubectl apply -k config/samples/ |
71 | 190 | ``` |
72 | 191 |
|
73 | | -3. **Deploy controller** |
| 192 | +## Uninstall |
| 193 | + |
| 194 | +### 1. Delete DAG instances |
74 | 195 | ```sh |
75 | | -make deploy IMG=nautikus:v1 |
| 196 | +kubectl delete -k config/samples/ |
76 | 197 | ``` |
77 | 198 |
|
78 | | -4. **Verify deployment** |
| 199 | +### 2. Remove CRDs |
79 | 200 | ```sh |
80 | | -kubectl get pods -n nautikus-system |
| 201 | +make uninstall |
81 | 202 | ``` |
82 | 203 |
|
83 | | -5. **Run a test DAG** |
| 204 | +### 3. Undeploy controller |
84 | 205 | ```sh |
85 | | -kubectl apply -f config/samples/workflow_v1_dag_test.yaml |
86 | | -kubectl get dags |
87 | | -kubectl logs -n nautikus-system -l control-plane=controller-manager |
| 206 | +make undeploy |
88 | 207 | ``` |
89 | 208 |
|
90 | | -6. **Cleanup** |
| 209 | +## Development |
| 210 | + |
| 211 | +### Run tests |
91 | 212 | ```sh |
92 | | -kind delete cluster --name nautikus |
| 213 | +make test |
93 | 214 | ``` |
| 215 | + |
| 216 | +### Run E2E tests |
| 217 | +```sh |
| 218 | +make test-e2e |
| 219 | +``` |
| 220 | + |
| 221 | +### Run controller locally (without Docker) |
| 222 | +```sh |
| 223 | +make run |
| 224 | +``` |
| 225 | + |
| 226 | +### Generate code and manifests |
| 227 | +```sh |
| 228 | +make manifests # Generate CRDs |
| 229 | +make generate # Generate DeepCopy methods |
| 230 | +``` |
| 231 | + |
| 232 | +## Project Structure |
| 233 | + |
| 234 | +``` |
| 235 | +nautikus/ |
| 236 | +├── api/v1/ # CRD definitions |
| 237 | +├── cmd/ |
| 238 | +│ ├── main.go # Controller entrypoint |
| 239 | +│ └── dag-cli/ # DAG compiler CLI |
| 240 | +├── internal/ |
| 241 | +│ ├── controller/ # Reconciliation logic |
| 242 | +│ └── compiler/ # Code-to-YAML compiler |
| 243 | +├── config/ # Kubernetes manifests |
| 244 | +│ ├── crd/ # CRD definitions |
| 245 | +│ ├── rbac/ # RBAC rules |
| 246 | +│ └── samples/ # Example DAGs |
| 247 | +├── test/dags/ # Example DAG definitions |
| 248 | +└── dist/ # Compiled YAML output (gitignored) |
| 249 | +``` |
| 250 | + |
| 251 | +## License |
| 252 | + |
| 253 | +Copyright 2025. |
| 254 | + |
| 255 | +Licensed under the Apache License, Version 2.0. |
0 commit comments