Skip to content

jkogut/k8s-py-rest-api-v1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

k8s-py-rest-api-v1

Proof of concept for deployment to k8s of simple python REST API

Build Status MIT license

Table of Contents

Install locally
Deploy to K8S
Run tests
Debug

Install

To install locally clone the repo first, then build the docker image and run it:

$ git clone git@github.com:jkogut/simple-python-rest-api-v1.git
$ docker build --tag simple_python_rest_api .
$ docker run -p 127.0.0.1:5002:5002 -d simple_python_rest_api

Run tests with pytest to check if API works:

$ py.test -v -l test_rest_api_docker.py

Test

Test available endpoints with curl:

Example usage:

$ curl http://0.0.0.0:5002/api/status |jq
$ curl http://0.0.0.0:5002/api/v1/employees |jq
$ curl http://0.0.0.0:5002/api/v1/employees/1 |jq
$ curl -H "Content-Type: application/json" -X POST -d@payload.json http://0.0.0.0:5002/api/v1/employees/new |jq
$ curl -X DELETE http://0.0.0.0:5002/api/v1/employees/delete/9 |jq

Debug

Clone the repo:

$ git clone git@github.com:jkogut/simple-python-rest-api-v1.git

Use virtualenv and install dependencies with pip:

$ virtualenv venv
$ source venv/bin/activate
$ pip install -r app/requirements.txt

Run flask rest application in debug mode:

$ cd app;
$ python rest_server.py