Dipping Your Toes Into Cloud Native Application Development

86
Dipping Your Toes Into Cloud Native Application Development

Transcript of Dipping Your Toes Into Cloud Native Application Development

Page 1: Dipping Your Toes Into Cloud Native Application Development

Dipping Your Toes Into Cloud Native Application Development

Page 2: Dipping Your Toes Into Cloud Native Application Development

Who is this guy?

– mattfarina.com, @mattfarina– Principal Engineer, Advanced Technology

Group, Hewlett Packard Enterprise– Go, Node.js, PHP, Ruby, Python, .NET… in

just past 5 years– Recently wrote book, “Go in Practice”– Co-lead Kubernetes SIG Apps– Likes to build things in the cloud– Doesn’t like bullet lists

2

Page 3: Dipping Your Toes Into Cloud Native Application Development

3By Swaminathan https://www.flickr.com/photos/araswami/2284451064/

Been doing cloud for 6 years and cloud native for 4 years. Yes, there is a difference

Page 4: Dipping Your Toes Into Cloud Native Application Development

4By Ted Silveira https://www.flickr.com/photos/cafebongo/14062452417/

Went from a large monolithic pet app to a cloud native application through a practical process

Page 5: Dipping Your Toes Into Cloud Native Application Development

5By Dubwise Version https://www.flickr.com/photos/dubwise_version/4718137117

Page 6: Dipping Your Toes Into Cloud Native Application Development

1.Why care about cloud native development?

2.What is cloud native?3.What tools can be used?4.How can you get from here to there?

6

Page 7: Dipping Your Toes Into Cloud Native Application Development

Why care about cloud native?

7

Page 8: Dipping Your Toes Into Cloud Native Application Development

8By: Fernando Frazão/Agência Brasil

Speed and Flexibility

Page 9: Dipping Your Toes Into Cloud Native Application Development

9Almost No Downtime

By: Marcin Wichary

Page 10: Dipping Your Toes Into Cloud Native Application Development

What does cloud native really mean?

10

Page 11: Dipping Your Toes Into Cloud Native Application Development

“container packaged, dynamically scheduled, and microservices based application development and operations.”– Cloud Native Computing Foundation (CNCF)

11

Page 12: Dipping Your Toes Into Cloud Native Application Development

“container packaged”

12By Sergio Morchon https://www.flickr.com/photos/smorchon/2431349077/

Page 13: Dipping Your Toes Into Cloud Native Application Development

Containers isn’t just Docker…

13

Page 14: Dipping Your Toes Into Cloud Native Application Development

Does this mean I can’t do cloud native with VMs?

14

Page 15: Dipping Your Toes Into Cloud Native Application Development

“dynamically scheduled”

15

Page 16: Dipping Your Toes Into Cloud Native Application Development

Method 1: You Manage It

16

Object Storage

Chef, Ansible, or Puppet

Network

Compute

Compute

Compute

Compute

Compute

Compute

Compute

Compute

Page 17: Dipping Your Toes Into Cloud Native Application Development

But, what way do most desktop applications work?

Choice 1 Choice B

17

App Laptop

Desktop

Pro Desktop

App CPU(s)

RAM

Drives

NIC(s)

Page 18: Dipping Your Toes Into Cloud Native Application Development

Method 2: Datacenter/Cluster as a Computer

18

Computer

• Could be a datacenter, rack, or single computer

• Manages the needed infra and changes for your apps for you

• Think of it as one computer rather than managed collection

REST API

Page 19: Dipping Your Toes Into Cloud Native Application Development

What’s Happening Inside The Computer?

19

Computer

REST APIRouter

Scheduler

App 1 App 2

App 3 App 4

Storage

Config

Page 20: Dipping Your Toes Into Cloud Native Application Development

20

Page 21: Dipping Your Toes Into Cloud Native Application Development

Combined Truth

21

ComputerREST API

Server

Server

Server Server

Server

ServerRouter

Router

Router

Chef, Ansible, or

Puppet

As app devs and operators see it What infra devs and operators do

Page 22: Dipping Your Toes Into Cloud Native Application Development

Managing Apps and a Datacenter as a Computer

22

Page 23: Dipping Your Toes Into Cloud Native Application Development

What You Can Use Today

23

Page 24: Dipping Your Toes Into Cloud Native Application Development

“microservices based”

What is a microservice?–Small–Focused on doing one thing well (single responsibility principle)–Independently deployable–Clearly defined API for interaction–Potentially reusable in other systems

24

Page 25: Dipping Your Toes Into Cloud Native Application Development

25

Monolithic App

Monolithic App

Monolithic App

Monolithic App

Micro Micro Micro Micro Micro

Micro

Micro

Micro

Micro

Micro

Micro

Micro

Micro

Page 26: Dipping Your Toes Into Cloud Native Application Development

Potential Network ProblemDon’t let the network be your bottleneck

26

Page 27: Dipping Your Toes Into Cloud Native Application Development

What makes a good REST API?

– Versioned, typically in the URL

– Use proper HTTP methods

– Behind Authentication and Authorization

– HTTP/2 if possible (for pipelines and connection reuse)

– TLS/HTTPS (encrypted transport)

– Proper HTTP response codes

– JSON

– Open API Initiative (Swagger)

27

Page 28: Dipping Your Toes Into Cloud Native Application Development

Reuse connections

28

Page 29: Dipping Your Toes Into Cloud Native Application Development

HTTP/2 and Pipelining

29

Page 30: Dipping Your Toes Into Cloud Native Application Development

12 Factor++ (12factor.net)

1. One codebase tracked in revision control, many deploys

2. Explicitly declare and isolate dependencies

3. Store config in the environment4. Treat backing services as attached

resources5. Strictly separate build and run

stages6. Execute the app as one or more

typically stateless processes containers

7. Export services via port binding8. Scale out via the process model

containers9. Maximize robustness with fast

startup and graceful shutdown10.Keep development, staging, and

production as similar as possible11.Treat logs as event streams12.Run admin/management tasks as

one-off processes containers

30

Page 31: Dipping Your Toes Into Cloud Native Application Development

Store config in the environment

31

Page 32: Dipping Your Toes Into Cloud Native Application Development

Treat backing services as attached resources

32

µ

Page 33: Dipping Your Toes Into Cloud Native Application Development

Execute the app as one or more stateless processes

33

Page 34: Dipping Your Toes Into Cloud Native Application Development

Treat logs as event streams (stdout)

34

Page 35: Dipping Your Toes Into Cloud Native Application Development

Pets vs cattle

35

Page 36: Dipping Your Toes Into Cloud Native Application Development

Updating Applications

36

Page 37: Dipping Your Toes Into Cloud Native Application Development

37

App(online)

App(online)

App(online)

App(offline)

App(offline)

App(offline)

App(update)

App(update)

App(update)

App(online)

App(online)

App(online)

Page 38: Dipping Your Toes Into Cloud Native Application Development

Blue / Green DeploymentsStart with Green

38

RouterUsers

AppAppAppApp

AppAppAppApp

Page 39: Dipping Your Toes Into Cloud Native Application Development

Blue / Green DeploymentsSwitch to Blue

39

RouterUsers

AppAppAppApp

AppAppAppApp

Page 40: Dipping Your Toes Into Cloud Native Application Development

Canary Release

40

Page 41: Dipping Your Toes Into Cloud Native Application Development

Rolling Updates

41

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

Page 42: Dipping Your Toes Into Cloud Native Application Development

Rolling Updates

42

v2 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

Page 43: Dipping Your Toes Into Cloud Native Application Development

Rolling Updates

43

v2 v2

v1 v1

v2 v2

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v2 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

v1 v1

Page 44: Dipping Your Toes Into Cloud Native Application Development

Rolling Updates

44

v2 v2

v2 v2

v2 v2

v2 v2

v2 v2

v2 v2

v2 v2

v2 v2

v2 v2

v2 v2

v2 v2

v2 v2

v2 v2

v2 v2

v2 v2

v2 v2

Page 45: Dipping Your Toes Into Cloud Native Application Development

3 Paths To Cloud Native:

1. Migration2. Greenfield3. Additive

45

Page 46: Dipping Your Toes Into Cloud Native Application Development

Path 1: Migrating

46

Page 47: Dipping Your Toes Into Cloud Native Application Development

My Web App Before The Cloud

47

This may look familiar

Webserver

Webserver

Webserver

Webserver

Load BalancersLoad BalancersUsersSharedfilesystemVia Gluster

memcached

memcached

memcached

memcached

MySQL

MySQL

MySQL

MySQL

MySQL had master and slave with fail over

Setup split between two physical locations

Individual servers managed by Chef in Prod, Test, and Dev environments

Page 48: Dipping Your Toes Into Cloud Native Application Development

3x Web Apps+ more coming

48

Page 49: Dipping Your Toes Into Cloud Native Application Development

… at the same time... Experiments in the cloud

49

Object Storage

VMVM VM

VM VM VM

Network

Users

Cloud resources managed by scripts and toolchains (like Chef)

Block Storage

Page 50: Dipping Your Toes Into Cloud Native Application Development

50

Page 51: Dipping Your Toes Into Cloud Native Application Development

51

Page 52: Dipping Your Toes Into Cloud Native Application Development

52

aPaaS

Page 53: Dipping Your Toes Into Cloud Native Application Development

53

Development Platform

Page 54: Dipping Your Toes Into Cloud Native Application Development

54

Page 55: Dipping Your Toes Into Cloud Native Application Development

Stackato Cluster(s)

Stackato ClustersProduction, QA, and Development Clusters

55

App 1

Load BalancersLoad BalancersUsersmemcachedmemcachedmemcached

MySQLMySQLMySQL

MySQL shifted over life of cluster. In Stackato and SaaS were used

Automation and scripts managed the clusters running on a IaaS (backed by VMs, Networking, Block Storage, and Object Storage).

App 1App 1

App 1App 1App 2

App 1App 1App N

…Detected top level problems and handled some failover

Ops Managed Platform

Filesystem Service

Page 56: Dipping Your Toes Into Cloud Native Application Development

Stackato ClustersDev Process

56

Production Stackato

QAStackato

DevStackato

PersonalEnvironment(s)

CI/CDGitDev

Branch to environment:master → productionQA → QAdevel → Dev

Production and QA used blue/green deployments with zero downtime

Features work on via feature branches

Page 57: Dipping Your Toes Into Cloud Native Application Development

Continuous Integration is about trust

57https://commons.wikimedia.org/wiki/File:CISV_trust_game.JPG

Page 58: Dipping Your Toes Into Cloud Native Application Development

Continuous Integration brings reproducibility

58

https://en.wikipedia.org/wiki/Assembly_line#/media/File:Ford_assembly_line_-_1913.jpg https://en.wikipedia.org/wiki/KUKA_Systems#/media/File:Application_field_automotive.jpg

Page 59: Dipping Your Toes Into Cloud Native Application Development

What is CD in CI/CD?

Continuous Delivery

Continuous Deployment

59

Code change pushed

Test code

BuildImage

Store build

...New build detected /

chosenDeploy to

environment

Page 60: Dipping Your Toes Into Cloud Native Application Development

Started With A Mono App

60

Stackato

memcached

MySQL

Filesystem Service

App 1Big Mono App

Page 61: Dipping Your Toes Into Cloud Native Application Development

Started With A Mono App

61

Stackato

memcached

MySQL

Filesystem Service

App 1Slightly SmallerBig App

App 1Microservice(App 2)

Page 62: Dipping Your Toes Into Cloud Native Application Development

Path 2: Greenfield

62

Page 63: Dipping Your Toes Into Cloud Native Application Development

Start With Your Setup

63

Computer

REST API

Page 64: Dipping Your Toes Into Cloud Native Application Development

Setup CI

64

Environment 1 Stackato

Environment 2 Stackato

Environment 3 Stackato

PersonalEnvironment(s)

CI/CD(Code Engine /

Jenkins)GitDev

Page 65: Dipping Your Toes Into Cloud Native Application Development

Built a Cloud Native Application

65

Stackato

DB DB DB

User InterfaceSe

rvic

e 1

Serv

ice

2

Serv

ice

3

Serv

ice

4

Serv

ice

N

… SaaS

Page 66: Dipping Your Toes Into Cloud Native Application Development

Built a Cloud Native Application

66

Docker

DB DB DB

User InterfaceSe

rvic

e 1

Serv

ice

2

Serv

ice

3

Serv

ice

4

Serv

ice

N

… SaaS

Page 67: Dipping Your Toes Into Cloud Native Application Development

Automation and ChatOps FTW

67

Page 68: Dipping Your Toes Into Cloud Native Application Development

Path 3: Additive

68

Page 69: Dipping Your Toes Into Cloud Native Application Development

We had a traditional application

69

These were physical but could have been VM

Webserver

Webserver

WebserverLoad BalancersLoad BalancersUsers

MongoDB

MongoDB

MongoDB

MongoDB

Setup split between multiple physical locations

Individual servers managed by Chef in Prod, Test, and Dev environments

Webserver

Page 70: Dipping Your Toes Into Cloud Native Application Development

Added Cloud Native Environment

70

The legacy environment was not retired

Webserver

Webserver

Webserver MongoDB

MongoDB

MongoDB

MongoDB

Legacy App called to cloud native app over REST API

Webserver

Stackato

Service 1

Service 2

Service 3

Service 4

Load BalancersLoad BalancersUsers

Page 71: Dipping Your Toes Into Cloud Native Application Development

Monitor Everything

71

Webserver

Webserver

WebserverMongoDB

MongoDB

MongoDB

MongoDBWebserver

Stackato

Service 1 Service 2

Load BalancersLoad BalancersUsers

Page 72: Dipping Your Toes Into Cloud Native Application Development

Monitor IntelligentlyIf you didn’t monitor it did it happen?

72

Page 73: Dipping Your Toes Into Cloud Native Application Development

Tools You Can Use

73

Page 74: Dipping Your Toes Into Cloud Native Application Development

74

Page 75: Dipping Your Toes Into Cloud Native Application Development

Datacenter/Cluster as a ComputerMake it easy for developers

75

Computer

REST APIThing that deploys

Page 76: Dipping Your Toes Into Cloud Native Application Development

Start With A PlatformThink Datacenter as a Computer

76

Page 77: Dipping Your Toes Into Cloud Native Application Development

Lifecycle ManagementConsider Helm when using Kubernetes

77

Kubernetes

REST APIHelm (to manage deployment)

Page 78: Dipping Your Toes Into Cloud Native Application Development

CI/CD

The CI/CD SystemMake it easy for developers

78

Computer

REST APIThing that deploysGitDev

Page 79: Dipping Your Toes Into Cloud Native Application Development

CI/CD SystemsThere are just so many

79

Page 80: Dipping Your Toes Into Cloud Native Application Development

Some Are Container Based By Default

80

Page 81: Dipping Your Toes Into Cloud Native Application Development

ChatOps

81

Page 82: Dipping Your Toes Into Cloud Native Application Development

Config service

82

Page 83: Dipping Your Toes Into Cloud Native Application Development

Monitor Everything

83

Page 84: Dipping Your Toes Into Cloud Native Application Development

GitHub ScientistPlus others following suit with more language support

84

Page 85: Dipping Your Toes Into Cloud Native Application Development

GitHub Scientisthttp://githubengineering.com/scientist/

85

Page 86: Dipping Your Toes Into Cloud Native Application Development

Questions?Matt [email protected] / hpe.com

86