Who I am.
- Python charmer
- Git Lover
- PostgreSQL Fan
I build web products and love learning something new.
This talk is the result of my question how to make things better
Version controle matters!!
It keeps the history of the application.
Notes..
What about servers?
How do I version them? Unfortunately I cannot do:
git reset --hard <previous>
Boom! magic rollback!
Notes..
What is an application?
Is it just code?
Or, does it include all its components?
Notes..
This is a talk about shipping release.
Warning: There is no silver bullet for all cases.
What's a Good release?
- Self Contained
- Easy to rollback
- Fast to deploy
- Easy to upgrade (less legacy)
- Easy to duplicate
- Testable in parallel
Notes..
What's the cloud?
- Buzzword
- Flexible resources
- More resources on demande
- Pay for what you use
Notes..
What to ship then?
- Source Code
- Python package
- Distribution Package
- LXC
- Images
Notes..
Tools
- Python Wheels
- FPM
- Docker
- Packer
Use tools or contribute but don't reinvent the wheel ;)
Notes..
Python Wheels
PEP 427 - A wheel is a ZIP-format archive.
Example: Create Wheels
pip install wheel
pip wheel --wheel-dir=/local/wheels -r requirements.txt
pip wheel --wheel-dir=/local/wheels ./app
Example: Install Wheels
pip install --use-wheel --no-index --find-links=http://myfancyurl/
Downsides
- Not self-contained.
- Just code.
- Not easy to rollback.
- Portability.
Fundamental Principle:
“ IF FPM IS NOT HELPING YOU MAKE PACKAGES EASILY, THEN THERE IS A BUG IN FPM.”
Example: Create Package
fpm -s python -t deb ./app/setup.py
fpm -s dir -t deb app_folder_with_venv/
Upsides
- Easy to rollback.
- Make migration easier.
- Wrap your dependencies.
Downsides
- Not self-contained (enough).
- Just code.
- Platform dependant.
What about the big picture
Notes..
Application are more complex and not just code
they have dependencies!!
- Redis
- Postgres
- System Libs
Notes..
Configuration managment?
Notes..
I love sensible configuration managment
Notes..
But they are not easy to rollback
... even if you keep it in a VCS. It's not enough.
bug because of dependency or dependency of dependecy
Immutable servers
From
Credit: Martin Fowler blog post on Immutable Server
Immutable servers
To
Credit: Martin Fowler blog post on Immutable Server
Versionning Server State!
Notes..
LXC, made easy with Docker
Notes..
What's docker
Docker, the Linux Container Runtime, an application to pack, ship and run any application as a lightweight container
Notes..
What container matter
- Content Agnostic
- Hardware Agnostic
- Content isolation
- Automation
- Separation of duties
Notes..
Get Started
git clone https://github.com/dotcloud/docker.git
cd docker
vagrant up
vagrant ssh
sudo docker
Docker Awesomeness
- Versionning
- Push / Pull
- Remote/Private Registery
- Logs
- Diff
- REST API
Notes..
Downsides
- Kernel version
- Auto-scalling
Notes..
Images, made easy via Packer
packer.io
Notes..
What's packer
Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
Notes..
Simple JSON to describe 3 steps:
- Provisioning (shell, files, Salt, Chef)
- Build (AWS, DigitalOcean,...)
- Post-Process (Vagrant, Compress)
Notes..
Examples
{
"builders": [{
"type": "amazon-ebs",
"region": "us-east-1",
"source_ami": "ami-e50e888c",
"instance_type": "t1.micro",
"ssh_username": "ubuntu",
"ami_name": "packer-example {{timestamp}}"
}],
"provisioners":[
{
"type": "shell",
"inline": ["echo 'I can chain Provisioners'"]
},
{
"type": "salt-masterless",
"bootstrap_args": "git v0.16.0",
"local_state_tree": "path/to/states",
"local_pillar_roots": "path/to/pillar"
}]
}
Notes..
What to use where
There is no rules. They all can play well together (with a shoehorn)
Notes..
Wheels
private libs, dependencies, pur python apps
Notes..
FPM
Migration, datacenter, no VM
Notes..
Docker
Recent Kernel (or patched), datacenter, Cloud Provider
Notes..
Packer
Cloud provider, Private Cloud, Virtualized Datacenter: AWS, Digital Ocean.
Notes..
A Final Word
Have Fun and Pick your tools.