Great to hear you're interested in writing a Django charm for juju! I have toyed around with the idea, but never got around to implementing something good.
I started looking at the current Django charm a little while ago, and while it works to some extend I think we could make really great things happen with a little work.
As far as feedback for your point goes, here are a few points and suggestion I'd like to add to the discussion:
- Most of the Django websites will likely live in private git/bzr/whatever repositories, and so in the workflow you outlined, you need to somehow push the *private identifier* to the running juju instance. In the "standard" scenario that means pushing your private ssh key to the instance, so it can git clone from a private repository on github... I think it's safe to say that most people will at least frown at the idea :)
Maybe we should instead make this a "push" process?
- It seems a little strange to me to run gunicorn on another machine. Most of the Django project I have encountered run Django with gunicorn on the webservers themselves (add gunicorn to INSTALLED_APPS and then "manage.py run_gunicorn"). Perhaps we should be a little more opinionated about things and for the sake of scaling simplicity deploy nginx or apache locally too (wither with a charm subordinate or at install), so that we can load-balance to all of the servers easily with any frontend (that means all webservers would serve static files, which might not be optimal, but we can refine that later).
- We should absolutely define a cache relation (redis or memcached).
Theses points would make the whole workflow look like the following (the juju syntax might be a little wrong, but please bear with me :) )
juju bootstrap
juju deploy --config my_django_conf.yaml cs:django_server my_django_site
juju deploy cs:postgresql # or mysql,mongodb, etc
juju deploy cs:memcached # or redis if that's still popular
juju deploy cs:haproxy
juju add-relation my_django_site postgresql
juju add-relation my_django_site memcached
juju add-relation my_django_site haproxy # strictly speaking that's optional if you have only one django machine
juju expose haproxy
# when needed (I hope we all need it someday!)
juju add-unit my_django_site
juju add-unit memcached
juju add-unit postgresql
So now we would have a running django server with no code.
But if it's a push process, we can implement many of the config changes as git hooks, which makes the workflow continue with:
cd my-django-site
git init . # If that's not done already of course
git add .
git commit -m "produciton push yay!"
git remote add production git+ssh://my_django_site/some_configurable_url.git
git push production master # or of course whatever branch you put in the config.yaml
Of course, that requires a non-trivial amount of git triggers to be written, and we should put some requirements.pip.txt file and requirements.apt.txt or whatever in the project tree, but I think that's acceptable.
The whole thing basically follows what many PaaS providers already do, so I guess most Django developers with some sites in production probably are familiar with the workflow.
This would just add the juju coolness to it :)
Hope this fuels the discussion,
- Chris
On Friday, March 1, 2013 8:13:36 PM UTC+1, Patrick wrote:
Hi,I'm building a Juju based Open Source Paas platform for Django andI need your help because it is a hard task to make a PAAS systemthat is flexible enough to deploy any projects and at the same timesimple to use.For the ones that don't know Juju, it's a service orchestration softwarecompatible with LXC (local), EC2, HPCloud, OpenStack and Baremetal/Maasdeveloped by Canonical (the company that makes Ubuntu).Check out the web site for more details: https://juju.ubuntu.com/So quickly, here's how it would works:After installing Juju and configuring it with for your favourite cloud provider youwill need to create a configuration file in the YAML format named my_django_conf.yamlin this example::my_django_site:vcs: gitrepos_url: https://github.com/my_username/my_site.git site_secret_key: abcdefgh123456789use_virtualenv: TrueThen you will need these commands to bootstrap and launch all the servers::juju bootstrapjuju deploy --config my_django_conf.yaml my_django_sitejuju deploy postgresql # or mysql,mongodb, etcjuju deploy gunicorn # Or mod_wsgi, etcjuju add-relation my_django_site postgresqljuju add-relation my_django_site gunicornjuju expose gunicorn # Open the tcp port in the firewallYou will end up with 3 servers running. One will be the controllerand one for each service (django and the database).Gunicorn will be a special charm that will be installed on your Django server.After that, adding a new Django node would be as simple as::juju add-unit my_django_siteAs I said, where it gets tricky is how do I make the configuration flexible enoughand at the same time simple.After looking at what was existing in Django's Paas world, I came with this:1 - We need a configurable requirements files for both pip and apt-get. By defaultit would be looking for package in there files at install time::requirements_pip_files: requirements.txt,requirements.pip requirements_apt_files: requirements.aptand we could also configure extra packages by adding variables like this in the YAML file::additional_distro_packages: vim,emacs,etcadditional_pip_packages: virtualenvwrapper,celery,South,etc 2 - I'm suggesting to use separate configurations files in a settings/ directoryso by default it will be injecting configuration in those files::settings_database_path: settings/20-engine.pysettings_static_path: settings/20-static.pysettings_uploads_path: settings/20-media.pysettings_cache_path: settings/30-cache.pysettings_secret_key_path: settings/20-secret.pyI'm suggesting splitting settings because when the configuration is modified,for some reason, it would be difficult and risky to parse settings.py andchange only the right thing.So instead, I would be using topic files rendered with templates.So if you would need to do more advanced stuff you could just fork the charmand modify the templates for your needs.3 - Finally, I was thinking adding some options to execute custom scripts thatwould run a various time during the deployment. Like after packages installation,database configuration and static file configuration::post_database_script:type: stringdefault: |#!/bin/shpython manage.py syncdb --noinputpython manage.py migrate --noinputpost_static_script:type: stringdefault: |#!/bin/shpython manage.py collectstatic -v 0 --noinputNote that this is not making unanimity so far.There is several reasons that makes the scripts approach tricky:* You don't want to execute these scripts every time a little detail change.* You might need the database configuration to be ready for some script.* You could be not using south* You might want to import some initial data and maybe only once at install time.* You could want to compress static files after running collectstatic* etcAn other idea could be to use a Fabric plug-in that use Juju's database to connectto the machines and run commands like this for example::fab -R my_django_site python manage.py pullwould pull the latest version of the site and reload the application on everydeployed Django machines.The bottom line here is that it's not simple to find out what a standardDjango deployment (and is maintenance) looks like.That being said, I'm really looking forwards for you comments and suggestions.Patrick
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment