Continuous Deployment: Automate your Deploy Pipeline with Singularity

Post on 18-Nov-2014

399 views 0 download

description

Use Singularity, a mesos framework, to automate the deployment of microservices, scheduled jobs, workers and on-demand processes in mesos clusters.

Transcript of Continuous Deployment: Automate your Deploy Pipeline with Singularity

CONTINUOUSDEPLOYMENTWITHSINGULARITY

LargeScaleMission-CriticalServiceandJobDeployment

GregoryChomatas@gchomatas

PAASTEAMImplement&maintain:

thedeploy&buildtools

thePAASplatform(mesosclusters)

loadbalancertools

logginginfrastructure

Boston:WhitneySorenson,TomPetr,TimFinley

Dublin:GregoryChomatas,KieranManning

ANESSENTIALSINGULARITYEXP(1/Z)

HUBSPOTSINGULARITY

THEWAYTOMESOSSpeedwins->SpeedProductDevelopment

Increasechangerate->RemoveFriction+Reducesize,cost,riskofchange:

smallteams,hightrust,lowprocessfreedomandresponsibilityculture

microserviceslibs&crosscuttingAPIstosimplifycoding

automatedeploymentbytooling

SOMEFACTS&NUMBERS3-4personteams

severalmicro-services&jobsperteam(fulloperation)1ormoreservicesperdev

AllQAinMESOS/PRODmigrationongoingnow

400+deploys/day-843DeployableItems:(longrunningwithanAPI)

(longrunningnoAPI)(CRONschedule)

SOMEFACTS&NUMBERSQAEnvironment

pre-mesos:400small&mediumsizeservers(c1.xlarge)

post-mesos:20bigservers(c3.8xlarge)

WHYSINGULARITY

providebestpossibleuserexperiencefor100+HubSpotproductdevelopers

deployentireHubSpotplatformontoSingularity

WHYSINGULARITYearlyadopter(2012)/immatureframeworks

unifiedAPIforalldeployables

missioncritical/strategictool:priorityanddeliveryofbugfixes

featuresandintegrationstheoverallroadmap

havetheresourcestoimplement&maintainahighlycomplexpieceofsoftware

DEPLOYWITHHUBSPOTPAAS

SINGULARITYCOMPONENTS

SINGULARITYSCHEDULER

ADEPLOY-CENTRICRESTAPITO:

registerdeployableitemsexecutetheirdeploysviewsandboxfilesgetmetadata/historicaldata

SINGULARITYUI

SINGULARITYUI-DEPLOYABLEITEMLIST

SINGULARITYUI-DEPLOYABLEITEM

SINGULARITYUI-HISTORICALTASK

SINGULARITYSCHEDULER

HealthCheckingattheprocessandtheserviceendpointlevel

Automaticcool-downofrepeatedlyfailingservices

Loadbalancingofserviceinstances(LBAPI)

AutomaticRollbackoffaileddeploys

DecommissioningofSlaves&Racks

Emailstoserviceownersonfailures

SINGULARITYEXECUTORLogRotation

TaskSandboxCleanup

GracefulTaskKillingwithconfigurabletimeout

EnvironmentSetup

TaskRunnerScript

ADVANCEDSLAVESERVICESLogWatcher:Forward/StreamLogs

S3uploader:ArchivelogswithAWSS3Service

ExecutorCleanup:Cleanfailedexecutortasks

DEVELOPWITHSINGULARITYjava7guice

dropwizard(jersey,jackson,liquibase)

maven

backbonenodejsbrunch

ROADMAP/NEWFEATURESPhaseddeployment

Auto-scaling/resourceusagemonitoringandalerting

Enhancejobscheduler

SupportdeployofDockercontainers

OpensourceHubSpotDeployerandDeployRegistry

USEFULLINKS

http://getsingularity.com/https://github.com/HubSpot/Singularity

https://github.com/HubSpot/Singularity/blob/master/Docs/Singularity_API_Reference.md

https://github.com/HubSpot/Singularity/blob/master/Docs/Singularity_Local_Setup_For_Testing.md

https://mesosphere.io/resources/mesos-case-study-hubspot/

APPENDIX

DEPLOYCONFIGURATION

name:MDS_All_Item_Types_In_One_ConfigbuildName:MesosDeployIntegrationTestsProjecttype:procfile

owners:-user@hubspot.com

appRoot:/mesos-deploy-test-srv1/v1loadBalancers:-test

env:all:JOB_JAR:TestJob.jar

procfile:webService:cmd:java$JVM_DEFAULT_OPTS-jarTestService.jarserver$CONFIG_YAMLinstances:2cpus:2memory:1024numRetriesOnFailure:5scheduledJob:cmd:java$JVM_DEFAULT_OPTS-jar$JOB_JAR-testjobschedule:'*/3****'numRetriesOnFailure:5healthcheckIntervalSeconds:40healthcheckTimeoutSeconds:40worker:

KEYSINGULARITYABSTRACTIONS

SINGULARITYREQUESTOBJECT

{"id":"TestService","owners":["feature_x_team@mycompany.com","developer@mycompany.com"],"daemon":true,"instances":3,"rackSensitive":true,"loadBalanced":true}

KEYSINGULARITYABSTRACTIONS

SINGULARITYDEPLOYOBJECT

RESOURCES:Memory,CPUs,networkportsHEALTHCHECKS:TimeoutsandURLsLOADBALANCINGofwebserviceinstances(LBgroups,apibasepath)EXECUTORINFORMATION:executionenvironment,executableartifacts,configurationfiles,commandtoexecute,executortouse,etc.

{"requestId":"MDS_TestService","id":"71_7","customExecutorCmd":".../singularity-executor","resources":{"cpus":1,"memoryMb":896,"numPorts":3},"env":{"DEPLOY_MEM":"768","JVM_MAX_HEAP":"384m",},

"executorData":{"cmd":"java-Xmx$JVM_MAX_HEAP-jar.../TestService.jarserver$CONFIG_YAML""embeddedArtifacts":[{"name":"rawDeployConfig","filename":"TestService.yaml","content":"bmFtZT..."}],"externalArtifacts":[],"s3Artifacts":[{"name":"executableSlug","filename":"TestService.tar.gz","md5sum":"313be85c5979a1c652ec93e305eb25e9","filesize":81055833,"s3Bucket":"hubspot.com","s3ObjectKey":"build_artifacts/.../TestService.tar.gz"}],

SINGULARITYAPI

MANAGEDEPLOYABLEITEMS

ENDPOINT:/requests

register/update/unregisteranitem

getinfoaboutanitem

listitemsinactive|paused|cool-downstate

run/restart/pause/un-pauseanitem

SINGULARITYAPI

DEPLOYTHEDEPLOYABLEITEMS

ENDPOINT:/deploys

deployanalreadyregistereditem

cancelapendingdeploy

SINGULARITYAPI

MANAGEDEPLOYABLEITEMINSTANCES(TASKS)ENDPOINT:/tasks

getthelistofallscheduledtasks(notyetactive)

getscheduledtasksforaspecificitem

listtasksin state

infoaboutaspecifictask

activetasksinaslave

Killatask

SINGULARITYAPI

HistoricalInformationaboutdeployableitems&theirtasks

ENDPOINT:/history

asingletaskhistory

tasksthathaveruninthepast

allpreviousitemupdates

searchforhistoricalitemsbyitemid

allitemdeploys

aspecificitemdeploy

SINGULARITYAPI

LIST&DOWNLOADFILESINACTIVETASKSANDBOX

ENDPOINT:/sandbox

listalltaskfiles

readfilechunks

downloadafile

SINGULARITYAPIClusterSTATEInformation

ENDPOINT:/state

{activeTasks:567,activeRequests:843,cooldownRequests:1,scheduledTasks:142,pendingRequests:0,lbCleanupTasks:1,activeSlaves:21,deadSlaves:0,decomissioningSlaves:0,activeRacks:3,deadRacks:0,futureTasks:142,maxTaskLag:0,overProvisionedRequests:0,underProvisionedRequests:0,allRequests:844}

SINGULARITYUI-DEPLOYABLEITEMTASK

SINGULARITYUI-DASHBOARD

SINGULARITYUI-RACKS&SLAVES