Companion library for 12-factor app support in Charmcraft & Rockcraft.
Project description
PaaS Charm
Easily deploy and operate your Flask or Django applications and associated infrastructure, such as databases and ingress, using open source tooling. This lets you focus on creating applications for your users backed with the confidence that your operations are taken care of by world class tooling developed by Canonical, the creators of Ubuntu.
Have you ever created an application and then wanted to deploy it for your users only to either be forced to use a proprietary public cloud platform or manage the deployment and operations yourself? PaaS Charm will take your application and create an OCI image using Rockcraft and operations code using Charmcraft for you. The full suite of tools is open source so you can see exactly how it works and even contribute! After creating the app charm and image, you can then deploy your application into any Kubernetes cluster using Juju. Need a database? Using Juju you can deploy a range of popular open source databases, such as PostgreSQL or MySQL, and integrate them with your application with a few commands. Need an ingress to serve traffic? Use Juju to deploy and integrate a range of ingresses, such as Traefik, and expose your application to external traffic in seconds.
Getting Started
There are 2 requirements for the flask application:
- There is a
requirements.txt
file in the project root - The WSGI path is
app:app
Make sure that you have the latest/edge
version of Charmcraft and Rockcraft
installed:
sudo snap install charmcraft --channel latest/edge --classic
sudo snap install rockcraft --channel latest/edge --classic
Both have the flask-framework
profile to create the required files
and include the flask-framework
extension which will do all the hard
operational work for you and you just need to fill in some metadata in the
rockcraft.yaml
and charmcraft.yaml
files. To create the necessary files:
rockcraft init --profile flask-framework
mkdir charm
cd charm
charmcraft init --profile flask-framework
After packing the rock and charm using rockcraft pack
and charmcraft pack
and uploading the rock to a k8s registry, you can juju deploy your flask
application, integrate it with ingress and start serving traffic to your users!
Read the comprehensive getting started tutorial for more!
Additional resources:
- Tutorial to build a rock for a Flask application
- Charmcraft
flask-framework
reference - Charmcraft
flask-framework
how to guides - Rockcraft
flask-framework
reference
Contributing
Is there something missing from the PaaS Charm framework? PaaS Charm welcomes contributions! This section covers how to add a new integration and a new framework.
Add an Integration
There are a few recommended steps to add a new integration which we'll go through below.
- Please write a proposal on the charm topic on discourse. This should cover things like:
- The integration you intend add
- For each of the frameworks that PaaS Charm supports:
- The commonly used package(s) to make use of the integration
- The environment variables, configuration etc. that would be made available to the app
- An example for how to use the integration within an app
- The proposed implementation in
paas-app
. Take a look atcharm.py
forgunicorn
based frameworks for integration examples.
- Update the reference with the new integration
- Raise a pull request to this repository adding support for the integration.
- Add a commented entry for
requires
to all the relevant Charmcraft templates for the new integration
Add a Framework
There are a few recommended steps to add a new framework which we'll go through below.
- Please write a proposal on the charm topic on discourse. This should cover things like:
- The programming language and framework you are thinking of
- Create an example
rockcraft.yaml
file and build a working OCI image. To see an example forflask
, install Rockcraft and runrockcraft init --profile flask-framework
and runrockcraft expand-extensions
and inspect the output. - Create an example
charmcraft.yaml
file and build a working charm. To see an example forflask
, install Charmcraft and runcharmcraft init --profile flask-framework
and runcharmcraft expand-extensions
and inspect the output. - How the configuration options of the charm map to environment variables, configurations or another method of passing the information to the app
- The requirements and conventions for how users need to configure their app to work with PaaS Charm
- Which web server to use
- Raise a pull request to rockcraft adding a new extension and profile for the framework. This is the flask profile and extension. The OCI image should work standalone, not just with the charm for the framework.
- Raise a pull request to this repository adding a new parent class that can be used by the app charms. The following is the example for flask.
- Raise a pull request to charmcraft adding a new extension and profile for the framework. This is the flask profile and extension.
- Write a tutorial and reference documentation for the framework. As an example, this is the flask tutorial and reference documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for paas_charm-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c6b4243a91f8ac59cbbdc8ab12b601191d7c1ecb450e14270ac05bd4b9072f8 |
|
MD5 | bb24fc429a7bae9525bb293cae94e5b3 |
|
BLAKE2b-256 | 3acad54c49a641dd41097a0bf2fb81752e78f98e332e3eccd63f68837cfe1b7e |