Skip to content

Commit f9d3d96

Browse files
committed
Introduce the native CLI
This command line tool overhauls the initial setup for Kubernetes deployments. The new tool gives us more information when something doesn't work out as intended and brings the the cluster setup considerably closer to what one would expect in a production grade system. The nativelink image and worker containers are now fully built in the cluster via Tekton Pipelines. Rebuilds may be triggered with curl requests instead of the old `nix run .#xxx.copyTo` workflow. This makes the setup more generic and provides clearer pointers on how to bring the system into continuously updating production workflows. The `native` tool is technically fully self-contained. The examples still make use of some local paths, but it's now possible to set up the cluster and deploy NativeLink in it without cloning the nativelink repository. This requires slightly modified `01_operations.sh` scripts which we'll add as a new example.
1 parent d854874 commit f9d3d96

33 files changed

+2340
-197
lines changed

.github/styles/config/vocabularies/TraceMachina/accept.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ parsable
2626
rebase
2727
remoteable
2828
Chromium
29+
Pulumi
30+
Tekton

.github/workflows/lre.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ jobs:
6767
6868
- name: Start Kubernetes cluster (Infra)
6969
run: >
70-
nix develop --impure --command
71-
bash -c "./deployment-examples/kubernetes/00_infra.sh"
70+
nix run .#native up
7271
7372
- name: Start Kubernetes cluster (Operations)
7473
run: >

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ result
1414
.bazelrc.user
1515
MODULE.bazel.lock
1616
trivy-results.sarif
17+
Pulumi.dev.yaml

.golangci.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
linters:
3+
enable-all: true
4+
disable:
5+
# Deprecated.
6+
- nosnakecase
7+
- interfacer
8+
- exhaustivestruct
9+
- ifshort
10+
- deadcode
11+
- varcheck
12+
- golint
13+
- maligned
14+
- scopelint
15+
- structcheck
16+
17+
# Allow all packages for now.
18+
- depguard
19+
20+
# TODO(aaronmondal): Fix these at some point.
21+
- exhaustruct

Pulumi.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: nativelink
3+
org: TraceMachina
4+
runtime: go
5+
description: The development cluster for NativeLink.
6+
organization:
7+
pulumi:tags:
8+
company: "Trace Machina, Inc."
9+
backend:
10+
# Only intended to run locally.
11+
url: file://~

deployment-examples/chromium/00_infra.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

deployment-examples/chromium/01_operations.sh

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,29 @@ set -xeuo pipefail
77

88
SRC_ROOT=$(git rev-parse --show-toplevel)
99

10-
kubectl apply -f ${SRC_ROOT}/deployment-examples/chromium/gateway.yaml
10+
EVENTLISTENER=$(kubectl get gtw eventlistener -o=jsonpath='{.status.addresses[0].value}')
1111

1212
# The image for the scheduler and CAS.
13-
nix run .#image.copyTo \
14-
docker://localhost:5001/nativelink:local \
15-
-- \
16-
--dest-tls-verify=false
13+
curl -v \
14+
-H 'content-Type: application/json' \
15+
-d '{
16+
"flakeOutput": "./src_root#image",
17+
"imageTagOverride": "local"
18+
}' \
19+
http://${EVENTLISTENER}:8080
1720

18-
# Wrap it with nativelink to turn it into a worker.
19-
nix run .#nativelink-worker-siso-chromium.copyTo \
20-
docker://localhost:5001/nativelink-worker-siso-chromium:local \
21-
-- \
22-
--dest-tls-verify=false
21+
# Wrap it nativelink to turn it into a worker.
22+
curl -v \
23+
-H 'content-Type: application/json' \
24+
-d '{
25+
"flakeOutput": "./src_root#nativelink-worker-siso-chromium",
26+
"imageTagOverride": "local"
27+
}' \
28+
http://${EVENTLISTENER}:8080
29+
30+
# Wait for the pipelines to finish.
31+
kubectl wait \
32+
--for=condition=Succeeded \
33+
--timeout=30m \
34+
pipelinerun \
35+
-l tekton.dev/pipeline=rebuild-nativelink

deployment-examples/chromium/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,25 @@ In this example we're using `kind` to set up the cluster `cilium` to provide a
1919
First set up a local development cluster:
2020

2121
```bash
22-
./00_infra.sh
22+
native up
2323
```
2424

25+
> [!TIP]
26+
> The `native up` command uses Pulumi under the hood. You can view and delete
27+
> the stack with `pulumi stack` and `pulumi destroy`.
28+
2529
Next start a few standard deployments. This part also builds the remote
2630
execution containers and makes them available to the cluster:
2731

2832
```bash
2933
./01_operations.sh
3034
```
3135

36+
> [!TIP]
37+
> The operations invoke cluster-internal Tekton Pipelines to build and push the
38+
> `nativelink` and worker images. You can view the state of the pipelines with
39+
> `tkn pr ls` and `tkn pr logs`/`tkn pr logs --follow`.
40+
3241
Finally, deploy NativeLink:
3342

3443
```bash

deployment-examples/kubernetes/00_infra.sh

Lines changed: 0 additions & 131 deletions
This file was deleted.

deployment-examples/kubernetes/01_operations.sh

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,35 @@ set -xeuo pipefail
77

88
SRC_ROOT=$(git rev-parse --show-toplevel)
99

10-
kubectl apply -f ${SRC_ROOT}/deployment-examples/kubernetes/gateway.yaml
11-
12-
# The image for the scheduler and CAS.
13-
nix run .#image.copyTo \
14-
docker://localhost:5001/nativelink:local \
15-
-- \
16-
--dest-tls-verify=false
17-
18-
# The worker image for C++ actions.
19-
nix run .#nativelink-worker-lre-cc.copyTo \
20-
docker://localhost:5001/nativelink-worker-lre-cc:local \
21-
-- \
22-
--dest-tls-verify=false
23-
24-
# The worker image for Java actions.
25-
nix run .#nativelink-worker-lre-java.copyTo \
26-
docker://localhost:5001/nativelink-worker-lre-java:local \
27-
-- \
28-
--dest-tls-verify=false
10+
EVENTLISTENER=$(kubectl get gtw eventlistener -o=jsonpath='{.status.addresses[0].value}')
11+
12+
curl -v \
13+
-H 'content-Type: application/json' \
14+
-d '{
15+
"flakeOutput": "./src_root#image",
16+
"imageTagOverride": "local"
17+
}' \
18+
http://${EVENTLISTENER}:8080
19+
20+
curl -v \
21+
-H 'content-Type: application/json' \
22+
-d '{
23+
"flakeOutput": "./src_root#nativelink-worker-lre-cc",
24+
"imageTagOverride": "local"
25+
}' \
26+
http://${EVENTLISTENER}:8080
27+
28+
curl -v \
29+
-H 'content-Type: application/json' \
30+
-d '{
31+
"flakeOutput": "./src_root#nativelink-worker-lre-java",
32+
"imageTagOverride": "local"
33+
}' \
34+
http://${EVENTLISTENER}:8080
35+
36+
# Wait for the pipelines to finish.
37+
kubectl wait \
38+
--for=condition=Succeeded \
39+
--timeout=30m \
40+
pipelinerun \
41+
-l tekton.dev/pipeline=rebuild-nativelink

deployment-examples/kubernetes/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,25 @@ In this example we're using `kind` to set up the cluster `cilium` to provide a
99
First set up a local development cluster:
1010

1111
```bash
12-
./00_infra.sh
12+
native up
1313
```
1414

15+
> [!TIP]
16+
> The `native up` command uses Pulumi under the hood. You can view and delete
17+
> the stack with `pulumi stack` and `pulumi destroy`.
18+
1519
Next start a few standard deployments. This part also builds the remote
1620
execution containers and makes them available to the cluster:
1721

1822
```bash
1923
./01_operations.sh
2024
```
2125

26+
> [!TIP]
27+
> The operations invoke cluster-internal Tekton Pipelines to build and push the
28+
> `nativelink` and worker images. You can view the state of the pipelines with
29+
> `tkn pr ls` and `tkn pr logs`/`tkn pr logs --follow`.
30+
2231
Finally, deploy NativeLink:
2332

2433
```bash

deployment-examples/kubernetes/gateway.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)