Skip to content

Kubernetes example

In this example you’ll deploy NativeLink to a local Kubernetes cluster using Helm and run Bazel builds against it.

Requirements

Pull the Helm chart from the NativeLink OCI registry and install it:

Terminal window
helm install nativelink \
oci://public.ecr.aws/b1l4l6w7/tracemachina/nativelink \
--version 1.0.0-rc1 \
-n nativelink \
--create-namespace

Wait for the pods to become ready:

Terminal window
kubectl get pods -n nativelink -w

You should see pods for the CAS, scheduler, and worker components:

NAME READY STATUS RESTARTS AGE
nativelink-cas-... 1/1 Running 0 60s
nativelink-scheduler-... 1/1 Running 0 60s
nativelink-worker-... 1/1 Running 0 60s

View logs for individual components:

Terminal window
# CAS (Content Addressable Storage) logs
kubectl logs deploy/nativelink-cas -n nativelink
# Scheduler logs
kubectl logs deploy/nativelink-scheduler -n nativelink
# Worker logs
kubectl logs deploy/nativelink-worker -n nativelink

Port-forward the NativeLink services to your local machine:

Terminal window
# In a separate terminal — keep this running
kubectl port-forward svc/nativelink-cas 50051:50051 -n nativelink &
kubectl port-forward svc/nativelink-scheduler 50052:50052 -n nativelink &

Now run a Bazel build against the cluster:

Terminal window
bazel build \
--remote_cache=grpc://localhost:50051 \
--remote_executor=grpc://localhost:50052 \
//...

The key output to look for:

INFO: 11 processes: 9 internal, 2 remote.

This tells you the build ran against the cluster. Clean the local cache and rebuild to verify caching works:

Terminal window
bazel clean && bazel build \
--remote_cache=grpc://localhost:50051 \
--remote_executor=grpc://localhost:50052 \
//...

You should now see cache hits:

INFO: 11 processes: 2 remote cache hit, 9 internal.

To customize the Helm chart values, first extract the default values:

Terminal window
helm show values \
oci://public.ecr.aws/b1l4l6w7/tracemachina/nativelink \
--version 1.0.0-rc1 > nativelink-values.yaml

Edit nativelink-values.yaml to your needs, then upgrade the release:

Terminal window
helm upgrade nativelink \
oci://public.ecr.aws/b1l4l6w7/tracemachina/nativelink \
--version 1.0.0-rc1 \
-n nativelink \
-f nativelink-values.yaml

See the Helm chart documentation for details on configuring cloud object stores (S3, GCS, Azure Blob), Redis, ingress, metrics, and more.

When you’re done testing, remove the NativeLink deployment:

Terminal window
helm uninstall nativelink -n nativelink
kubectl delete namespace nativelink