Skip to content

Sohoxic/EtcdKVStore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 

Repository files navigation

High Level Design Diagram

Demo

Components of the distributed k-v store Demo

Week1: Setting Up and Understanding etcd

Todo

  • etcd Installation
  • Single-Node Cluster Setup Guide
  • Write functions to List all keys using etcd client library.
  • Get the value for a specific key provided by the user.
  • Put a key-value pair into etcd, allowing users to specify both key and value.

This guide provides a comprehensive overview of installing etcd, configuring your system to run it, and setting up a single-node etcd cluster on a Linux system.

Downloading etcd

To download a specific version of etcd from the official GitHub repository:

  1. Identify the version you want to download from etcd releases.
  2. Use the following commands to download and extract etcd to a temporary location:
ETCD_VER=<version> # Example: v3.4.31
DOWNLOAD_URL=https://github.com/etcd-io/etcd/releases/download
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/etcd-download-test --strip-components=1

This is how it should appear by the end of installation:

Demo

Making etcd Accessible System-wide

After downloading and extracting etcd, you may encounter a message indicating etcd command is not found. This is because the binary is not in your system's PATH. To resolve this:

Moving etcd Binaries

  1. Move etcd and etcdctl to a more permanent location, /usr/local/bin:
sudo mv /tmp/etcd-download-test/etcd /usr/local/bin/
sudo mv /tmp/etcd-download-test/etcdctl /usr/local/bin/

Updating the PATH Variable

For bash users, add /usr/local/bin to your PATH by editing ~/.bashrc:

echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

For zsh users, modify ~/.zshrc instead:

echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Setting Up a Single-Node Cluster

Follow the steps outlined in the etcd documentation for setting up a single-node cluster:

  1. Start the etcd server:
etcd
  1. Interact with etcd using etcdctl:
etcdctl put mykey myvalue
etcdctl get mykey

Getting and Setting K-V pair in local system:

Demo

For detailed instructions, refer to the etcd Quickstart Guide.

Running the script.py

To run the script.py file and interact with the etcd cluster, perform the following steps:

  • Ensure the etcd service is running.
  • Install the etcd3 Python package if not already installed:
  pip install etcd3

If you encounter errors related to the protobuf library, downgrade the protobuf package to version 3.20.x or lower:

pip install protobuf==3.20.0

or you can set the protocol buffers env. variable:

set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
  • Run script.py
python script.py

Output:

Demo

Week2: Adding Features and Error Handling

Todo

  • Write function to delete keys.
  • Write function to implement range scan.
  • Error handling for the functions
  • Design a CLI.

Run script.py

python script.py

CLI:

Demo

Week3: Testing

Todo

  • Write unit tests for program's functionalities
  • Multi-Node cluster set up

Run script.py

python script.py

Running Unit Tests

Demo

Multi Node Cluster Setup Running.

Demo

Multi Node Cluster Before Deleting Leader.

Demo

Multi Node Cluster After Deleting Leader.

Demo

Note

  • This guide focuses on development and testing environments. For production setups, consult the official etcd documentation for security, clustering, and configuration best practices.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages