| 1 | # Distributed Build with Consistent Hashing |
| 2 | |
| 3 | Demo for efficiently using BuildKit daemon-local cache with multi-node cluster |
| 4 | |
| 5 | ## Deploy |
| 6 | |
| 7 | ```console |
| 8 | $ kubectl apply -f ../statefulset.rootless.yaml |
| 9 | $ kubectl scale --replicas=10 statefulset/buildkitd |
| 10 | ``` |
| 11 | |
| 12 | ## Consistent hashing |
| 13 | |
| 14 | Define the key string for consistent hashing. |
| 15 | |
| 16 | For example, the key can be defined as `<REPO NAME>:<CONTEXT PATH>`, e.g. |
| 17 | `github.com/example/project:some/directory`. |
| 18 | |
| 19 | |
| 20 | Then determine the pod that corresponds to the key: |
| 21 | ```console |
| 22 | $ go build -o consistenthash . |
| 23 | $ pod=$(./show-running-pods.sh | consistenthash $key) |
| 24 | ``` |
| 25 | |
| 26 | You can connect to the pod using `export BUILDKIT_HOST=kube-pod://$pod`. |