60
Software Development Life Cycle A DevOps Approach Akshaya Mahapatra

Automating Software Development Life Cycle - A DevOps Approach

Embed Size (px)

Citation preview

Page 1: Automating Software Development Life Cycle - A DevOps Approach

Software Development Life Cycle

A DevOps Approach

Akshaya Mahapatra

Page 2: Automating Software Development Life Cycle - A DevOps Approach

Akshaya Mahapatra Software Engineer @ VCE (Virtual

Computing Environment) Experienced in

◦ Java/J2EE◦ VMware products

vSphere, vCloud◦ Puppet

Developing solutions for application deployment on cloud

About me

Page 3: Automating Software Development Life Cycle - A DevOps Approach

3

Page 4: Automating Software Development Life Cycle - A DevOps Approach

Why DevOps? Why now? Stages in SDLC

◦Check-in◦Build and Test◦Infrastructure setup◦Release◦Monitoring and scaling

A typical use case Q & A

Agenda

Page 5: Automating Software Development Life Cycle - A DevOps Approach

Dev and Ops have different goals.◦Features vs SLA

Skills are different.◦Dev team lacks infrastructure knowledge◦Ops team unaware of complexity of

development. Slow feedback loop

◦Business -> Ops ->Dev

Dev Ops - Two Teams

Page 6: Automating Software Development Life Cycle - A DevOps Approach

An idea, practice or culture that brings Dev, Ops and Business together.

How?◦Repeatable processes◦End-to-end automation.◦Continuous monitoring

What is DevOps?

Page 7: Automating Software Development Life Cycle - A DevOps Approach

Virtualization and Cloud Computing◦Programmable Infrastructure◦Just-in-time Provisioning Network Compute Storage

Agile software development◦Speed is critical.

DevOps – Why now?

Page 8: Automating Software Development Life Cycle - A DevOps Approach

Application Needs◦Nodes can fail◦No “manual” configuration◦Heterogeneous Execution environments

Advancement of technology◦Puppet eco-system

DevOps – Why now?

Page 9: Automating Software Development Life Cycle - A DevOps Approach

Software Development Life Cycle

Continuous Integration

Continuous Deploymen

t

Check-in

Continuous Monitoring

Scale Out

Page 10: Automating Software Development Life Cycle - A DevOps Approach

Stages in SDLC - Packaging

Check-in

Version Control Continuous

Integration System

Build Test

Packaged Application

warearAppliancevApp

Page 11: Automating Software Development Life Cycle - A DevOps Approach

Stages in SDLC – Prepare Infra

Packaged Application

Infra Setup

LB APP

DB

vSphere

VM Templates

IP Assignment

APP

Page 12: Automating Software Development Life Cycle - A DevOps Approach

Stages in SDLC - Deployment

Configuration Management

MonitoringTools

Scale Out

MonitoringLB APP

DB

vSphere

Config

APP

Page 13: Automating Software Development Life Cycle - A DevOps Approach

Apache License Initial Release – October 2000Central Repository.

◦Better access controlFast branching and tagging.

Version Control - Subversion

Page 14: Automating Software Development Life Cycle - A DevOps Approach

Version Control - GIT

De-centralized. Inherent redundancy.

Local repository. Efficient use of space.Offline Use

Page 15: Automating Software Development Life Cycle - A DevOps Approach

SVN vs GIT

SVN GIT

svn checkout.svn addsvn commit.svn commitsvn diffsvn updateonline

git clonegit addgit commitgit pushgit diffgit pullonline/offline

Page 16: Automating Software Development Life Cycle - A DevOps Approach

Version Control – Best Practice

All “stable” code goes to trunk.Major development in branches.

◦Merge to trunk when stable.Snapshots for release are tagged.

Page 17: Automating Software Development Life Cycle - A DevOps Approach

Simple, Java basedXML based configurationDependency Management

◦Project ->TargetEase of logging and debugging. Integration with major IDEs.

Build – Apache Ant

Page 18: Automating Software Development Life Cycle - A DevOps Approach

Beyond “typical” build◦Reporting◦Collaboration.◦Project life cycle.

Automated dependency management

Sensible default configurationBetter suited for complex projects

Build - Maven

Page 19: Automating Software Development Life Cycle - A DevOps Approach

settings.xml◦ ${user.home}/.m2/settings.xml

<proxies> <proxy> <host>172.30.100.25</host> <port>8080</port> </proxy> </proxies><repositories> <repository> <id>central</id> </repository></repositories>

Maven

Page 20: Automating Software Development Life Cycle - A DevOps Approach

Dependency in pom.xml<dependencies> <dependency>

<groupId>log4j</groupId><artifactId>log4j</artifactId>

<version>${log4j.version}</version> </dependency></dependencies>

Maven

Page 21: Automating Software Development Life Cycle - A DevOps Approach

Distribution Management in pom.xml<distributionManagement><repository> <id>devops-snapshot</id> <name>DevOps Repository</name> <url>http://codecamp.com/repo/devops</url></repository> </distributionManagement>

Maven

Page 22: Automating Software Development Life Cycle - A DevOps Approach

Open source Continuous Integration server

http://jenkins-ci.org/◦Written in Java◦Performs jobs◦Numerous plugins◦Wide support◦Post build actions

Jenkins

Page 23: Automating Software Development Life Cycle - A DevOps Approach

Continuous Integration -Jenkins

Code Repository(GIT/SVN)

MavenAnt

JunitTestNG

Selenium

Check-in Workspace

Target Server

Jenkins(Hudson) Build

Update

Test3

1

2

4 Packaging

PackagedApplication

Page 24: Automating Software Development Life Cycle - A DevOps Approach

Infrastructure Setup

Clone VM

ConfigureVM

Blue PrintsTemplates

Infra Setup

3

1

2

Power On

BuildSuccessful

4

VM

VM

VM

VM

vSphere

Page 25: Automating Software Development Life Cycle - A DevOps Approach

Cloning Specification:◦Networking Info◦DNS◦Domain

Host/Cluster Information OS Customization

◦Sysprep in windows◦IP configuration in Linux

Infrastructure Setup

Page 26: Automating Software Development Life Cycle - A DevOps Approach

Supported by VMware and up-to-date Clone VM:

◦ Create Clone Spec: Set host name, network info, data store, host resources, folder etc.

◦ Task task = vm.cloneVM_Task(vcFolder, vmName, cloneSpec);

◦ if (task.waitForTask() == Task.SUCCESS) return true; else return false;

VMware API - VIJava

Page 27: Automating Software Development Life Cycle - A DevOps Approach

Supported by VMware and up-to-date Clone VM:

◦ Add-PSSnapin VMware.VimAutomation.Core◦ Connect-VIServer -Server $VC◦ New-VM -Name $cloneName -VM $sourceVM -

ResourcePool $respool -Datastore $datastore

VMware API - PowerCLI

Page 28: Automating Software Development Life Cycle - A DevOps Approach

PowershellNew-NetIPAddress –InterfaceAlias “Local Area Connection” –IPv4Address “192.168.1.100” –PrefixLength 24 -DefaultGateway 192.168.1.1

Set-DnsClientServerAddress -InterfaceAlias “Local Area Connection” -ServerAddresses 192.168.1.254, 192.168.1.253

IP Address- Windows

Page 29: Automating Software Development Life Cycle - A DevOps Approach

/etc/sysconfig/networkNETWORKING=yesHOSTNAME=codecamp.devops.comGATEWAY=192.168.1.1

/etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth0BOOTPROTO=staticBROADCAST=192.168.1.255IPADDR=192.168.1.10

/etc/resolv.confsearch devops.com nameserver 192.168.1.2

IP Address- Redhat

Page 30: Automating Software Development Life Cycle - A DevOps Approach

Install Applications on Templates◦ Red hat with Apache◦ Windows with SQL Server◦ Cent OS with Tomcat◦ Red hat with ActiveMQ

Create Virtual Machines from templates.◦ Applications already installed.

Configure virtual machines.

VM Templates – Option 1

Page 31: Automating Software Development Life Cycle - A DevOps Approach

Templates with Base OS◦ Red hat◦ Windows◦ Cent OS

Create Virtual Machines from templates. Install required components on virtual

machines on demand using Puppet.

Better alternative..

Page 32: Automating Software Development Life Cycle - A DevOps Approach

Open source Configuration Management

http://puppetlabs.com/◦Written in Ruby◦Infrastructure as code.◦Client Server system.◦Gaining lot of traction◦Simple domain specific language (DSL)

Puppet

Page 33: Automating Software Development Life Cycle - A DevOps Approach

Puppet

Catalog

PuppetMaster

Node(Puppet Agent)

Node(Puppet Agent)

Facts

Facts

CatalogConfigRepository

Client Server Architecture

Page 34: Automating Software Development Life Cycle - A DevOps Approach

Puppet – DSL - Package

package { "sudo": ensure => "installed"

}

package { 'mysql': ensure => installed, source => ‘C:/mysql-winx64.msi',

}

Page 35: Automating Software Development Life Cycle - A DevOps Approach

Puppet – DSL - User

User { “codecamp":ensure => "present",uid => "1001",gid => "1001",comment => “Code Camp Developer",home => "/home/codecamp ",shell => "/bin/bash"

}

Page 36: Automating Software Development Life Cycle - A DevOps Approach

Puppet – DSL - File

file { "C:/apache": ensure => directory, recurse => true, source =>puppet:///modules/apache",}

Page 37: Automating Software Development Life Cycle - A DevOps Approach

Puppet – DSL - Exec

exec { "Install Apache" : command => 'install_apache.bat', require => File["C:/apache"'], path => "C:/apache/bin", }

Page 38: Automating Software Development Life Cycle - A DevOps Approach

Puppet – DSL - Service

service { "Apache2.4": ensure => running, require => Exec['Install Apache'], enable => true, }

Page 39: Automating Software Development Life Cycle - A DevOps Approach

Puppet – DSL - Class

Class apache { File { "C:/apache": }

exec { "Install Apache" : }

service { "Apache2.4": }}

Page 40: Automating Software Development Life Cycle - A DevOps Approach

Puppet – DSL - nodes.pp

node apache1 { include apache }

node tomcat1{ include tomcat}

Page 41: Automating Software Development Life Cycle - A DevOps Approach

Get information on all the nodes: Host Name, domain, IP Address facter -p

Puppet manifests can access them as global variable

Ex: “$::hostname” Customizable.

Facter – A complement

Page 42: Automating Software Development Life Cycle - A DevOps Approach

Puppet – DSL

class ntp { case $::operatingsystem {

centos, redhat: { $service_name = 'ntpd'}

debian, ubuntu: { $service_name = 'ntp' }

}…………}

Page 43: Automating Software Development Life Cycle - A DevOps Approach

Most of application deployment need Orchestration support◦Orchestration is “cumbersome” with

base puppet. Changes need to wait until next “agent” run..

Puppet – Orchestration

Page 44: Automating Software Development Life Cycle - A DevOps Approach

Open source Asynchronous Orchestration

◦Can manage puppet runs. Scalable

◦Parallel execution

Marionete Collective(mCollective)

Page 45: Automating Software Development Life Cycle - A DevOps Approach

Puppet with mCollective

PuppetMaster

Node(Puppet

and mCollective

Agent)

Catalog

mCollective Client

Node(Puppet and mCollective

Agent)

ActiveMQCommands Commands

Catalog

Page 46: Automating Software Development Life Cycle - A DevOps Approach

Find out reachable nodes◦mco ping

Find service status◦mco rpc service start service=httpd

Run puppet agent once on a node◦mco puppet runonce –W

hostname=apache1

mCollective Commands

Page 47: Automating Software Development Life Cycle - A DevOps Approach

Environments◦Development◦Test◦Production

Defined as a config parameter.Puppet Master can handle multiple environments.

Puppet Environment

Page 48: Automating Software Development Life Cycle - A DevOps Approach

Puppet Environment

PuppetMaster

Test

Development

Production

svn/dev

svn/test

/svn/prod

Page 49: Automating Software Development Life Cycle - A DevOps Approach

Managing what nodes get what classes..◦Nodes.pp grows out of control when you have thousands of nodes.

Solution: ◦External Node Classifier

Puppet – Large Deployments

Page 50: Automating Software Development Life Cycle - A DevOps Approach

Key/Value pair lookup toolProvides environment hierarchy

◦Default◦Node Name◦Environment◦Domain

Hiera (External Node Classifier)

Page 51: Automating Software Development Life Cycle - A DevOps Approach

Puppet and Hiera

PuppetMaster

Node(Puppet Agent)

Hiera

External Node Classifier

FactsCatalog(Classes)

Facts

Catalog(Classes)

Page 52: Automating Software Development Life Cycle - A DevOps Approach

Continuous Monitoring

VM

VM

VM

Hyperic

Infra Setup

VM

VMVM

PuppetMaster

Check Threshold

Page 53: Automating Software Development Life Cycle - A DevOps Approach

VMware Products◦Hyperic – OS/Infrastructure◦App Insight – Inside Application

Java Tools and APIs◦Sigar◦Jconsole

Monitoring

Page 54: Automating Software Development Life Cycle - A DevOps Approach

Use Case

Page 55: Automating Software Development Life Cycle - A DevOps Approach

A simple Web App

Web Server(Apache)

App Server

(Tomcat)

App Server

(Tomcat)

App Server

(Tomcat)

Page 56: Automating Software Development Life Cycle - A DevOps Approach

<application> <name>Puppet Demo</name>

<nodes><name>Tomcat Server</name><template>CentOS56 64bit</template><key>war_file</key><instances>3</instances>

</nodes><nodes>

<name>Apache Load Balancer</name><template>CentOS56 64bit</template>

</nodes></application>

App Blue Print

Page 57: Automating Software Development Life Cycle - A DevOps Approach

Clone templates to create virtual machines.◦One VM for apache Load Balancer◦Three VMs for Tomcat and App .war file.

Create Puppet Manifest or Configure ENC.◦Associate Puppet/Classes with node

names. Run Puppet Agent on Virtual Machines

◦In correct sequence.

Steps

Page 58: Automating Software Development Life Cycle - A DevOps Approach

Install Apache◦mco puppet -W hostname=apache1

runonce Install Tomcat

◦ mco puppet -W role=apserver runonce Configure Apache

◦mco puppet -W hostname=apache1 runonce

Steps

Page 59: Automating Software Development Life Cycle - A DevOps Approach

Puppet and Puppet Forge◦ puppetlabs.com◦ forge.puppetlabs.com/

VMware VIJava API◦ vijava.sourceforge.net/

Provisioning◦ github.com/puppetlabs/razor

More Info: