Managed Kubernetes Platform
Follow these steps to have a local running copy of the app.
git clone https://github.com/crane-cloud/backend.git
Here'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 venv
Activate the virtual environment:
.\venv\Scripts\activate
Install the dependencies:
pip install -r requirements.txt
Create 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 run
make 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 upgrade
To run migrations in case there are changes in the schema, use the following command:
flask db migrate
This app uses nose to run tests.
To run tests with coverage:
nosetests --with-coverage --cover-package=routes
To run tests without coverage:
nosetests
To create the default roles, run:
flask create_roles
To 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_registries
celery -A server.celery worker --loglevel=info celery -A server.celery beat --loglevel=info
celery -A server.celery worker --pool=solo --loglevel=info celery -A server.celery beat --loglevel=info