GithubHelp home page GithubHelp logo

simple-keystore's Introduction

Simple Keystore API

Exposes following APIs:

  1. getall
  2. set
  3. get/<key>
  4. search?prefix=<pattern> and search?suffix=<pattern>
  5. del/<key>

Examples:

  1. get all
→ curl -s --location --request GET 'http://simple-keystore.info/getall'|jq 
    {
    "abc-2": "abc-2",
    "key1": "value1",
    "key2": "value2",
    "key3": "value3",
    "xyz-1": "xyz-1",
    "xyz-2": "xyz-2"
    } 
  1. get/<key>
→ curl -s --location --request GET 'http://simple-keystore.info/get/abc-1'|jq
"abc-1"
  1. set key (sample payload)
→ curl -s --location --request POST 'http://simple-keystore.info/set' \
--header 'Content-Type: application/json' \
--data-raw '{
    "xyz-3": "xyz-3"
}' |jq
{
  "abc-1": "abc-1",
  "abc-2": "abc-2",
  "key1": "value1",
  "key2": "value2",
  "key3": "value3",
  "xyz-1": "xyz-1",
  "xyz-2": "xyz-2",
  "xyz-3": "xyz-3"
}
  1. search prefix
→ curl -s --location --request GET 'http://simple-keystore.info/search?prefix=abc'|jq
[
  "abc-1",
  "abc-2"
]
  1. search suffix
→ curl -s --location --request GET 'http://simple-keystore.info/search?suffix=-1'|jq
[
  "abc-1",
  "xyz-1"
]

Includes a Dockerfile and k8s yaml plus steps to deploy the same in a local minikube kubernetes setup

  1. clone this repository into your local
  2. enable the ingress addon for minikue(it will deoloy the nginx-ingress controller)
minikube addons enable ingress

minikube ip will act as the entry point for external traffic here(in case of cloud we will deploy a loadbalancer) 3. create the keystore deployment

kubectl create -f k8s/deployment.yaml
  1. expose the service
kubectl expose deployment keystore  --port=5000
  1. create the ingress rule
kubectl create -f k8s/ingress.yaml
  1. check if the keystore app pods are running
→ kubectl get pods
NAME                        READY   STATUS    RESTARTS   AGE
keystore-56ccbb9fb6-7f2gq   1/1     Running   0          32m
keystore-56ccbb9fb6-h7n4b   1/1     Running   0          32m
keystore-56ccbb9fb6-q29lw   1/1     Running   0          32m
  1. create a local dns entry in the hosts file for the minikube ip.
echo "$(minikube ip) simple-keystore.info" | sudo tee -a /etc/hosts

Test Coverage:

Validates 200 status code and respose body get/set/search api calls

root@keystore-7cc6c9659b-qd249:/app# python3 test_app.py
.['value1', 'value2', 'value3']
..
----------------------------------------------------------------------
Ran 3 tests in 0.010s

OK

simple-keystore's People

Contributors

vivekanandham avatar vivekdevops avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.