Giter VIP home page Giter VIP logo

kubezephyr-backend's Introduction

KubeZephyr backend

This project is KubeZephyr backend based on fastapi+mongodb. It can operate kubernetes resources with web API.

Quickstart

Clone git repo and run pip3 install

git clone https://github.com/zephyrxvxx7/KubeZephyr-Backend.git
cd kubezephyr-backend
pip3 install -f requirements.txt

Then create .env file in project root and set environment variables for application:

touch .env
echo "PROJECT_NAME=KubeZephyr" >> .env
echo MONGODB_URL=mongo://$MONGO_USER:$MONGO_PASSWORD@$MONGO_HOST:$MONGO_PORT/$MONGO_DB >> .env
echo SECRET_KEY=$(openssl rand -hex 32) >> .env
echo ALLOWED_HOSTS='"127.0.0.1", "localhost"' >> .env
echo K8S_DOMAIN=$DOMAIN >> .env
echo K8S_CLUSTER_ISSUER=$ISSUER >> .env

echo GRAFANA_API_KEY=$API_KEY >> .env
echo GRAFANA_SERVER=$SERVER_URL >> .env

To run the web application in debug use:

python3 start_server.py

Build into Docker image

The build file includes the builds and uploads to the Docker Hub. Just exec this command line:

./build_docker.sh

Deployment with Docker

You must have docker and docker-compose tools installed to work with material in this section. First, create .env file like in Quickstart section or modify .env.example. MONGO_HOST must be specified as db or modified in docker-compose.yml also. Then just run:

docker-compose up -d

Application will be available on localhost or 127.0.0.1 in your browser.

Depolyment with Kubernetes

This project also can deployment in the Kubernetes cluster. If you want to use. Just to modify file deploy-k8s.yaml with your config to deployment. Then run:

kubectl apply -f deploy-k8s.yaml

Note: The image needs to push to the Docker hub before deployment.

Web routes

All routes are available on /docs or /redoc paths with Swagger or ReDoc.

Project structure

Files related to application are in the app directory

models     - pydantic models that used in crud or handlers
crud       - CRUD for types from models (create new user/article/comment, check if user is followed by another, etc)
db         - db specific utils
core       - some general components (jwt, security, configuration)
api        - handlers for routes
kubernetes - Operate kubernetes API resources with Python client
grafana    - Operate Grafana API
main.py - FastAPI application instance, CORS configuration and api router including

Related Efforts

kubezephyr-backend's People

Contributors

zephyrxvxx7 avatar

Stargazers

 avatar  avatar

Watchers

 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.