Skip to content

Commit 0ffffd0

Browse files
committed
apply format change
1 parent e1fa6ef commit 0ffffd0

File tree

14 files changed

+369
-234
lines changed

14 files changed

+369
-234
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ lint-config: golangci-lint ## Verify golangci-lint linter configuration
108108
build: manifests generate fmt vet ## Build manager binary.
109109
go build -o bin/manager cmd/main.go
110110

111+
.PHONY: build-cli
112+
build-cli: ## Build dag-cli binary.
113+
go build -o bin/dag-cli cmd/dag-cli/main.go
114+
115+
.PHONY: compile-dags
116+
compile-dags: build-cli ## Compile DAG definitions to YAML manifests.
117+
./bin/dag-cli compile
118+
111119
.PHONY: run
112120
run: manifests generate fmt vet ## Run a controller from your host.
113121
go run ./cmd/main.go

README.md

Lines changed: 201 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,255 @@
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
312

413
## Getting Started
514

615
### 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)
1020

11-
### To Deploy on cluster
12-
1. Build & push your image to location specified by `IMG`:
21+
## Quick Start: Local Development
1322

23+
### 1. Create a local cluster
1424
```sh
15-
make docker-build docker-push IMG=<some-registry>/nautikus:tag
25+
kind create cluster --name nautikus
1626
```
1727

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+
```
1933

34+
### 3. Install CRDs and deploy controller
2035
```sh
2136
make install
37+
make deploy IMG=nautikus:v1
2238
```
2339

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+
```
2544

45+
### 5. Compile and run a DAG
46+
47+
**Option A: Use pre-defined YAML**
2648
```sh
27-
make deploy IMG=<some-registry>/nautikus:tag
49+
kubectl apply -f config/samples/workflow_v1_dag_test.yaml
2850
```
2951

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
3160

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+
```
3467

68+
### CLI Options
3569
```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
3784
```
3885

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
4096

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+
```
43100

101+
### 7. Cleanup
44102
```sh
45-
kubectl delete -k config/samples/
103+
kubectl delete dags --all
104+
make undeploy
105+
make uninstall
106+
kind delete cluster --name nautikus
46107
```
47108

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+
```
49153

154+
Then compile and apply:
50155
```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
52168
```
53169

54-
3. UnDeploy the controller from cluster:
170+
## Production Deployment
55171

172+
### 1. Build & push your image
56173
```sh
57-
make undeploy
174+
make docker-build docker-push IMG=<your-registry>/nautikus:tag
58175
```
59176

60-
## How to test in local
177+
### 2. Install CRDs
178+
```sh
179+
make install
180+
```
61181

62-
1. **Create a local cluster**
182+
### 3. Deploy controller
63183
```sh
64-
kind create cluster --name nautikus
184+
make deploy IMG=<your-registry>/nautikus:tag
65185
```
66186

67-
2. **Build and load image**
187+
### 4. Create DAG instances
68188
```sh
69-
make docker-build IMG=nautikus:v1
70-
kind load docker-image nautikus:v1 --name nautikus
189+
kubectl apply -k config/samples/
71190
```
72191

73-
3. **Deploy controller**
192+
## Uninstall
193+
194+
### 1. Delete DAG instances
74195
```sh
75-
make deploy IMG=nautikus:v1
196+
kubectl delete -k config/samples/
76197
```
77198

78-
4. **Verify deployment**
199+
### 2. Remove CRDs
79200
```sh
80-
kubectl get pods -n nautikus-system
201+
make uninstall
81202
```
82203

83-
5. **Run a test DAG**
204+
### 3. Undeploy controller
84205
```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
88207
```
89208

90-
6. **Cleanup**
209+
## Development
210+
211+
### Run tests
91212
```sh
92-
kind delete cluster --name nautikus
213+
make test
93214
```
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.

api/v1/dag_types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ type TaskSpec struct {
2020
Dependencies []string `json:"dependencies,omitempty"` // Parent tasks that must be completed before this task can run
2121

2222
// Execution details for each task type
23-
Command string `json:"command,omitempty"` // For Bash tasks
24-
Script string `json:"script,omitempty"` // For Python/Go code
25-
Image string `json:"image,omitempty"` // Custom container image if needed
23+
Command string `json:"command,omitempty"` // For Bash tasks
24+
Script string `json:"script,omitempty"` // For Python/Go code
25+
Image string `json:"image,omitempty"` // Custom container image if needed
26+
Env map[string]string `json:"env,omitempty"` // Environment variables for the task
2627
}
2728

2829
// DagSpec defines the complete specification of a DAG as defined by the user.

api/v1/zz_generated.deepcopy.go

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)