Deployability. of Python. web applications

Similar documents
DISQUS. Continuous Deployment Everything. David

datapusher Documentation

Gunnery Documentation

School Navigator Documentation

Distributed CI: Scaling Jenkins on Mesos and Marathon. Roger Ignazio Puppet Labs, Inc. MesosCon 2015 Seattle, WA

I hate money. Release 1.0

Python web frameworks

Niv Mizrahi. VP github.com/nivm

Pulp Python Support Documentation

Trunk Player Documentation

Python Project Documentation

django-jenkins Documentation

upaas Documentation Release 0.2 Łukasz Mierzwa

open-helpdesk Documentation

Created by: Nicolas Melillo 4/2/2017 Elastic Beanstalk Free Tier Deployment Instructions 2017

Using NGiNX for release automation at The Atlantic

nacelle Documentation

LSST software stack and deployment on other architectures. William O Mullane for Andy Connolly with material from Owen Boberg

Software Development I

Django MFA Documentation

The Long Road from Capistrano to Kubernetes

TM DevOps Use Case. 2017TechMinfy All Rights Reserved

Biostar Central Documentation. Release latest

Cloud Computing II. Exercises

Heroku. Rimantas Kybartas

Aldryn Installer Documentation

Getting Started With Containers

dh-virtualenv Documentation

NVIDIA DIGITS CONTAINER

INFRASTRUCTURE AS CODE

Advanced Continuous Delivery Strategies for Containerized Applications Using DC/OS

Garment Documentation

bootmachine Documentation

DEPLOYMENT MADE EASY!

How to bootstrap a startup using Django. Philipp Wassibauer philw ) & Jannis Leidel

DevOps Course Content

Django Wordpress API Documentation

Index. Bessel function, 51 Big data, 1. Cloud-based version-control system, 226 Containerization, 30 application, 32 virtualize processes, 30 31

dj-libcloud Documentation

Build, test and release your python packages

LECTURE 15. Web Servers

django-dynamic-db-router Documentation

UNDER THE HOOD. ROGER NUNN Principal Architect/EMEA Solution Manager 21/01/2015

TangeloHub Documentation

Python Packaging. Jakub Wasielak

django-private-chat Documentation

GIT. A free and open source distributed version control system. User Guide. January, Department of Computer Science and Engineering

LAB EXERCISE: RedHat OpenShift with Contrail 5.0

This tutorial provides a basic understanding of the infrastructure and fundamental concepts of managing an infrastructure using Chef.

doconv Documentation Release Jacob Mourelos

Implementing the Twelve-Factor App Methodology for Developing Cloud- Native Applications

django-reinhardt Documentation

coxtactoe Documentation

Kinto Documentation. Release Mozilla Services Da French Team

Managing Dependencies and Runtime Security. ActiveState Deminar

python-packaging Documentation

django-fabric Documentation

Dell EMC Networking Saltstack Integration Documentation

By: Jeeva S. Chelladhurai

Poulpe Documentation. Release Edouard Klein

Python Development Workflow

Patch Server for Jamf Pro Documentation

Confire Documentation

DNS Zone Test Documentation

Jackalope Documentation

Installing and Using Docker Toolbox for Mac OSX and Windows

Building Microservices with the 12 Factor App Pattern

django simple pagination Documentation

Docker on VDS. Aurelijus Banelis

INDIGO PAAS TUTORIAL. ! Marica Antonacci RIA INFN-Bari

Easy-select2 Documentation

Building a Django Twilio Programmable Chat Application

Managing Infrastructure with Python, Fabric and Ansible. By Tim Henderson hackthology.com github.com/timtadh

Continuous Delivery for Python Developers PyCon 8, 2017

Git Basi, workflow e concetti avanzati (pt2)

CS 410/510: Web Security X1: Labs Setup WFP1, WFP2, and Kali VMs on Google Cloud

Beginners guide to at #phpworld

OpenShift 3 Technical Architecture. Clayton Coleman, Dan McPherson Lead Engineers

chatterbot-weather Documentation

There Should be One Obvious Way to Bring Python into Production. Sebastian Neubauer

Building Scalable Web Apps with Python and Google Cloud Platform. Dan Sanderson, April 2015

viki-fabric-helpers Documentation

TM DevOps Use Case. 2017TechMinfy All Rights Reserved

Chris Calloway for Triangle Python Users Group at Caktus Group December 14, 2017

withenv Documentation

Copyright 2016 Pivotal. All rights reserved. Cloud Native Design. Includes 12 Factor Apps

Tutorial 4 Data Persistence in Java

devops with

MapEntity Documentation

Configuration Management

django-cas Documentation

Python Schema Generator Documentation

CROWDCOIN MASTERNODE SETUP COLD WALLET ON WINDOWS WITH LINUX VPS

Tutorial: Getting Started with Git. Introduction to version control Benefits of using Git Basic commands Workflow

Django-frontend-notification Documentation

Libra Client Documentation

Python wrapper for Viscosity.app Documentation

django-idioticon Documentation

Technical Manual. Software Quality Analysis as a Service (SQUAAD) Team No.1. Implementers: Aleksandr Chernousov Chris Harman Supicha Phadungslip

calyptos Documentation

Transcription:

Deployability of Python web applications Bruno Renié EuroPython 2013

Deployability, n The extent to which something is deployable

Disclaimer Most of this isn't python-specific or even web-specific Oriented at custom infrastructures Some things still apply if you're on PaaS

How easy it is to install, configure and operate your software?

Mostly about devs and ops working together

12factor.net

installation configuration operation

Installation

Installing postgres sudo apt-get install postgresql

Installing a python webapp sudo apt-get install build-essential python-virtualenv git clone https://deadbeef@github.com/corp/repo cd repo virtualenv env env/bin/pip install -r requirements.txt # Figure out PYTHONPATH

Installing a python webapp sudo apt-get install build-essential python-virtualenv git clone https://deadbeef@github.com/corp/repo cd repo virtualenv env env/bin/pip install -r requirements.txt # Figure out PYTHONPATH

Installing software is a solved problem Just use packaging Yep, python packaging

Why python packaging? Release process Dependency management Trivial rollbacks Easy system packaging

Packaging in 30 seconds # setup.py from distutils.core import setup from setuptools import find_packages with open('requirements.txt') as reqs: install_requires = reqs.read().split('\n') setup( name='project', version= import ('project'). version, packages=find_packages(), include_package_data=true, zip_safe=false, install_requires=install_requires, ) # MANIFEST.in include requirements.txt recursive-include project *

Private package hosting Local filesystem python setup.py sdist pip install --download dist -r requirements.txt rsync -avz -e ssh dist/ host.corp.com:/srv/pypi pip install --no-index --find-links=/srv/pypi myproject Network-based, ala pypi.python.org HTML directory index (apache / nginx / SimpleHTTPServer) pip install --no-index --find-links=http://host myproject

System packages https://github.com/jordansissel/fpm fpm -s python -t deb setup.py awk -F= '{printf "fpm -s python -t deb -v %s %s\n", $3, $1}' \ requirements.txt sh Sign, upload to your private repository https://github.com/rcrowley/freight sudo apt-get install python-myproject sudo apt-get install python-myproject=1.2.3

Pin your dependencies Bad Django Django>=1.4,<1.5 Good Django==1.4.5 This is for end products, not libraries http://nvie.com/posts/pin-your-packages/

Configuration

Configuring postgres $EDITOR /etc/postgresql/9.2/main/postgresql.conf service postgresql restart

Does your app have a config file? settings.py, production_settings.py are not config files Configuration!= code

Problems with configuration as code Incompatible with packaging Code shouldn't be tied to environments Code shouldn't be generated (salt / puppet / fabric) Environment-specific code Production-specific code will break production.

Define your configuration What changes between environments? Database Secret key Host / port Credentials to external services (AWS, Sentry ) Read configuration from your code.ini files yaml environment variables

Code changes release, deploy app Infrastructure changes write config, reload app

Config as environment variables Pros Trivial to set with $PROCESS_MANAGER Native to every programming language De-facto standard (PaaS). Interoperability! Cons Shared hosting Apache

Case study: Django settings settings_local.py settings_staging.py settings_prod.py Before DATABASES = {'default': {'HOST': 'localhost', }} DATABASES = {'default': {'HOST': 'staging', }} DATABASES = {'default': {'HOST': 'prod', }} After settings.py env DATABASES = {'default': dj_database_url.config()} DATABASE_URL="postgres://host:5432/db"

Config patterns Sane defaults when possible PORT = int(os.environ.get('port', 8000)) Use *_URL and parsers to reduce the number of variables EMAIL_URL DATABASE_URL REDIS_URL Prevent the app from booting if something critical is missing SECRET_KEY = os.environ['secret_key'] KeyError: 'SECRET_KEY'

In development django-dotenv virtualenvwrapper postactivate hooks custom manage.py envdir

Operation

WSGI Have a WSGI entry point gunicorn myapp.wsgi -b 0.0.0.0:$PORT

Stateless processes Persistence via external services Database Caching Storage

Scale out with processes More traffic? Spawn more processes. Caveat: backend services rarely scale horizontally

Maximize dev/prod parity Same software If you use postgres in production, use postgres in development Same versions PostgreSQL 9.1 and 9.2 do not perform equally Same people Developers should know about infrastructure

Continuous integration/deployment CI!= green badge on your github page CD!= always running master in production CI Having shippable code tested packaged installable CD Deploying it whenever your want

Example workflow Commit Run tests Package Staging Production

Example workflow Commit Run tests Package manual or automated Staging Production Jenkins, SaltStack, IRC bots are your automation friends

use packaging to manage software clearly define the configuration contract automate as much as possible to minimize deployment friction

? @brutasse bruno@renie.fr