Kubernetes operator that keeps a Git repository and an application's files in sync through a shared PVC. Declare and Treebind pulls, commits and pushes.
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:
| 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 |
bidirectional commits and pushes the application's edits. pull is a read-only mirror of the repository..env and private keys, and it leaves out of its commits a file that holds what looks like a new token or private key (secret scan). It refuses storage that cannot hold a checkout, such as an object store mounted as a file system (storage that is refused).commit.maxPerHour (60 by default) stops an application and a repository that answer each other from committing for ever (echo loops).repository.path syncs one directory of a monorepo, and paths.include / paths.exclude take .gitignore patterns.kubectl get treebind shows Ready, Synced and Conflict. Changes of Synced, Conflict, FilesLeftOut, GitHostReachable and VolumeReady are also events and Prometheus metrics, with alert expressions in the docs.restricted Pod 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: followLocal
Write 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:
agent image: the base image has a newer Git or ssh
https://github.com/mohanedmoh/treebind/issues/352
Labels: area/packaging, needs-triage
Review the API before beta, and decide what the breaking release changes
https://github.com/mohanedmoh/treebind/issues/305
Labels: area/operator, kind/decision, phase/2
docs(rbac): say that creating a Treebind grants use of the namespace's deploy keys
https://github.com/mohanedmoh/treebind/issues/300
Labels: area/security, area/docs, kind/feature, needs-triage
bug: commit is accepted on a Treebind that only pulls
https://github.com/mohanedmoh/treebind/issues/299
Labels: area/operator, kind/bug, priority/low, needs-triage
bug: the API accepts repository URLs that can never work
https://github.com/mohanedmoh/treebind/issues/298
Labels: area/operator, kind/bug, priority/low, needs-triage
feat(chart): add Treebinds to the built-in edit and view roles
https://github.com/mohanedmoh/treebind/issues/297
Labels: area/security, area/packaging, kind/feature, needs-triage
docs: migration from the alpha API group
https://github.com/mohanedmoh/treebind/issues/295
Labels: area/docs, kind/feature, blocked
Treebind keeps a Git repository and an application's files in sync through a
shared volume. Code, docs, tests, storage reports and bug reports all help. You
do not need to know Kubernetes internals to start: the issues labelled
good first issue are written so that you can finish them from the issue text
alone.
By taking part you agree to the Code of Conduct.
good first issue for a first change, or
help wanted for larger ones.api/), adds a dependency, or will be more than about 200
lines.<type>/<issue>-<short-description>, for example
fix/42-lock-heartbeat-race.make lint test, and make generate manifests if you touched api/.git commit -s.main. Put
Fixes #<issue> in the description.We use Conventional Commits. The pull
request title is what becomes the commit on main, because pull requests are
squash-merged, so it must follow the format too. CI checks it.
type(scope): short summary in the imperative
feat, fix, docs, test, refactor, perf, build, ci,
chore.operator, agent, api, git, volume,
lock, chart, adapters, ci, docs.! after the scope and add a BREAKING CHANGE:
line in the body that says what to do instead.Every commit needs a Signed-off-by: Your Name <you@example.com> line, which
git commit -s adds. It certifies the
Developer Certificate of Origin: that you
wrote the change or have the right to submit it under the project's licence. A
bot checks it, and the pull request cannot merge without it. To add it
afterwards, run git rebase --signoff upstream/main and force-push your branch.
make generate manifests leaves no diff.breaking-change label and a line for the
release notes.gofmt and goimports. golangci-lint settings are in .golangci.yml and
CI enforces them.%w and add context at each layer. Do not panic in reconcile
or agent loops.internal/agent/git. No other package calls the git binary.| Kind | Where | Use it for |
|---|---|---|
| Unit | Next to the code | Logic with no cluster |
| envtest | internal/controller | Reconciler behaviour against a real API server |
| End-to-end | test/e2e | The whole sync loop on kind |
| Failure injection | test/e2e | Crashes, conflicts, a lost lock, a full disk |
| Storage conformance | test/conformance | A storage class against the sync guarantees (the suite). Reports are welcome: run it on your own cluster and open a conformance report issue. |
The Treebind API is the project's contract with its users.
docs/adr/.v1alpha1 a breaking change is allowed but needs the
breaking-change label and a release note. From phase 2 on, changes within a
released version must stay backward compatible.Do not open a public issue for a vulnerability. Use the private report form under the Security tab, as described in SECURITY.md. Expect an acknowledgement within three working days.
Treebind is Apache-2.0 and written from scratch.