introduction to devops

60
Infrastructure as Code Infrastructure As Code Infrastructure as Code Introduction to DevOps and Infrastructure as Code Rolands Mekšs A/S 4finance

Upload: neueda

Post on 10-May-2015

1.285 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Introduction to DevOps

Infrastructure as Code

Infrastructure As CodeInfrastructure as Code

Introduction to DevOps and Infrastructure as Code

Rolands Mekšs

A/S 4finance

Page 2: Introduction to DevOps

< 80s Mainframes

Infrastructure Complexity

Page 3: Introduction to DevOps

80s - 90s ClientServer

< 80s Mainframes

Infrastructure Complexity

Page 4: Introduction to DevOps

80s - 90s Client Server

< 80s Mainframes

90sMulti-Tier apps

Infrastructure Complexity

Page 5: Introduction to DevOps

2000sData Centers

90sMulti-Tier apps

80s - 90s Client Server

< 80s Mainframes

Infrastructure Complexity

Page 6: Introduction to DevOps

Client Data CenterCloud Provider

Internet

Infrastructure Complexity in 2010s

Page 7: Introduction to DevOps

19901991

19921993

19941995

19961997

19981999

20002001

20022003

20042005

20062007

20082009

20102011

20122013

20142015

Virtual Nodes

Physical Hardware

Infrastructure Complexity

Page 8: Introduction to DevOps

Concept of physical hardware blurs

Page 9: Introduction to DevOps

Everything as a Service

Page 10: Introduction to DevOps
Page 11: Introduction to DevOps

Soon will hit 100 production server count (DB/Application/Web Proxies)

Not counting testing / staging / UAT / DR environments

Page 12: Introduction to DevOps

Agile development

Quick reaction to requirements and change

Short development sprints

Develop small, incremental releases

Continuous integration

Continious delivery of working software

Page 13: Introduction to DevOps

Agile software delivery

Develop

Dep

loy

Develop

Dep

loy

Time

Risk

Risk

Page 14: Introduction to DevOps

Continuous delivery

Develop

Time

Risk

Risk

Risk

Risk

Develop

Develop

Develop

Dep

loy

Dep

loy

Dep

loy

Dep

loy

Challenging if not impossible without serious CI, testing and automated deployments

Page 15: Introduction to DevOps

Separate teams

Development Operations

Page 16: Introduction to DevOps

Separate teams

Development Operations

We want change

Page 17: Introduction to DevOps

Separate teams, distinct goals

Development Operations

We want change The answer is NO

Page 18: Introduction to DevOps

Wall of confusion

Development Operations

We want change The answer is NO

Page 19: Introduction to DevOps

Merge of concerns

DevOps

Page 20: Introduction to DevOps

What is DevOps

More like an idea or collaborative culture/philosophy between technical teams

Often stated as «Agile for Operations»

Unified processes, unified tools for faster end-to-end delivery of quality software

Automate all the things!

Not a job description, same way as there is no such job «Agile Developer»

It’s just a way of work

Page 21: Introduction to DevOps

DevOps team in 4finance

Provide teams with processes and tools for better day to day project activities

Automate environment creation

Enable automated deployment process

Enable freely available performance monitoring and log viewing

Provide support in infrastrucure related questions

Enable DevOps

Page 22: Introduction to DevOps

Infrastructure as code

Page 23: Introduction to DevOps

How do you provision new server?

Adhoc actions – hack while it works

Page 24: Introduction to DevOps

SNOWFLAKES ARE SPECIAL, SERVERS ARE NOT

Adhoc actions – hack while it works

How do you provision new server?

Page 25: Introduction to DevOps

How do you provision new server?

Follow some documented instructions

Page 26: Introduction to DevOps

Doing changes to servers manually involves

PEOPLE

Page 27: Introduction to DevOps

Doing changes to servers manually involves

PEOPLE

Terrible of doing things repeatedly

Page 28: Introduction to DevOps

Doing changes to servers manually involves

PEOPLE

Terrible of doing things repeatedly

Page 29: Introduction to DevOps

More than 80% of all mission-critical IT service outages are

due to PEOPLE and process errors

Page 30: Introduction to DevOps

How do you provision new server?

Use self written shell scripts

+ Some sort of automation+ Version control possible+ Works fine if you have 5 or so servers

Page 31: Introduction to DevOps

How do you provision new server?

Use self written shell scripts

+ Some sort of automation+ Version control possible+ Works fine if you have 5 or so servers

- Does not handle change during server lifecycle

Page 32: Introduction to DevOps

True story

Simple change as timezone setting

Options:

• Log in each affected server and change manually• SSH for loop could do the trick

Page 33: Introduction to DevOps

True story

Simple change as timezone setting

Options:

• Log in each affected server and change manually• SSH for loop could do the trick

Configuration drift!

Page 34: Introduction to DevOps

There got to be better way

Page 35: Introduction to DevOps

We know how to handle change in software development

Code and configuration is in verison control system

Unit and integration tests

Safe acceptance testing in test/stage environments

Code review

Page 36: Introduction to DevOps

Infrastructure should be treated like a code

Packages installed, versionsServer and application configuration (such as timezone settings)Relationships with other servers and services

Page 37: Introduction to DevOps

Infrastructure should be treated like a code

Packages installed, versionsServer and application configuration (such as timezone settings)Relationships with other servers and services

We want

Automated , repeatable operationsPredictable outcomeRemove manual, error prone stepsManage change during server lifecycleAbility to test outcomes

Page 38: Introduction to DevOps

"Enable the reconstruction of the business from nothing but a source code repository, an application data backup, and bare metal resources"

Adam Jacob

Infrastructure as Code

Page 39: Introduction to DevOps

Netflix Chaos Monkey

Page 40: Introduction to DevOps

Configuration management

Declarative specifications or policies

Setting the Policy

Executing the policy

Auditing the policy

Report the policy

Page 41: Introduction to DevOps

Configuration management systems

Page 42: Introduction to DevOps

How Puppet Works

Manage infrastructure throughout its lifecycle

Page 43: Introduction to DevOps

Puppet Resources

Resources – Puppet building blocks

user { 'dave': ensure => present, uid => '507', gid => 'admin', shell => '/bin/zsh', home => '/home/dave', }

Page 44: Introduction to DevOps

Resources – Puppet building blocks

package { 'apache2':ensure=>'installed'

}

Page 45: Introduction to DevOps

Resources – Puppet building blocks

package { 'apache2':ensure=>'installed'

}service { 'apache2': ensure=>'running'}

Page 46: Introduction to DevOps

Resources – Puppet building blocks

package { 'apache2':ensure=>'installed'

}service { 'apache2': ensure=>'running'}

cron { cleanup: command=>'/test/cleanup.sh', user=>test, hour=>5, minute=>0}

Page 47: Introduction to DevOps

Resources – Puppet building blocks

package { 'apache2':ensure=>'installed'

}service { 'apache2': ensure=>'running'}

cron { cleanup: command=>'/test/cleanup.sh', user=>test, hour=>5, minute=>0}

file { ‘/tmp/helloPuppet': content=>‘Hello!'}

Page 48: Introduction to DevOps

package { "openssh": ensure => present, }

service { "sshd": ensure => running, hasstatus => true, hasrestart => true, enable => true, require => Package["openssh"],}

Puppet manifests

Page 49: Introduction to DevOps

Puppet templatespackage { "openssh": ensure => present, }

service { "sshd": ensure => running, hasstatus => true, hasrestart => true, enable => true, require => Package["openssh"],}

$listen_port=2222

file { "/etc/ssh/sshd_config": path => "/etc/ssh/sshd_config", owner => root, group => root, mode => 444, content => teplate("sshdconf/sshd_config.erb"), notify => Service[sshd],}

Port <%= listen_port%>Protocol 2SyslogFacility AUTHPRIVPermitRootLogin noPasswordAuthentication noChallengeResponseAuthentication noGSSAPIAuthentication yesGSSAPICleanupCredentials yesUsePAM yesX11Forwarding yesBanner /etc/motd

sshd_config.erb

Page 50: Introduction to DevOps

Reusable Configuration Modules

Page 51: Introduction to DevOps

How Puppet Enforces Desired State

Page 52: Introduction to DevOps

node base { include openssh include mymanifest.pp }

node { ‘my.prod.server.com’ inherits base $apacheversion = "2.0.33" package { "apache2": ensure => $apacheversion, }}

Node definitions in Puppet

Page 53: Introduction to DevOps

Development practices applied to infrastructure

Version control & source code management

IDEs, editors, refactoring tools

Environments

Self-documentation

Testing

Page 54: Introduction to DevOps

BDD with Puppet

Page 55: Introduction to DevOps

Puppet development with Vagrant

A tool for building virtualized environments in your PC

Actually works as command line wrapper for VirutalBox

Shared filesystem between host and guest

Allows to spin up virtual machine with preinstalled Puppet/Chef

Page 56: Introduction to DevOps
Page 57: Introduction to DevOps

$ vagrant box add lucid32 http://files.vagrantup.com

Vagrant::Config.run do |config| # Setup the box config.vm.box = "lucid32"

config.vm.provision :puppet do |puppet| puppet.module_path = "puppet/modules"

puppet.manifests_path = "puppet/manifests" end

end

Vagrant – boxes and environments

Page 58: Introduction to DevOps

Vagrant – boxes and environments

$ vagrant up

$ vagrant provision

$ vagrant ssh

$ vagrant destroy

Page 59: Introduction to DevOps

Modeling environment systems with Vagrant

Page 60: Introduction to DevOps

Q&A