Database

Etcd Playground

etcd is a distributed key-value store used for configuration management, service discovery, and coordination in distributed systems..

Get access to the Etcd playground with one click

Welcome to the etcd Playground!

etcd — the distributed key-value store that powers Kubernetes cluster state. Fast, consistent, and fault-tolerant via the Raft consensus algorithm.

What’s Pre-installed

  • etcd server (Bitnami, starts automatically)
  • etcdctl — the CLI for interacting with etcd
  • Endpoint: http://localhost:2379
  • Root password: codeground

Quick Start

export ETCDCTL_API=3
export ETCDCTL_ENDPOINTS=http://localhost:2379

etcdctl put greeting "hello etcd"
etcdctl get greeting

Common Workflows

# Key-value operations
etcdctl put /config/db/host localhost
etcdctl put /config/db/port 5432
etcdctl get /config/ --prefix
etcdctl del /config/db/host

# Watch for changes (open another terminal)
etcdctl watch /config/ --prefix

# Lease (TTL-based expiry)
etcdctl lease grant 30
etcdctl put --lease=<id> /tmp/session "active"
etcdctl lease timetolive <id>

Advanced Tips

# Transactions (compare-and-swap)
etcdctl txn <<EOF
cmp("lock") = ""
put("lock", "owner-1")
EOF

# Compact revision history
etcdctl compact $(etcdctl endpoint status --write-out=fields | grep Revision | awk '{print $NF}')

# Backup and restore
etcdctl snapshot save /tmp/etcd.snapshot
etcdctl snapshot status /tmp/etcd.snapshot

Session Notes

  • Session lasts 1 hour.
  • etcd starts in background. Set ETCDCTL_API=3 before using etcdctl.