atmosphere 2014

89
Holy shit the Polish know how to drink. I hope nobody can tell that I'm still drunk from last night By Jamie Winsor

Upload: jamie-winsor

Post on 06-May-2015

925 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Atmosphere 2014

Holy shit the Polish know how to drink. I hope nobody can tell that I'm still drunk from last nightBy Jamie Winsor

Page 2: Atmosphere 2014
Page 3: Atmosphere 2014

Berkshelf Core Team» Jamie Winsor <[email protected]>

» Seth Vargo <[email protected]>

» Michael Ivey <[email protected]>

Page 4: Atmosphere 2014

berkshelfChef Cookbook manager and dependency resolver

» Retrieve a cookbooks dependencies

» Package cookbooks and their dependencies

» Author new cookbooks

Page 5: Atmosphere 2014

» League of Legends

» Guild Wars 2

» TERA

» Lord of The Rings Online

» Dungeons and Dragons Online

» Asheron's Call

Page 6: Atmosphere 2014
Page 7: Atmosphere 2014

"Deploy Windows"

Page 8: Atmosphere 2014

Risk Mitigation

Page 9: Atmosphere 2014

Introducing change into a system is a synonym for introducing risk

Page 10: Atmosphere 2014

Not deploying is a risk, too

Page 11: Atmosphere 2014

Q. What?A. Graphing the risk of multiple changes over time isn't linear

Page 12: Atmosphere 2014

Risk is exponentially greaterirb> changes = ChangeSet.newirb> changes.add Change.newirb> changes.risk_level=> 1irb> 5.times doirb> changes.add Change.newirb> endirb> changes.risk_level=> 46656

Risk Level: 6 ^ 6

Page 13: Atmosphere 2014

Not deploying at 5pm isn't Robbing peter to pay paul

Page 14: Atmosphere 2014

Not deploying at 5PM is:1.Killing Peter

a. Framing it as a suicideb. Making his wife your wifec. Stealing his entire family inheritenced. Telling his children you're their new dade. Defecating on his grave

To pay Paul

Page 15: Atmosphere 2014

When should we deploy?

Page 16: Atmosphere 2014
Page 17: Atmosphere 2014

Yeah, I'm gonna release it at 5PM on a Friday.

Page 18: Atmosphere 2014

Deploy WindowsA clear indicator that your release process is broken

Page 19: Atmosphere 2014

What about the risk?That's why we have deploy windows

Page 20: Atmosphere 2014

They exist because

Deployment was an afterthoughtAnd it's within your power to control deployment times to reduce risk

Page 21: Atmosphere 2014

That software doesn't even want to be deployed

Page 22: Atmosphere 2014

Just Deploy Already

Page 23: Atmosphere 2014

How do we reduce riskwhile still allowing for change

Page 24: Atmosphere 2014

Continuous Delivery & DevopsTo the rescue

Page 25: Atmosphere 2014

“Just rub some DevOps on it.”Joshua Timberman

Page 26: Atmosphere 2014

DevOps is a software development pattern

Page 27: Atmosphere 2014

DevOps is not» A position

» A team

» A department

» Or an organization

Page 28: Atmosphere 2014

“Disruptive startup is hiring DevOps ninjas”LinkedIn Spammer

Page 29: Atmosphere 2014
Page 30: Atmosphere 2014

You can't buy a DevOps tool andYou can't buy a continuous delivery tool

Page 31: Atmosphere 2014

Software doesn't solve problems. People do.

Page 32: Atmosphere 2014

“If you put the right people in the right room they'll solve the problem the right way”Jeff Hackert

Page 33: Atmosphere 2014

Coming Together

Page 34: Atmosphere 2014

You will need to change your development and release process

Page 35: Atmosphere 2014

Adopting devops isMUCH EASIERon new projects

Page 36: Atmosphere 2014

Start smallYour first program is typically "Hello, World!"

Page 37: Atmosphere 2014

Automate and testeverything

Page 38: Atmosphere 2014

Version, package, and releaseEVERYTHING

Page 39: Atmosphere 2014

Let's build something

Page 40: Atmosphere 2014

Application Checklist» Source code

» Build tasks

» Release tasks

» Cookbook

Page 41: Atmosphere 2014

Resulting in1.Software Artifact (app.tar.gz)

2.Cookbook Artifact (cookbooks.tar.gz)

3.Installation | Upgrade | Configuration Docs

Page 42: Atmosphere 2014

If you're a developerGive these three things to your Operators for every release.

Page 43: Atmosphere 2014

Elixir

Page 44: Atmosphere 2014
Page 45: Atmosphere 2014

Generate Your Project$ mix new highfive

Page 46: Atmosphere 2014

Add to source control$ cd highfive$ git init .$ git remote add origin [email protected]:reset/highfive.git

Page 47: Atmosphere 2014

Generate Your application's Cookbook$ berks cookbook highfive ./cookbook --pattern environment --skip-git

Page 48: Atmosphere 2014

Make deployment part of your build process

Page 49: Atmosphere 2014

Cookbook And Application Share Version$ cat cookbook/metadata.rb

name "highfive"maintainer "Jamie Winsor"maintainer_email "[email protected]"license "All rights reserved"description "Installs/Configures highfive"long_description "Installs/Configures highfive"version File.read(File.expand_path("../../VERSION", __FILE__))

Page 50: Atmosphere 2014

$ cat cookbook/attributes/default.rb

## Cookbook Name:: highfive# Attribute:: default#

default[:highfive][:release] = Highfive::Chef.cookbook_version(run_context)}

Page 51: Atmosphere 2014

$ cat cookbook/libraries/highfive.rb

## Cookbook Name:: highfive# Libraries:: highfive#

module Highfive module Chef class << self # Returns the version of the loaded highfive cookbook # # @param [Chef::RunContext] context # # @return [String] def cookbook_version(context) context.cookbook_collection["highfive"].version end end endend

Page 52: Atmosphere 2014

Environment Cookbook» Nearly identical to an Application Cookbook

» Has it's Berksfile.lock committed into version control

Page 53: Atmosphere 2014

Build Tasks» Version bump

$ mix version.bump patch

» Compile$ mix compile

» Test$ mix test

Page 54: Atmosphere 2014

Version BumpingGenerates a VERSION file at the root of the project

$ cat VERSION1.0.0

Page 55: Atmosphere 2014

How do we get our compiled software in our vm?

Page 56: Atmosphere 2014

Build and package release» OTP Release assemble

$ mix release.assemble

» Package$ mix package$ ls pkghighfive-osx.tar.gz

Page 57: Atmosphere 2014

We need to assemble a release for the os we're deploying to

Page 58: Atmosphere 2014

Build a Build Server

Page 59: Atmosphere 2014

Build Server Recipe$ cat cookbook/recipe/build_server.rb

include_recipe "highfive::_common"include_recipe "build-essential::default"include_recipe "elixir::default"

Page 60: Atmosphere 2014

Edit metadata.rb$ cat cookbook/metadata.rb

name "highfive"maintainer "Jamie Winsor"maintainer_email "[email protected]"license "All rights reserved"description "Installs/Configures highfive"long_description "Installs/Configures highfive"version "0.1.0"

supports "ubuntu"

depends "build-essential", "~> 2.0"depends "elixir", "~> 0.5"

Page 61: Atmosphere 2014

Vagrant BuilderOn-demand virtualized build server

Page 62: Atmosphere 2014

Vagrant.configure("2") do |config| # ... additional configuration ...

config.vm.synced_folder File.dirname(__FILE__), "/builder" config.vm.provision :chef_solo do |chef| chef.run_list = [ "recipe[highfive::build_server]" ] end

config.vm.provision :shell, inline: <<-SCRIPTexport PATH=/usr/local/lib/elixir/bin::$PATHexport ELIXIR_EBIN=/usr/local/lib/elixir/lib/elixir/ebinexport MIX_ENV=prodmix clean --allmix version.bump patchmix deps.getmix compilemix release.assemblemix package SCRIPTend

Page 63: Atmosphere 2014

Build it (from our host machine)$ vagrant up --provision.... provisioning ...$ ls pkghighfive-linux-x86-tar.gz

Page 64: Atmosphere 2014

deploying our artifact

Page 65: Atmosphere 2014

Create app.rb recipe

node.set[:'build-essential'][:compile_time] = trueinclude_recipe "libarchive::default"include_recipe "runit"

libarchive_file "highfive-linux-x86.tar.gz" do path "/pkg" extract_to "/opt/highfive" owner "highfive" group "highfive"

action :extract notifies :restart, "runit_service[highfive]" only_if { ::File.exist?(asset.asset_path) }end

runit_service "highfive"

Page 66: Atmosphere 2014

Update Cookbook Dependenciesdepends "build-essential", "~> 2.0"depends "elixir", "~> 0.5"depends "libarchive"

Page 67: Atmosphere 2014

Edit .kitchen.yml$ cat cookbook/.kitchen.yml

driver: name: vagrant synced_folders: - ["<%= File.expand_path("../../pkg", __FILE__) %>", "/pkg"]

provisioner: name: chef_solo

platforms: - name: ubuntu-12.04

suites: - name: default run_list: - recipe[highfive::default] attributes:

Page 68: Atmosphere 2014

Kitchen Converge$ cd cookbook$ kitchen converge-----> Starting Kitchen (v1.2.2.dev)...-----> Kitchen is finished. (14m6.31s)

Page 69: Atmosphere 2014

Generating the Cookbook artifact$ berks package pkg/cookbooks.tar.gz -b cookbook/BerksfileCookbook(s) packaged to pkg/cookbooks.tar.gz

Page 70: Atmosphere 2014

The archive contains

» The Berksfile.lock from resolution

» A cookbooks directory containing each cookbook found in the Berksfile.lock

Page 71: Atmosphere 2014

Put these archives in an artifact server

Page 72: Atmosphere 2014

Artifact Servers» Github | Github Enterprise

» Sonatype's Nexus

» Artifactory

» Basic Auth HTTP Server (sadface)(https://artifacts.myorg.com/myapp/1.2.3/myapp.tar.gz)

Page 73: Atmosphere 2014

Github Releases and Release Assets

Page 74: Atmosphere 2014
Page 75: Atmosphere 2014

GitHub Deploy

asset_path = "/pkg"

unless node[:highfive][:_local_deploy] asset = github_asset "berkshelf-api.tar.gz" do repo "berkshelf/berkshelf-api" release "v1.2.1" end

asset_path = asset.pathend

libarchive_file "highfive-linux-x86.tar.gz" do path asset_path extract_to "/opt/highfive" owner "highfive" group "highfive"

action :extract notifies :restart, "runit_service[highfive]" only_if { ::File.exist?(asset.asset_path) }end

Page 76: Atmosphere 2014

Update .kitchen.ymldriver: name: vagrant synced_folders: - ["<%= File.expand_path("../../pkg", __FILE__) %>", "/pkg"]

provisioner: name: chef_solo

platforms: - name: ubuntu-12.04

suites: - name: default run_list: - recipe[highfive::default] attributes: { highfive: { _local_deploy: true } }

Page 77: Atmosphere 2014

Release artifacts allow us to» Build a new environment with a specific version

» Upgrade pre-existing environments

» Promote through logical environments(Dev, Stage, Production)

Page 78: Atmosphere 2014

Deploy It

Page 79: Atmosphere 2014

Create Environment$ knife environment create highfive-dev

Page 80: Atmosphere 2014

Bootstrap A Node$ knife ec2 server create -I ami-0eb2d83e -E highfive-dev

Page 81: Atmosphere 2014

BerkflowA Cookbook-Centric Deployment workflow tool

Page 82: Atmosphere 2014

Install Berkflow with Chef-DK$ chef gem install berkflow$ export PATH=/opt/chefdk/embedded/bin:$PATH

$ which blo/opt/chefdk/embedded/bin/blo

Page 83: Atmosphere 2014

"Install" the cookbook artifact into your Chef Server$ blo install https://github.com/reset/highfive/releases/download/v1.0.0/cookbooks.tar.gz

Page 84: Atmosphere 2014

"Upgrading" a Chef Environment$ blo upgrade highfive-dev highfive 1.2.1

Or upgrade to latest

$ blo upgrade highfive-dev highfive latest

Page 85: Atmosphere 2014

One Button Upgrade

Page 86: Atmosphere 2014

Be a catalyst for changeBut don't expect a parade. It's not coming.

Page 87: Atmosphere 2014

Even if it doesYou won't have your own float

Page 88: Atmosphere 2014

Wanna Make Games?http://undeadlabs.com/jobs/

» Game Programmer

» Game Producer

» Game Animator

» Game Designer

Page 89: Atmosphere 2014

Jamie [email protected]/reset