Keep a Git repository and a Kubernetes volume in sync, in both directions.
Declare a Treebind. It pulls changes from Git, commits what your application writes, and pushes it back.
Quickstart · Examples · Documentation · Discussions
⭐ If Treebind is useful to you, star it on GitHub. It helps other people find it.
Many applications keep their state as plain files: dashboards, workflow definitions, site content, settings. People edit them in the application's own UI, so the edits have no history, no review and no rollback. GitOps tools deploy your manifests, but they do not follow the files an application writes while it runs.
Treebind puts such a directory under Git, in both directions:
- A user saves a dashboard in the application, and Treebind commits and pushes it.
- Someone merges a change in Git, and Treebind writes it into the application's directory.
| When... | Treebind... |
|---|---|
| the application writes a file | waits until the file has been quiet for settleTime (5s by default), commits it as one author, and pushes it as a fast-forward |
| someone pushes to the branch | pulls at every interval (30s by default) and writes the change into the directory, never over an edit that is not committed yet |
| both sides changed the same file | applies your conflictPolicy: followRemote (Git wins, your commits are kept in a ref) or followLocal (the application wins, in a merge commit that keeps Git's version in the history) |
| it cannot decide safely | stops, says why in kubectl describe (Synced, Conflict), and waits for you |
- Two-way, or pull-only.
bidirectionalcommits and pushes the application's edits.pullis a read-only mirror of the repository. - Safe by default. It never force-pushes and never writes over an uncommitted local edit. It refuses an update that would remove more than 100 files at once (deletion guard), and it never commits files named like secrets, such as
.envand private keys. - Breaks echo loops.
commit.maxPerHour(60 by default) stops an application and a repository that answer each other from committing for ever (echo loops). - Syncs exactly what you mean.
repository.pathsyncs one directory of a monorepo, andpaths.include/paths.excludetake.gitignorepatterns. - Observable.
kubectl get treebindshowsReady,SyncedandConflict. Each change ofSyncedandConflictis also an event and a Prometheus metric, with alert expressions in the docs. - Locked down. Two operator replicas with leader election. Pods run under the
restrictedPod Security level. The operator never reads a Secret and can be limited to the namespaces you name (RBAC). The chart and images are signed, with SBOMs, for amd64 and arm64.
A Treebind is one small manifest:
apiVersion: treebind.example.org/v1alpha1
kind: Treebind
metadata: {name: dashboards, namespace: monitoring}
spec:
repository:
url: ssh://git@github.com/acme/dashboards.git # change: the ssh address of your repository
branch: main # change: the branch to follow
auth:
sshKeySecretRef: {name: deploy-key, key: id_ed25519} # change: your Secret with the deploy key
knownHostsConfigMapRef: {name: git-known-hosts, key: known_hosts} # change: your ConfigMap with the host's keys
target:
claimName: app-data # change: an existing PersistentVolumeClaim
subPath: dashboards # change: the directory of the claim that is synced
sync:
direction: bidirectional
conflictPolicy: followLocalWrite a file the way your application would:
kubectl -n demo exec app -- sh -c 'echo "Written by the application" > /data/from-the-app.txt'A few seconds later it is a commit on the branch. This is the log on the quickstart's Git server:
d3de362 treebind-bot: treebind: sync 1 file(s)
a8b732d Developer: First commit
Push a commit from Git, and the file appears in the application's directory within the interval. The quickstart runs the whole loop on a local kind cluster, with a Git server inside the cluster, in about ten minutes. CI runs every command on that page on a kind cluster.
You need Kubernetes 1.35 or later, Helm, an existing PVC, and a Git repository that you can give an ssh deploy key.
helm install treebind oci://ghcr.io/mohanedmoh/charts/treebind --version 0.0.1-alpha.5 \
--namespace treebind-system --create-namespace --waitEach release also publishes an install.yaml for kubectl apply, and signs the chart and both images (how to verify a release). The chart README lists what it installs and its values.
Each example is a complete, tested walk-through that starts where the quickstart ends.
| Use case | What it shows |
|---|---|
| Dashboards edited in the application | Both directions, the author and message of the commits, and a dashboard changed in the application and in Git at the same time |
| A static site that Git deploys and nginx serves | direction: pull, a read-only mount, and a push that is live within the interval |
| One directory of a monorepo | repository.path, commits that change only that directory, and paths.exclude |
Treebind is alpha, and its releases are pre-releases. Do not use it with data you cannot lose. Read this before you use it with anything that matters.
- The API will change. The group
treebind.example.orgis a placeholder (#15), and when it changes you will create every Treebind again. - Tested on kind. The tests run on kind clusters of one node with
local-pathstorage.v0.0.1-alpha.5was also tried by hand on a cluster of two nodes, with local and NFS volumes. No storage class is listed as supported yet (storage support). - Placement next to the application is opt-in. With a
ReadWriteOnceclaim on several nodes, setspec.placement.appSelector(newer than 0.0.1-alpha.5), or the scheduler can put the two on different nodes. When the application moves to another node, the operator replaces the sync pod beside it, after 30 seconds and at most once in 2 minutes (when the application moves); a Deployment needsstrategy: type: Recreateto move such a claim at all. - The only credential is an ssh key (tokens for https: #58). The agent polls, and webhooks are planned (#61).
- Some fields are accepted and ignored.
spec.placement.mode: sidecar,spec.agent.fsGroupandspec.agent.resources.claimsare not built yet, and the conditionSpecSupportedsays so.
| Topic | Page |
|---|---|
| Get started | Quickstart · Credentials · Examples |
| How the sync behaves | Pulling · Local changes and commits · Conflicts · Deletion guard · Echo loops |
| When something is wrong | Recovering from a conflict or a rejected push · Reading the agent's status |
| Running it | Operator replicas · RBAC · Pod Security and file ownership · Metrics and events · Deleting a Treebind |
| Design decisions | Architecture decision records |
Contributions are welcome, and you do not need to know Kubernetes internals to start. Issues labelled good first issue are self-contained, with named files and an acceptance test. A maintainer gives a first response within three working days.
- Start with CONTRIBUTING.md. Commits are signed off (
git commit -s), and docs/development.md gets you a working setup. - Ask questions and share ideas in Discussions.
- Storage reports wanted. Tried Treebind on your storage class? The storage support matrix fills in from what people report.
- Decisions are made as described in GOVERNANCE.md. Report security problems privately, as SECURITY.md describes.