All Projects → hjacobs → connexion-example-redis-kubernetes

hjacobs / connexion-example-redis-kubernetes

Licence: GPL-3.0 license
Connexion Example REST Service with Redis Store

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to connexion-example-redis-kubernetes

Swagger Core
Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
Stars: ✭ 6,898 (+28641.67%)
Mutual labels:  openapi, swagger-api
Swagger Ui
Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
Stars: ✭ 21,279 (+88562.5%)
Mutual labels:  openapi, swagger-api
abap-openapi-client
ABAP OpenAPI Client and Server generator in ABAP
Stars: ✭ 44 (+83.33%)
Mutual labels:  openapi
flask-couch-microservice
Star the repo if its useful, looking for contributors
Stars: ✭ 22 (-8.33%)
Mutual labels:  connexion
mattermost-api-reference
Mattermost API reference documentation.
Stars: ✭ 74 (+208.33%)
Mutual labels:  openapi
oauth1-signer-ruby
Zero dependency library for generating a Mastercard API compliant OAuth signature.
Stars: ✭ 15 (-37.5%)
Mutual labels:  openapi
swagger-converter
OpenAPI/Swagger 2.0 to OpenAPI 3.0 Converter WebService
Stars: ✭ 58 (+141.67%)
Mutual labels:  openapi
openapi-types.ts
Generated TypeScript definitions based on GitHub's OpenAPI spec
Stars: ✭ 30 (+25%)
Mutual labels:  openapi
openapi-generator-go
An opinionated OpenAPI v3 code generator for Go. Use this to generate API models and router scaffolding.
Stars: ✭ 42 (+75%)
Mutual labels:  openapi
openapi-client
Generate ES6 or Typescript service integration code from an OpenAPI 2 spec
Stars: ✭ 92 (+283.33%)
Mutual labels:  openapi
fastapi-tortoise
The template for building scalable web APIs based on FastAPI, Tortoise ORM and other.
Stars: ✭ 95 (+295.83%)
Mutual labels:  openapi
pyotr
Python OpenAPI-to-REST (and back) framework
Stars: ✭ 54 (+125%)
Mutual labels:  openapi
ogen
OpenAPI v3 code generator for go
Stars: ✭ 436 (+1716.67%)
Mutual labels:  openapi
openapi
OpenAPI 3 Specification for golang
Stars: ✭ 18 (-25%)
Mutual labels:  openapi
sttp-openapi-generator
Generate sttp client from openapi specification with ease!
Stars: ✭ 26 (+8.33%)
Mutual labels:  openapi
whook
Build strong and efficient REST web services.
Stars: ✭ 18 (-25%)
Mutual labels:  openapi
mock-json-schema
Simple utility to mock example objects based on JSON schema definitions
Stars: ✭ 23 (-4.17%)
Mutual labels:  openapi
restdocs-spec
A maven plugin for generating Open API and Postman Collection specifications using Spring Restdocs.
Stars: ✭ 43 (+79.17%)
Mutual labels:  openapi
moko-network
Network components with codegeneration of rest api for mobile (android & ios) Kotlin Multiplatform development
Stars: ✭ 107 (+345.83%)
Mutual labels:  openapi
lokole
Source code for the Lokole project. Lokole enables communities in the Congo DRC to pool resources to access efficient communication via email at an affordable price.
Stars: ✭ 37 (+54.17%)
Mutual labels:  connexion

Connexion Example REST Service with Redis Store

This example application implements a very basic "pet shop" REST service using the Connexion Python library. Compared to hjacobs/connexion-example, this setup focuses more on operational aspects and includes Redis as a persistent storage and Kubernetes deployment manifests.

QUICKSTART: Please follow the steps to deploy to Kubernetes (Minikube).

This example should demonstrate:

  • how to map an OpenAPI/Swagger specification to Python code with Connexion
  • how to run Connexion with gevent
  • how to build a Docker image for Connexion
  • how to integrate a simple persistent database (Redis)
  • how to set up Kubernetes manifests for deployment and making sure rolling updates do not cause downtime
  • how to configure some best practices for production usage

This example is NOT:

  • a real world application (unless you need a REST service to store pets)
  • a production-ready service
  • a best practice setup for a persistent database (Redis has its own issues, but is used here to keep the database part simple)

DISCLAIMER: While trying to show some best practices for production usage, this is still just an example project --- especially the Redis database setup is not highly available (single replica).

Local Development

This requires Pipenv:

pipenv install --dev
pipenv shell
docker run -d --name connexion-example-redis -p 6379:6379 redis:4-alpine
./app.py
xdg-open http://localhost:8080/ui/

Deploying to Kubernetes (Minikube)

First install and then start Minikube:

minikube start

Build the Docker image:

eval $(minikube docker-env)
docker build -t connexion-example:local-minikube .

Deploy to Kubernetes:

kubectl apply -f deploy/

Wait for pods to come up:

kubectl get pod

Create a pet:

url=$(minikube service connexion-example --url)
curl -X PUT $url/pets/susie -d '{"animal_type": "cat", "name": "Susie", "tags": {"color": "black"}}' -H Content-Type:application/json

Get all pets:

curl $url/pets

Simple load test with Vegeta:

echo "GET $url/pets" | vegeta attack -rate 100 -duration 60s | vegeta report

The output should look something like this (depends on your hardware/VM configuration):

Requests      [total, rate]            6000, 100.02
Duration      [total, attack, wait]    1m0.034341468s, 59.98999991s, 44.341558ms
Latencies     [mean, 50, 95, 99, max]  41.344672ms, 46.279545ms, 52.171431ms, 54.320335ms, 72.515124ms
Bytes In      [total, mean]            3156000, 526.00
Bytes Out     [total, mean]            0, 0.00
Success       [ratio]                  100.00%
Status Codes  [code:count]             200:6000
Error Set:

High Availability

While the setup gracefully handles rolling deployments (try it out by changing a pod label in deploy/deployment.yaml and doing kubectl apply -f deploy/), it cannot handle Redis downtimes without causing HTTP errors. Deleting the Redis pod causes a ~10 seconds unavailability for the REST service:

Vegeta Plot for unavailability caused by Redis downtime

The above latency cap at 5000ms reflects the configured Redis socket timeout of 5 seconds.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].