SlideShare ist ein Scribd-Unternehmen logo
1 von 45
Downloaden Sie, um offline zu lesen
From Zero to Hero
Job Ganzevoort
Douwe van der Meij
Goldmund, Wyldebeast & Wunderliebe
{ ganzevoort, vandermeij } @gw20e.com
Outline
● Introduction
● Initial Setup
● Deployment
● Maintenance
● Deployment continued
● Conclusion
Introduction
● People have great ideas
● Django is perfect for RAD
○ But...
● How to deploy to production?
● How to keep the system maintainable?
○ Or even…
● When is my application production ready?
Why this presentation?
Initial Setup
● Before you do anything related to code:
○ git init
● Make sure you track everything you do in a
VCS
Version Control System
● In the first stage of development, program
only the parts that are the core of your
application
● But how to do this in git?
Define Minimum Viable Product
● Have base/production code in master
branch
● git branch for every code change
● Merge all branches with acceptance
branch before going live (again)
Use branches (1/2)
Use branches (2/2)
master
acceptance
time
bi-weekly
release
change #123
branch
mergemerge
Deployment
● VPS
● Provision with e.g., Puppet
● Find or create scripts
● Put the scripts in version control!
Server(s)
node 'kiezel.gw20e.com' {
class { 'ssh':
server_options => {
'PasswordAuthentication' => 'no',
'PermitRootLogin' => 'no',
},
}
appie::app { "mysite":
envs => ["tst", "acc", "prd"],
secret => "secret",
accountinfo => $gw20e::user_accounts,
accounts => ['ganzevoort', 'vandermeij'],
}
}
● Create a user per environment-layer
combination
○ app-mysite-tst
○ app-mysite-acc
○ app-mysite-prd
● With their own home dir, postgresql DB,
nginx glue
● Check out (and fork) our puppet module:
○ puppet-appie @ GitHub
Separate users
● Use fabric to script deploying to your
servers:
○ fab deploy:layer=tst
● Put the scripts in version control!
● Check out (and fork) our template:
○ templateproject @ GitHub
○ It includes gunicorn and supervisor configurations
Use scripts to deploy
● Don’t just change Django’s settings.py
● Keep dev, tst, acc and prd specific
settings in separate files
● Put the settings in version control!
Different DTAP layers (1/6)
● Deploy to their respective environment
Different DTAP layers (2/6)
DEV
● Laboratory setup
● Switch to the branch you’re working on
● Work with dev settings
● Deploy to TST, ACC or PRD environment
Different DTAP layers (3/6)
TST
● Real deployment, but alpha
● Work with tst settings
Different DTAP layers (4/6)
ACC
● Real deployment, but beta
● Work with acc settings
Different DTAP layers (5/6)
PRD
● Real deployment!
● Work with prd settings
● Setup monitoring
○ Nagios
○ Sentry
○ ...
● Setup backup
○ Database
○ Uploaded media
Different DTAP layers (6/6)
● Move settings.py as is to:
settings/core.py
● Create: settings/base.py
○ Add: from settings.core import *
○ Add your own generic settings
● Create: settings/{dev,tst,acc,prd}.
py
○ Add: from settings.base import *
○ Add your own layer specific settings
Django settings (1/4)
Django settings (2/4)
settings.py core.py
base.py
LAYER.py
settings/
● Use Fabric to create:
settings/__init__.py
● This command:
○ fab pick_settings:layer=prd
● Results in:
○ from settings.prd import *
● Stackable settings scale
○ Imagine (white) labeling
Django settings (3/4)
Django settings (4/4)
__init__.pysettings/
dev.py tst.py acc.py prd.py
base.py
core.py
Django settings (5/4)
Database passwords in version control?
from .base import *
read_pgpass('app-mysite-prd')
Maintenance
● Scrum, RUP, etc.
○ Any iterative methodology will do
● Basicly:
○ Have periodic deadlines/releases
■ Bi-weekly
○ Deliver each iteration
■ To ACC, if OK, to PRD
○ Release early, release often (MVP)
Iterative development
● Create a ticket for every change (RFC)
● Estimate the ticket
● Have discussion in ticket thread
● Create a code branch per ticket
○ Let git help you
● Deploy to a separate TST environment
○ (with separate database)
(How to) use a ticket system
Branching revisited
master
acceptance
time
bi-weekly
release
change #123
branch
mergemerge
iteration
● On your test machine, let each ticket/branch
have its own environment (with database)
● Test implementations individually, care for
code merging later
● Multiple TST environments means multiple
deployments
○ So not only three (= TST, ACC, PRD)
Separate environments for TST (1/5)
● change_123/$ fab deploy
● Is shorthand for:
○ fab deploy:layer=tst,branch=change_123
Separate environments for TST (2/5)
● Isn’t setting up separate webserver(s),
database(s), etc. causing a lot of overhead?
Separate environments for TST (3/5)
● Computer says NO
○ If you do it the right way
Separate environments for TST (4/5)
● Keep your (webserver) configuration files in
version control
○ Use e.g., Django templates to construct environment
specific files
● Keep your database scripts in version
control
○ To copy a new DB from a production fixture
○ To install a new DB from scratch with fixtures
○ Or both!
Separate environments for TST (5/5)
Deployment continued
● Have separate deployment settings per
layer:
○ use_https
○ path_to_certificate
○ sitename
○ deploy_user_at_host
○ dir_to_deploy_to
○ ...
Deployment settings (1/4)
Deployment settings (2/4)
LAYER.pydeployment/
● Use the Django template engine to construct
configuration files on deployment:
{% if use_https %}
server {
listen 80;
server_name {{ sitename }};
rewrite ^(.*) https://$server_name$request_uri?;
}
...
Deployment settings (3/4)
● Symlink the generated configuration files
from the user homedir into the place they’re
needed
● E.g.
○ ln -s ~/current/etc/nginx.conf
/etc/nginx/sites-enabled/SITENAME.conf
○ service nginx reload
Deployment settings (4/4)
● Create a tag for each PRD release
● Switch to that tag on deploy to PRD
○ For easy rollback
■ Switch to previous tag to rollback
● Run migration scripts after switch
○ Watch out for backwards incompatible changes!
Use Git tagging
● When using Pip
○ pip freeze > frozen.txt
● Add to version control!
● pip install -r frozen.txt
Freeze dependencies
Conclusion
● Use a VCS
● Have separate DTAP layers
● Script and store
● Work with RFCs
● Make everything repeatable
○ By your colleague
Conclusion(s)
● github.com/
○ Goldmund-Wyldebeast-Wunderliebe/
■ templateproject
■ puppet-appie
References
Thank you!
Job Ganzevoort,
Douwe van der Meij
Goldmund, Wyldebeast & Wunderliebe
{ ganzevoort, vandermeij } @gw20e.com

Weitere ähnliche Inhalte

Was ist angesagt?

Netflix Data Benchmark @ HPTS 2017
Netflix Data Benchmark @ HPTS 2017Netflix Data Benchmark @ HPTS 2017
Netflix Data Benchmark @ HPTS 2017
Ioannis Papapanagiotou
 

Was ist angesagt? (20)

ClickHouse in Real Life. Case Studies and Best Practices, by Alexander Zaitsev
ClickHouse in Real Life. Case Studies and Best Practices, by Alexander ZaitsevClickHouse in Real Life. Case Studies and Best Practices, by Alexander Zaitsev
ClickHouse in Real Life. Case Studies and Best Practices, by Alexander Zaitsev
 
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander ZaitsevMigration to ClickHouse. Practical guide, by Alexander Zaitsev
Migration to ClickHouse. Practical guide, by Alexander Zaitsev
 
Netflix Data Benchmark @ HPTS 2017
Netflix Data Benchmark @ HPTS 2017Netflix Data Benchmark @ HPTS 2017
Netflix Data Benchmark @ HPTS 2017
 
ClickHouse Paris Meetup. Pragma Analytics Software Suite w/ClickHouse, by Mat...
ClickHouse Paris Meetup. Pragma Analytics Software Suite w/ClickHouse, by Mat...ClickHouse Paris Meetup. Pragma Analytics Software Suite w/ClickHouse, by Mat...
ClickHouse Paris Meetup. Pragma Analytics Software Suite w/ClickHouse, by Mat...
 
Tick
TickTick
Tick
 
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
 
How to build analytics for 100bn logs a month with ClickHouse. By Vadim Tkach...
How to build analytics for 100bn logs a month with ClickHouse. By Vadim Tkach...How to build analytics for 100bn logs a month with ClickHouse. By Vadim Tkach...
How to build analytics for 100bn logs a month with ClickHouse. By Vadim Tkach...
 
Analyzing MySQL Logs with ClickHouse, by Peter Zaitsev
Analyzing MySQL Logs with ClickHouse, by Peter ZaitsevAnalyzing MySQL Logs with ClickHouse, by Peter Zaitsev
Analyzing MySQL Logs with ClickHouse, by Peter Zaitsev
 
Journey and evolution of Presto@Grab
Journey and evolution of Presto@GrabJourney and evolution of Presto@Grab
Journey and evolution of Presto@Grab
 
ClickHouse on Plug-n-Play Cloud, by Som Sikdar, Kodiak Data
ClickHouse on Plug-n-Play Cloud, by Som Sikdar, Kodiak DataClickHouse on Plug-n-Play Cloud, by Som Sikdar, Kodiak Data
ClickHouse on Plug-n-Play Cloud, by Som Sikdar, Kodiak Data
 
How to be Successful with Scylla
How to be Successful with ScyllaHow to be Successful with Scylla
How to be Successful with Scylla
 
Clickhouse at Cloudflare. By Marek Vavrusa
Clickhouse at Cloudflare. By Marek VavrusaClickhouse at Cloudflare. By Marek Vavrusa
Clickhouse at Cloudflare. By Marek Vavrusa
 
AWS Athena vs. Google BigQuery for interactive SQL Queries
AWS Athena vs. Google BigQuery for interactive SQL QueriesAWS Athena vs. Google BigQuery for interactive SQL Queries
AWS Athena vs. Google BigQuery for interactive SQL Queries
 
P99CONF — What We Need to Unlearn About Persistent Storage
P99CONF — What We Need to Unlearn About Persistent StorageP99CONF — What We Need to Unlearn About Persistent Storage
P99CONF — What We Need to Unlearn About Persistent Storage
 
BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013
 
Our Story With ClickHouse at seo.do
Our Story With ClickHouse at seo.doOur Story With ClickHouse at seo.do
Our Story With ClickHouse at seo.do
 
Supercharge your Analytics with ClickHouse, v.2. By Vadim Tkachenko
Supercharge your Analytics with ClickHouse, v.2. By Vadim TkachenkoSupercharge your Analytics with ClickHouse, v.2. By Vadim Tkachenko
Supercharge your Analytics with ClickHouse, v.2. By Vadim Tkachenko
 
You might be paying too much for BigQuery
You might be paying too much for BigQueryYou might be paying too much for BigQuery
You might be paying too much for BigQuery
 
Indexes don't mean slow inserts.
Indexes don't mean slow inserts.Indexes don't mean slow inserts.
Indexes don't mean slow inserts.
 
Mongo db admin_20110316
Mongo db admin_20110316Mongo db admin_20110316
Mongo db admin_20110316
 

Andere mochten auch

Udlrevolution
UdlrevolutionUdlrevolution
Udlrevolution
drrevdean
 
HHS: Using Tech To Reduce Paper Usage
HHS: Using Tech To Reduce Paper UsageHHS: Using Tech To Reduce Paper Usage
HHS: Using Tech To Reduce Paper Usage
drrevdean
 
How to enroll in bdo’s online banking
How to enroll in bdo’s online bankingHow to enroll in bdo’s online banking
How to enroll in bdo’s online banking
JeffBadanoy
 
4t Virtual Con Guerrilla Flip
4t Virtual Con Guerrilla Flip4t Virtual Con Guerrilla Flip
4t Virtual Con Guerrilla Flip
drrevdean
 

Andere mochten auch (20)

Sacrifice for success
Sacrifice for successSacrifice for success
Sacrifice for success
 
Sacrifice for success
Sacrifice for successSacrifice for success
Sacrifice for success
 
Edmodoparentfinal
EdmodoparentfinalEdmodoparentfinal
Edmodoparentfinal
 
Child find
Child findChild find
Child find
 
Udlrevolution
UdlrevolutionUdlrevolution
Udlrevolution
 
HHS: Using Tech To Reduce Paper Usage
HHS: Using Tech To Reduce Paper UsageHHS: Using Tech To Reduce Paper Usage
HHS: Using Tech To Reduce Paper Usage
 
Bryan Dean UDL-IRN Summit/March 2014
Bryan Dean UDL-IRN Summit/March 2014Bryan Dean UDL-IRN Summit/March 2014
Bryan Dean UDL-IRN Summit/March 2014
 
How to enroll in bdo’s online banking
How to enroll in bdo’s online bankingHow to enroll in bdo’s online banking
How to enroll in bdo’s online banking
 
Những đóng góp của ngành thương mại Việt Nam trong việc chống tụt hậu kinh tế...
Những đóng góp của ngành thương mại Việt Nam trong việc chống tụt hậu kinh tế...Những đóng góp của ngành thương mại Việt Nam trong việc chống tụt hậu kinh tế...
Những đóng góp của ngành thương mại Việt Nam trong việc chống tụt hậu kinh tế...
 
4t Virtual Con Guerrilla Flip
4t Virtual Con Guerrilla Flip4t Virtual Con Guerrilla Flip
4t Virtual Con Guerrilla Flip
 
1 modeling concepts
1 modeling concepts1 modeling concepts
1 modeling concepts
 
Building an open source python application the right way
Building an open source python application the right wayBuilding an open source python application the right way
Building an open source python application the right way
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Python
 
CLTL python course: Object Oriented Programming (1/3)
CLTL python course: Object Oriented Programming (1/3)CLTL python course: Object Oriented Programming (1/3)
CLTL python course: Object Oriented Programming (1/3)
 
Python
PythonPython
Python
 
AOP in Python API design
AOP in Python API designAOP in Python API design
AOP in Python API design
 
Rapid Web Development with Python for Absolute Beginners
Rapid Web Development with Python for Absolute BeginnersRapid Web Development with Python for Absolute Beginners
Rapid Web Development with Python for Absolute Beginners
 
Ingreso prefectura asignaturas
Ingreso prefectura asignaturasIngreso prefectura asignaturas
Ingreso prefectura asignaturas
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 
Protecting Your APIs Against Attack & Hijack
Protecting Your APIs Against Attack & Hijack Protecting Your APIs Against Attack & Hijack
Protecting Your APIs Against Attack & Hijack
 

Ähnlich wie From Zero to Hero @ PyGrunn 2014

A3Sec Advanced Deployment System
A3Sec Advanced Deployment SystemA3Sec Advanced Deployment System
A3Sec Advanced Deployment System
a3sec
 
Ceph Day Beijing: CeTune: A Framework of Profile and Tune Ceph Performance
Ceph Day Beijing: CeTune: A Framework of Profile and Tune Ceph Performance Ceph Day Beijing: CeTune: A Framework of Profile and Tune Ceph Performance
Ceph Day Beijing: CeTune: A Framework of Profile and Tune Ceph Performance
Ceph Community
 
Plc2 2015 your own ide
Plc2 2015 your own idePlc2 2015 your own ide
Plc2 2015 your own ide
Sigasi
 

Ähnlich wie From Zero to Hero @ PyGrunn 2014 (20)

A3Sec Advanced Deployment System
A3Sec Advanced Deployment SystemA3Sec Advanced Deployment System
A3Sec Advanced Deployment System
 
Getting started with drupal 8 code
Getting started with drupal 8 codeGetting started with drupal 8 code
Getting started with drupal 8 code
 
Buildout: creating and deploying repeatable applications in python
Buildout: creating and deploying repeatable applications in pythonBuildout: creating and deploying repeatable applications in python
Buildout: creating and deploying repeatable applications in python
 
GeoServer Developers Workshop
GeoServer Developers WorkshopGeoServer Developers Workshop
GeoServer Developers Workshop
 
Wrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetWrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from Puppet
 
Ceph Day Beijing: CeTune: A Framework of Profile and Tune Ceph Performance
Ceph Day Beijing: CeTune: A Framework of Profile and Tune Ceph Performance Ceph Day Beijing: CeTune: A Framework of Profile and Tune Ceph Performance
Ceph Day Beijing: CeTune: A Framework of Profile and Tune Ceph Performance
 
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
PostgreSQL Sharding and HA: Theory and Practice (PGConf.ASIA 2017)
 
High performance json- postgre sql vs. mongodb
High performance json- postgre sql vs. mongodbHigh performance json- postgre sql vs. mongodb
High performance json- postgre sql vs. mongodb
 
Upgrade to MySQL 5.6 without downtime
Upgrade to MySQL 5.6 without downtimeUpgrade to MySQL 5.6 without downtime
Upgrade to MySQL 5.6 without downtime
 
Installing and Upgrading AtoM
Installing and Upgrading AtoMInstalling and Upgrading AtoM
Installing and Upgrading AtoM
 
My "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails ProjectsMy "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails Projects
 
Pivotal Greenplum Cloud Marketplaces - Greenplum Summit 2019
Pivotal Greenplum Cloud Marketplaces - Greenplum Summit 2019Pivotal Greenplum Cloud Marketplaces - Greenplum Summit 2019
Pivotal Greenplum Cloud Marketplaces - Greenplum Summit 2019
 
Linux Distribution Automated Testing
 Linux Distribution Automated Testing Linux Distribution Automated Testing
Linux Distribution Automated Testing
 
Plc2 2015 your own ide
Plc2 2015 your own idePlc2 2015 your own ide
Plc2 2015 your own ide
 
Strategies for developing and deploying your embedded applications and images
Strategies for developing and deploying your embedded applications and imagesStrategies for developing and deploying your embedded applications and images
Strategies for developing and deploying your embedded applications and images
 
LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...
OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...
OSMC 2009 | Windows monitoring - Going where no man has gone before... by Mic...
 
High-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQLHigh-availability with Galera Cluster for MySQL
High-availability with Galera Cluster for MySQL
 
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios CoreNagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
 

Kürzlich hochgeladen

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Kürzlich hochgeladen (20)

10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 

From Zero to Hero @ PyGrunn 2014

  • 1. From Zero to Hero Job Ganzevoort Douwe van der Meij Goldmund, Wyldebeast & Wunderliebe { ganzevoort, vandermeij } @gw20e.com
  • 2. Outline ● Introduction ● Initial Setup ● Deployment ● Maintenance ● Deployment continued ● Conclusion
  • 4. ● People have great ideas ● Django is perfect for RAD ○ But... ● How to deploy to production? ● How to keep the system maintainable? ○ Or even… ● When is my application production ready? Why this presentation?
  • 6. ● Before you do anything related to code: ○ git init ● Make sure you track everything you do in a VCS Version Control System
  • 7. ● In the first stage of development, program only the parts that are the core of your application ● But how to do this in git? Define Minimum Viable Product
  • 8. ● Have base/production code in master branch ● git branch for every code change ● Merge all branches with acceptance branch before going live (again) Use branches (1/2)
  • 11. ● VPS ● Provision with e.g., Puppet ● Find or create scripts ● Put the scripts in version control! Server(s)
  • 12. node 'kiezel.gw20e.com' { class { 'ssh': server_options => { 'PasswordAuthentication' => 'no', 'PermitRootLogin' => 'no', }, } appie::app { "mysite": envs => ["tst", "acc", "prd"], secret => "secret", accountinfo => $gw20e::user_accounts, accounts => ['ganzevoort', 'vandermeij'], } }
  • 13. ● Create a user per environment-layer combination ○ app-mysite-tst ○ app-mysite-acc ○ app-mysite-prd ● With their own home dir, postgresql DB, nginx glue ● Check out (and fork) our puppet module: ○ puppet-appie @ GitHub Separate users
  • 14. ● Use fabric to script deploying to your servers: ○ fab deploy:layer=tst ● Put the scripts in version control! ● Check out (and fork) our template: ○ templateproject @ GitHub ○ It includes gunicorn and supervisor configurations Use scripts to deploy
  • 15. ● Don’t just change Django’s settings.py ● Keep dev, tst, acc and prd specific settings in separate files ● Put the settings in version control! Different DTAP layers (1/6)
  • 16. ● Deploy to their respective environment Different DTAP layers (2/6)
  • 17. DEV ● Laboratory setup ● Switch to the branch you’re working on ● Work with dev settings ● Deploy to TST, ACC or PRD environment Different DTAP layers (3/6)
  • 18. TST ● Real deployment, but alpha ● Work with tst settings Different DTAP layers (4/6)
  • 19. ACC ● Real deployment, but beta ● Work with acc settings Different DTAP layers (5/6)
  • 20. PRD ● Real deployment! ● Work with prd settings ● Setup monitoring ○ Nagios ○ Sentry ○ ... ● Setup backup ○ Database ○ Uploaded media Different DTAP layers (6/6)
  • 21. ● Move settings.py as is to: settings/core.py ● Create: settings/base.py ○ Add: from settings.core import * ○ Add your own generic settings ● Create: settings/{dev,tst,acc,prd}. py ○ Add: from settings.base import * ○ Add your own layer specific settings Django settings (1/4)
  • 22. Django settings (2/4) settings.py core.py base.py LAYER.py settings/
  • 23. ● Use Fabric to create: settings/__init__.py ● This command: ○ fab pick_settings:layer=prd ● Results in: ○ from settings.prd import * ● Stackable settings scale ○ Imagine (white) labeling Django settings (3/4)
  • 24. Django settings (4/4) __init__.pysettings/ dev.py tst.py acc.py prd.py base.py core.py
  • 25. Django settings (5/4) Database passwords in version control? from .base import * read_pgpass('app-mysite-prd')
  • 27. ● Scrum, RUP, etc. ○ Any iterative methodology will do ● Basicly: ○ Have periodic deadlines/releases ■ Bi-weekly ○ Deliver each iteration ■ To ACC, if OK, to PRD ○ Release early, release often (MVP) Iterative development
  • 28. ● Create a ticket for every change (RFC) ● Estimate the ticket ● Have discussion in ticket thread ● Create a code branch per ticket ○ Let git help you ● Deploy to a separate TST environment ○ (with separate database) (How to) use a ticket system
  • 30. ● On your test machine, let each ticket/branch have its own environment (with database) ● Test implementations individually, care for code merging later ● Multiple TST environments means multiple deployments ○ So not only three (= TST, ACC, PRD) Separate environments for TST (1/5)
  • 31. ● change_123/$ fab deploy ● Is shorthand for: ○ fab deploy:layer=tst,branch=change_123 Separate environments for TST (2/5)
  • 32. ● Isn’t setting up separate webserver(s), database(s), etc. causing a lot of overhead? Separate environments for TST (3/5)
  • 33. ● Computer says NO ○ If you do it the right way Separate environments for TST (4/5)
  • 34. ● Keep your (webserver) configuration files in version control ○ Use e.g., Django templates to construct environment specific files ● Keep your database scripts in version control ○ To copy a new DB from a production fixture ○ To install a new DB from scratch with fixtures ○ Or both! Separate environments for TST (5/5)
  • 36. ● Have separate deployment settings per layer: ○ use_https ○ path_to_certificate ○ sitename ○ deploy_user_at_host ○ dir_to_deploy_to ○ ... Deployment settings (1/4)
  • 38. ● Use the Django template engine to construct configuration files on deployment: {% if use_https %} server { listen 80; server_name {{ sitename }}; rewrite ^(.*) https://$server_name$request_uri?; } ... Deployment settings (3/4)
  • 39. ● Symlink the generated configuration files from the user homedir into the place they’re needed ● E.g. ○ ln -s ~/current/etc/nginx.conf /etc/nginx/sites-enabled/SITENAME.conf ○ service nginx reload Deployment settings (4/4)
  • 40. ● Create a tag for each PRD release ● Switch to that tag on deploy to PRD ○ For easy rollback ■ Switch to previous tag to rollback ● Run migration scripts after switch ○ Watch out for backwards incompatible changes! Use Git tagging
  • 41. ● When using Pip ○ pip freeze > frozen.txt ● Add to version control! ● pip install -r frozen.txt Freeze dependencies
  • 43. ● Use a VCS ● Have separate DTAP layers ● Script and store ● Work with RFCs ● Make everything repeatable ○ By your colleague Conclusion(s)
  • 44. ● github.com/ ○ Goldmund-Wyldebeast-Wunderliebe/ ■ templateproject ■ puppet-appie References
  • 45. Thank you! Job Ganzevoort, Douwe van der Meij Goldmund, Wyldebeast & Wunderliebe { ganzevoort, vandermeij } @gw20e.com