https://github.com/ahmetb/etcdedit
Directly edit Kubernetes resources stored in etcd
https://github.com/ahmetb/etcdedit
etcd etcd-client etcd-manage etcdv3
Last synced: 3 months ago
JSON representation
Directly edit Kubernetes resources stored in etcd
- Host: GitHub
- URL: https://github.com/ahmetb/etcdedit
- Owner: ahmetb
- License: apache-2.0
- Created: 2026-03-01T00:47:24.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-03-01T07:03:21.000Z (3 months ago)
- Last Synced: 2026-03-05T15:16:43.166Z (3 months ago)
- Topics: etcd, etcd-client, etcd-manage, etcdv3
- Language: Go
- Homepage:
- Size: 60.5 KB
- Stars: 11
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# etcdedit
Directly edit Kubernetes resources stored in etcd, bypassing the API server.
> [!WARNING]
> This is a brain surgery tool, use with caution.
This tool directly deals with Kubernetes proto binary encoding (and JSON
encoding for CRDs) so it may cause loss of certain fields depending on which
kubernetes server version you're using.
## Why?
Sometimes you need to directly access the data stored in etcd:
- Recover from a broken cluster state, or restore admin access to the cluster
- Inspect or modify resources when the API server is unavailable
- Load the cluster with objects as fast as possible for stress testing
## Installation
```bash
brew tap ahmetb/etcdedit https://github.com/ahmetb/etcdedit
brew install etcdedit
```
```bash
go install github.com/ahmetb/etcdedit@latest
```
## Usage
Set credentials in the env (or --flags) the same way you would for `etcdctl`:
```bash
export ETCDCTL_ENDPOINTS=https://127.0.0.1:2379
export ETCDCTL_CACERT=/etc/kubernetes/pki/etcd/ca.crt
export ETCDCTL_CERT=/etc/kubernetes/pki/etcd/server.crt
export ETCDCTL_KEY=/etc/kubernetes/pki/etcd/server.key
```
- **Get a key**: retrieve a resource from etcd
```bash
etcdedit get /registry/pods/default/nginx
```
- **Edit a resource **: launches $EDITOR (default: vim) to modify a resource
in place. Before applying the change the original etcd value is saved to a
temp file.
```bash
etcdedit edit /registry/pods/default/nginx
```
- **Apply**: replace the etcd key with a given YAML manifest
```bash
etcdedit apply -f manifest.yaml /registry/pods/default/my-pod
```
## etcd Kubernetes Key Paths
You should always run `etcdctl get --keys-only --prefix ` to figure
out which key you should be replacing (**do not guess**).
Most of the key format looks like this:
```text
/registry/// # namespaced
/registry// # cluster-scoped
/registry//// # CRD
```
but nothing is guaranteed since this is an implementation detail of the
API server.
## Examples
- Create a ConfigMap (name/namespace derived from key path):
```bash
etcdedit apply -f - /registry/configmaps/default/my-config <