Managed Kubernetes Platform
Follow these steps to have a local running copy of the app.
git clone https://github.com/crane-cloud/backend.gitHere's a great resource to check out: How To Install and Use PostgreSQL
Create the two databases:
cranecloud(for development)cranecloud_test_db(for unit testing)
App was developed with Python 3.6.
Make sure you have pip installed on your machine.
Create a pip virtual environment called venv.
python -m venv venvActivate the virtual environment:
.\venv\Scripts\activateInstall the dependencies:
pip install -r requirements.txtCreate a .env file (which defines the environment variables used) at the root of the app.
Add the following details, customizing as needed:
export FLASK_APP=server.py
export FLASK_ENV=development
export FLASK_DEBUG=1
export FLASK_RUN_PORT=5000
export FLASK_APP_SECRET=<app_secret>Run the application:
flask runmake is a build automation tool that is used to manage the build process of a software project.
- In the project directory, running
makeshows you a list of commands to use. - Run
make startto start the application and required services. - Run
make connect-to-containerto connect to the Flask application container after runningmake start.
Application should be running on http://localhost:5000 and apidocs on http://localhost:5000/apidocs/#/
To run with Docker, you have to ssh into the container first by running
make connect-to-container, and then execute the following commands.
The application uses SQLAlchemy ORM to manage and run database migrations.
To run migration upgrade against the database relations, use the following command:
flask db upgradeTo run migrations in case there are changes in the schema, use the following command:
flask db migrateThis app uses nose to run tests.
To run tests with coverage:
nosetests --with-coverage --cover-package=routesTo run tests without coverage:
nosetestsTo create the default roles, run:
flask create_rolesTo create an admin account, run:
flask admin_user --email=<email> --password=<password> --confirm_password=<password>Run the application using flask run and visit http://127.0.0.1:5000/apidocs/#/clusters/post_clusters
Use the following JSON payload:
{
"description": "string",
"host": "string",
"name": "string",
"token": "string"
}Reach out to the backend team to get token and host values.
To add image repositories to the database, run:
flask create_registriescelery -A server.celery worker --loglevel=info
celery -A server.celery beat --loglevel=infocelery -A server.celery worker --pool=solo --loglevel=info
celery -A server.celery beat --loglevel=info