https://github.com/polyrabbit/etcdfs
:file_folder: Mount etcd into a local directory
https://github.com/polyrabbit/etcdfs
etcd etcd-client filesystem fuse
Last synced: 11 months ago
JSON representation
:file_folder: Mount etcd into a local directory
- Host: GitHub
- URL: https://github.com/polyrabbit/etcdfs
- Owner: polyrabbit
- License: mit
- Created: 2020-07-30T15:53:18.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-25T06:24:09.000Z (over 3 years ago)
- Last Synced: 2025-04-06T14:36:17.845Z (about 1 year ago)
- Topics: etcd, etcd-client, filesystem, fuse
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 82
- Watchers: 5
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# etcdfs - A FUSE filesystem backed by etcd
[](https://github.com/polyrabbit/etcdfs/actions)
[](https://opensource.org/licenses/MIT)
[](https://github.com/polyrabbit/my-token/pulls)
[](https://goreportcard.com/report/github.com/polyrabbit/etcdfs)
[中文简介](https://blog.betacat.io/post/2020/08/how-to-mount-etcd-as-a-filesystem/)
Tired of typing `etcdctl`? why not mount it to local filesystem and open in your favorite editors?
## Example
Wondering how Kubernetes organizes data in etcd? After mounting it locally, we can use [VS Code](https://code.visualstudio.com/) to get the whole picture:

_Hint: steps to mount Kubernetes etcd locally:_
```bash
$ # scp etcd certificates to a local directory (keep them carefully)
$ scp -r :/etc/kubernetes/pki/etcd .
$ # mount to a local directory
$ etcdfs --endpoints=:2379 --cacert etcd/ca.crt --key etcd/server.key --cert etcd/server.crt mnt
$ # open it in VS code
$ code mnt
```
## Installation
#### Homebrew
```bash
# WIP
```
#### `curl | bash` style downloads to `/usr/local/bin`
```bash
$ curl -sfL https://raw.githubusercontent.com/polyrabbit/etcdfs/master/.godownloader.sh | bash -s -- -d -b /usr/local/bin
```
#### Using [Go](https://golang.org/)
```bash
$ go get -u github.com/polyrabbit/etcdfs
```
## Usage
```bash
$ etcdfs
Mount etcd to local file system - find help/update from https://github.com/polyrabbit/etcdfs
Usage:
etcdfs [mount-point] [flags]
Flags:
--endpoints strings etcd endpoints (default [127.0.0.1:2379])
--dial-timeout duration dial timeout for client connections (default 2s)
--read-timeout duration timeout for reading and writing to etcd (default 3s)
-v, --verbose verbose output
--enable-pprof enable runtime profiling data via HTTP server. Address is at "http://localhost:9327/debug/pprof"
--cert string identify secure client using this TLS certificate file
--key string identify secure client using this TLS key file
--cacert string verify certificates of TLS-enabled secure servers using this CA bundle
--mount-options strings options are passed as -o string to fusermount (default [nonempty])
-h, --help help for etcdfs
```
_Notice: `etcdfs` has a very similar CLI syntax to `etcdctl`._
## Limitations
* Etcdfs depends on the [FUSE](https://en.wikipedia.org/wiki/Filesystem_in_Userspace) kernel module which only supports Linux and macOS(?). It needs to be installed first:
* Linux: `yum/apt-get install -y fuse`
* macOS: install [OSXFUSE](https://osxfuse.github.io/)
* Keys in etcd should have a hierarchical structure to fit the filesystem tree model. And currently the only supported hierarchy separator is `/` (the same as *nix), more will be supported in the future.
* Currently only etcd v3 is supported.
## Supported Operations
Most commonly used POSIX operations are supported:
* Readdir
* Lookup
* Getattr
* Open
* Read
* Write
* Create
* Flush
* Fsync
* Unlink
* Setattr
## TODO
- [x] ~~When building a directory, all keys belonging to that directory can be skipped~~
- [ ] Support hierarchy separators other than `/` in etcd
- [ ] Watch for file/directory changes
## Credits
* Inspired by [rssfs](https://github.com/dertuxmalwieder/rssfs)
* Based on [go-fuse](https://github.com/hanwen/go-fuse) binding
## License
The MIT License (MIT) - see [LICENSE.md](https://github.com/polyrabbit/etcdfs/blob/master/LICENSE) for more details