Large Events (Knative Proof of Portability)
An app built as proof of portability for Knative that provides a platform for event organizers to share info during large events like concerts, parades, expos, etc. Key features of this app include:
- Allow authorized event organizers to create and edit events
- Handle uploading and serving multimedia posts made by attendees
- Organize and filter multiple sub-events
- Provide a clean front-end web UI for interaction with the service
- Authenticate with OAuth 2.0
This app is built as part of a proof of portability project for Knative. It is meant to show the key features of Knative, to test the conformance across various cloud product implementations of Knative, and to document with functioning sample code how one might develop, build, and deploy with Knative. Key features of Knative this app demonstrates include:
- Develop microservices independently that can be individually deployed, updated, and auto-scaled
- Deploy containerized code with minimal configuration, allowing the developer to focus on features rather than infrastructure
- Run serverless, stateful containers that enable pay-for-use billing
A note on microservices
This project is organized into microservices. Although this repository contains a few top level files such as this README.md, each direct subfolder of this project is its own independent microservice. This means a few things:
- Each microservice subfolder is meant to be built and deployed independently from each other
- The microservices interact with each other in deployment through HTTP requests
- You will need to supply environment variable to the microservices specifying each others' endpoints
- Each subfolder has its own README.md with more specific information regarding building, testing, deployment, etc.
There are 4 microservices in this project. They are:
- events - Add, edit, and fetch events list.
- pageserve - Serve web UI and act as an API gateway to other microservices.
- posts - Add, edit, and fetch posts list.
- users - Authenticate with Google Sign-In, edit and fetch authorization level of users.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. Because of this microservice architecture, each subfolder will need to be deployed as its own independent subfolder. For specific instructions, see the README.md file in each subfolder, but generally, they all follow the following pattern:
These microservices are written in Python 3 and should run on Python 3.6+.
How to install and run each microservice for local development.
Each microservice has slightly different dependencies and thus slightly different installation procedures. Generally, installation for each microservice is as follows, but each subfolder's README.md has an "Installing" section with more accurate instructions.
Install into a virtualenv:
cd events python3 -m venv venv && . venv/bin/activate pip3 install -r requirements.txt
Provision a MongoDB instance (e.g. via MongoDB Atlas), then provide the app with its endpoint via an environment variable (this step is not needed for the pageserve microservice).
Set any other environment variables needed by the microservice.
export USERS_ENDPOINT="https://endpoint.where-users-is-deployed.com/v1/" export EVENTS_ENDPOINT="https://endpoint.where-events-is-deployed.com/v1/" export GAUTH_CLIENT_ID="123-my-google-oauth-service-client-id-456" export FLASK_SECRET_KEY="some secure and unique byte-string" ...
Running the service
To locally run a microservice, execute
app.py with Python.
Running the tests
Testing again is handled on the microservice level. To test, ensure your working directory is the microservice's subfolder then use
python3 -m unittest discover
To see code coverage, use Coverage.py
# install coverage if you don't already have it python3 -m pip install --upgrade coverage # run coverage on all discovered tests analyzing the 'app' package coverage run -m --source app unittest discover # report coverage with line numbers coverage report -m
This project is built for Knative and should be able to be deployed on any cloud product built on Knative or on any Kubernetes cluster. It has been tested on Google Cloud Run.
You can also manually deploy this project to a service like Cloud Run. For example, to deploy one of the microservices to the service [SERVICE] in the GCP project with ID [PROJECT-ID] run:
gcloud builds submit --tag gcr.io/[PROJECT-ID]/[SERVICE] gcloud beta run deploy --image gcr.io/[PROJECT-ID]/[SERVICE] --platform managed
- Python 3 - Python programming language
- Flask - Python web service framework
- pymongo - MongoDB Python client
- GitHub - Development platform for open source
- Travis CI - Hosted continuous integration service
- Gunicorn - Python WSGI HTTP Server for UNIX
- unittest - Python unit testing framework
- Coverage.py - Python code coverage measurement tool
- Coveralls - Test coverage history and statistics service
- MongoDB Atlas - Cloud NoSQL database
- Google Cloud Storage - Unified object storage for developers and enterprises
- Google Sign-In for Websites - OAuth 2.0 authentication library
- Google Cloud Build - Continuous build, test, deploy in the cloud
- Google Cloud Run - On top of Knative, run fully managed stateless containers
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
See also the list of contributors who participated in this project.
This project is licensed under the Apache 2.0 License - see the LICENSE.md file for details.