Skip to content

A Key-Value storage server using FastAPI on Kubernetes cluster

License

Notifications You must be signed in to change notification settings

jalayrupera/KVstore

Repository files navigation

KVstore

A key-value storage server built with FastAPI, etcd, and Kubernetes.

Author

Tech Stack

  • Python
  • FastAPI
  • Docker version v20.10.23
  • minikube v1.30.1

Installation

Create .env file outside app folder. The env should contain field ETCD_HOST, ETCD_PORT.
Screenshot of env file   picture alt

  • Local Installation

    1. In one terminal run command
      etcd
    1. In another terminal run following commands and set ETCD_HOST=localhost, ETCD_PORT=2379 in .env file
      source venv.sh
      deactivate
      source venv/bin/activate
      export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
      uvicorn app.main:app --reload --reload-dir app --port 8000

     

  • Installation with Docker Compose

    1. In order to run the app on docker container configure the .env file with below host and port values
      ETCD_HOST=etcd
      ETCD_PORT=2379
    1. Run the below command to create app and etcd containers
      docker-compose up
    1. Visit the localhost:8000/docs to access the API.  
  • Kubernetes Deployments, services and Installation

    1. Run below command to start minikube, minikube dashboard and metrics-server
      minikube start
      minikube addons enable metrics-server
      minikube dashboard
    1. Run the below command to generate secrets for fastapi application pods. The ETCD_HOST and ETCD_PORT values should not be changed. It should same as below command.
      kubectl create secret generic etcd-secret --from-literal=ETCD_HOST=etcd --from-literal=ETCD_PORT=2379 --dry-run -o yaml > secrets.yaml
    1. Run the below commands to create deployment, service, HorizontalPodAutoScaler and volumes.
      kubectl apply -f=master-backend.yaml -f=master-etcd.yaml
      kubectl apply -f=secrets.yaml
    1. Expose the service on local machine
      minikube service backend

About

A Key-Value storage server using FastAPI on Kubernetes cluster

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published