Top Banner
© 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE | NOVEMBER 15, 2016 CONTINUOUS DELIVERY WITH DC/OS AND JENKINS
40

SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

Aug 30, 2019

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

SOFTWARE ARCHITECTURE | NOVEMBER 15, 2016

CONTINUOUS DELIVERY WITH DC/OS AND JENKINS

Page 2: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

AGENDAPresentation

● Introduction to Apache Mesos and DC/OS● Components that make up modern infrastructure● Running Jenkins as a service on DC/OS● Continuously deploying applications to DC/OS

Demos & Lab

● Installing and configuring Jenkins● Installing and configuring a load balancer● Creating a new CI/CD pipeline● Putting it all together (CD in practice)

Page 3: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

DEVELOPER AGILITY, DEFINED

Page 4: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

Developer agility empowers developers to● ship their apps to production● leverage the power of Mesos and DC/OS● fix bugs rapidly

without downtime!

DEVELOPER AGILITY, DEFINED

Page 5: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

DEVELOPER AGILITY, DEFINED

Page 6: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

INTRO TO APACHE MESOS AND DC/OS

Page 7: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

A QUICK PRIMER ON CONTAINERS

Physical Server

Virtual Machine–BasedApplication Deployment

Container–BasedApplication Deployment

Hypervisor

OS

VM VM

OS

App App

Physical Server

Hypervisor

OS

VM VM

OS

App App

Physical Server

Operating System

App App

Physical Server

Operating System

App App

Mesos

Isolate apps by running multiple VMs per physical server; still need to manage each guest OS!

Isolate apps using features of the host OS, such as Linux cgroups.

Page 8: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

A QUICK PRIMER ON CONTAINERS

Linux cgroup

Dependencies

Linux Host OS

Application

Docker Container

Dependencies

Host OS

Application

Linux cgroupsDocker Containers

VM

Dependencies

Hypervisor

Application

Virtual Machines

Guest OS

Docker Engine

Page 9: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

A BIT OF CLARIFICATION

https://mesos.apache.org https://dcos.io

Page 10: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

● General purpose cluster resource manager● Represents many machines as a single entity● Advertises resources directly to frameworks● Works at scale: Apple, Twitter, Airbnb, Netflix, …

WHAT IS MESOS?

Page 11: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

● Two-tier scheduling across resource types● cpus, mem, disk, and ports by default

● Masters are highly available, agents are fault tolerant● Checkpointing, agent recovery

● Resource isolation between processes● Linux cgroups, Docker, …

● Language bindings: C++, Java, Python, Go, …

WHAT IS MESOS? (CONTINUED)

Page 12: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

MESOS ARCHITECTURE

Launch task(s)

Mesos Master Quorum

Mesos Master(Standby)

ZK

Mesos Master(Standby)

ZK

Mesos Master(Leader)

ZK

Framework B Scheduler

Agent 1

Framework A Executor

Task(s)

Agent n

Framework A Executor

Task(s)

Framework B Executor

Task(s)

Resource offer

Resource offer

Framework A Scheduler

Launch task(s)

Page 13: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

ANATOMY OF A RESOURCE OFFER (TWO-TIER SCHEDULING)

Mesos Master(s)

Mesos Agent

16 CPUs128 GB RAM

1 TB disk

Mesos Agent

16 CPUs128 GB RAM

1 TB disk

Mesos Agent

16 CPUs128 GB RAM

1 TB disk

Master offers resources to scheduler

SchedulerExecutor

Available compute resources

Resource offer accepted, launch executors/tasks

Tasks

Executor

Tasks

Executor

Tasks

Scheduler accepts or declines an offer

Page 14: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

● Service discovery and load balancing● BIND, Mesos-DNS, Consul-Mesos, Marathon-LB

NEW (OLD) PROBLEMS

Page 15: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

● Service discovery and load balancing● BIND, Mesos-DNS, Consul-Mesos, Marathon-LB

● Monitoring and metrics collection● Collectd, Nagios, Prometheus, Snap

NEW (OLD) PROBLEMS

Page 16: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

● Service discovery and load balancing● BIND, Mesos-DNS, Consul-Mesos, Marathon-LB

● Monitoring and metrics collection● Collectd, Nagios, Prometheus, Snap

● Persistent storage (filesystems, databases, etc)● Ceph, HDFS, Amazon EBS / EFS / S3, NFS, Cassandra

NEW (OLD) PROBLEMS

Page 17: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

● Service discovery and load balancing● BIND, Mesos-DNS, Consul-Mesos, Marathon-LB

● Monitoring and metrics collection● Collectd, Nagios, Prometheus, Snap

● Persistent storage (filesystems, databases, etc)● Ceph, HDFS, Amazon EBS / EFS / S3, NFS, Cassandra

● Administration: named URIs vs. ports, IPAM● Nginx, HAProxy, Mesos-DNS, dhcpd, Minuteman

NEW (OLD) PROBLEMS

Page 18: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

https://dcos.io

https://github.com/dcos

DC/OS:BUILT ON MESOS

Page 19: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

DC/OS:BUILT ON MESOS

Page 20: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

All of the benefits of Mesos, plus● Built-in service discovery and load balancing● Support for stateful services● Turn-key installation of distributed systems● Cloud-agnostic installer● Web and command-line interfaces● All components are integration tested and supported by

Mesosphere, Inc.

MESOS AND DC/OS: BETTER TOGETHER

Page 21: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

JENKINS ON DC/OS

Page 22: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved. 22

WHEN IT BEGAN

Jenkins on DC/OS

Jenkins master

Continuous Integration is soooo

futuristic and this interface is beautiful.

Page 23: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved. 23

THE OLD WORLD

Jenkins on DC/OS

Jenkins master

Life is good.

Jenkins agent

Jenkins agent

Jenkins agent

Jenkins agent

Jenkins master

Oh, is that Jenkins cluster still up? I do all my builds on a Raspberry Pi now.

Jenkins agent

Jenkins agent

Jenkins agent

Jenkins agent

Jenkins agent

Jenkins agent

Jenkins agent

Jenkins agent

Jenkins agent

Jenkins agent

Jenkins agent

Jenkins agent

Jenkins master

My builds take hours to run!

Jenkins agent

Page 24: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved. 24

RESOURCE EFFICIENCYJenkins on DC/OS

DC/OS master

DC/OS agentDC/OS agentDC/OS agent DC/OS agent DC/OS agent

Jenkins agent (master 1)

Jenkins agent (master 1)

Jenkins agent (master 3)

Jenkins agent (master 3)

Jenkins agent (master 3)

Jenkins master 1

Life is good.

Jenkins master 2

Jenkins master 3

Life is good.

Life is good.

Page 25: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved. 25

RESOURCE EFFICIENCYJenkins on DC/OS

DC/OS master

DC/OS agentDC/OS agentDC/OS agent DC/OS agent DC/OS agent

Jenkins agent (master 3)

Jenkins agent (master 3)

Jenkins agent (master 3)

Jenkins agent (master 3)

Jenkins agent (master 3)

Jenkins master 1

Team dinner! Let’s bounce.

Jenkins master 2

Jenkins master 3

Life is good.

Life is good.

Page 26: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

CONTINUOUSLY DEPLOYING APPLICATIONS TO DC/OS

Page 27: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

TRADITIONAL RELEASE PROCESS

● Planning & implementing new technologies

● Waiting for people & infrastructure

● Building environment specific CI/CD for each project

● Moving apps from dev to staging to prod

DEV(OPS) TEAMS SPEND SIGNIFICANT TIME AND EFFORT ON:

PROJECT PLANNING

WEEK 1 WEEK 2 WEEK 3 WEEKS 4 TO 8 WEEK 9

CUSTOMER FEEDBACKCONFIGURATIONRESOURCE

ALLOCATIONDev

Test Stage

Release

Page 28: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

MODERN RELEASE PROCESS

WEEK 1 WEEK 2 WEEK 3 WEEK 4

PROJECT PLANNING

CUSTOMER FEEDBACK

CUSTOMER FEEDBACK

CUSTOMER FEEDBACK

RELEASE 1 RELEASE 2 RELEASE 3 RELEASE 4

Better products through a repeatable release cadence

Happier customers through continuous feedback

Dev

Test Stage

Release Dev

Test Stage

Release Dev

Test Stage

Release Dev

Test Stage

Release

Page 29: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

● Scheduling — advertising available compute resources● Deployments — getting an application onto a node● Health checks — ensuring the app/service is healthy● Service discovery — connecting to dependent services● Persistence — running stateful services in containers

DEPLOYING APPLICATIONS: BASIC REQUIREMENTS

Page 30: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

A sysadmin provisions one or more physical/virtual servers to host the app

Mesos resource offers (two-tier scheduling) offers available resources directly to frameworks

DEPLOYING APPLICATIONS: SCHEDULING

Before DC/OS With DC/OS

Page 31: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

By hand or using Puppet / Chef / Ansible

Jenkins SSHing to the machine and running a shell script

Note: all dependencies must also be present!

Marathon deploys containers, ideally using a CI/CD tool to create/update app definitions

Docker containers packages app and dependencies

DEPLOYING APPLICATIONS: DEPLOYMENTS

Before DC/OS With DC/OS

Page 32: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

Nagios pages a sysadmin Marathon performs health checks, restarts unhealthy/failed instances

DEPLOYING APPLICATIONS: HEALTH CHECKS

Before DC/OS With DC/OS

Page 33: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

Static hostnames / IP addresses in a spreadsheet or config management

A sysadmin configures a load balancer manually or with Puppet / Chef / Ansible

Mesos-DNS provides DNS resolution for running services (hostname / IP address, ports, etc)

Load balancer configs built dynamically using cluster state

DEPLOYING APPLICATIONS: SERVICE DISCOVERY

Before DC/OS With DC/OS

Page 34: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

Individual servers with RAID 1/5/6/10, expensive SANs, NFS, etc.

Dedicated, statically partitioned Ceph or Gluster storage clusters

Mesos external/persistent volumes (REX-Ray), HDFS, etc.

Self-healing Ceph or Gluster on Mesos / DC/OS

DEPLOYING APPLICATIONS: PERSISTENCE

Before DC/OS With DC/OS

Page 35: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

DEMOS & LAB

Page 36: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved. 36

PIPELINE COMPONENTS

Continuous Integration

Container Registry

Container Orchestrator

Version Control System Load BalancerProduction

Environment

Continuous Delivery Pipeline

git push

DC/OS

Page 37: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved. 37

PIPELINE COMPONENTS

Jenkins

DockerHub

MarathonGitHub Marathon-lbMesos

Continuous Delivery Pipeline

git push

DC/OS

Page 38: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved. 38

PIPELINE CONFIGURATION

Jenkinsfile

Dockerfile

marathon.json

Continuous Delivery Pipeline

git push

DC/OS

Page 39: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

● Head over to github.com/mesosphere/software-architecture

● Follow the exercises!

● Use the username/password: sauser/sapass

YOUR TURN

Page 40: SOFTWARE ARCHITECTURE - mesosphere.github.iomesosphere.github.io/.../continuous-delivery-with-dcos-and-jenkins.pdf · © 2016 Mesosphere, Inc. All Rights Reserved. SOFTWARE ARCHITECTURE

© 2016 Mesosphere, Inc. All Rights Reserved.

Sunil [email protected]

@ssk2

THANK YOU!

Karl Isenberg speaks on POSIX for the data center3:50pm, Tower Salon A

Learn more by visiting dcos.io and mesosphere.com