Etcd is an open-source, distributed key-value database. In key-value databases, each record contains a key which is the unique identifier. A value is associated with the key. Etcd is a major component of many projects such as Kubernetes, Rook, CoreDNS, etc. Kubernetes uses etcd as a data store to maintain information about the state of the cluster. It stores the metadata ("data about data") in a fault-tolerant setup, using multiple servers. So even if one server fails, etcd should still work, if the other servers are still available.
etcdctl put key1 value1
etcdctl lease grant 10
Leases are used to specify TTL (Time-to-live) for temporary keys. Once a lease is created, keys can be associated with this lease. We'll see how in the next example.
Note: This command will return an id. And this id should be used when you want to associate a key with this specific lease.
etcdctl put key2 value23 --lease=<lease_id>
etcdctl get key1
Note: This command will also print the key associated with the value.
etcdctl get key1 --print-value-only
etcdctl get key1 key5
Note: It will fetch a list of available keys from key1 to key5
etcdctl get --prefix=key
etcdctl del key1
KodeKloud provides a small etcd cluster so you can quickly and easily get hands-on experience. This playground comes up with a 3-node etcd cluster. You can access all three nodes using the same terminal. No need to install anything or go through a complex setup process. If you're unfamiliar with etcd, you can use the quick start guide link provided in the playground.