42
SPRINGONE2GX WASHINGTON, DC Unless otherwise indicated, these slides are © 2013-2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Boot for DevOps Nicolas Fränkel @nicolas_frankel

Spring Boot for Devops

Embed Size (px)

Citation preview

Page 1: Spring Boot for Devops

SPRINGONE2GX WASHINGTON, DC

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Spring Boot for DevOps Nicolas Fränkel

@nicolas_frankel

Page 2: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Pardon my French…

2

Page 3: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Those don’t go well together

3

Page 4: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Me, Myself and I

•  Developer & Architect

–  As Consultant

•  Teacher/trainer

•  Blogger

Page 5: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

hybris, an SAP company

5

Page 6: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Shameless self-promotion

6

Page 7: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

DevOps

•  Devs and Ops collaboration?

•  Treat your infrastructure as code?

•  Automate everything?

Page 8: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

DevOps

•  Meta-data

•  Health checks

•  Metrics

Page 9: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

A little story

Page 10: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Spring Boot to the rescue

10

Page 11: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Non-Functional Requirements

•  Meta data

•  Monitoring

–  Health checks

–  Metrics

Page 12: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Non-Functional Requirements

•  Configuration

–  Beans

–  Property values

–  Controller mappings

–  etc.

Page 13: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Enough talk, time for a demo

Page 14: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

POM

<dependency> <groupId>

org.springframework.boot </groupId>

<artifactId> spring-boot-starter-actuator </artifactId>

</dependency>

Page 15: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Some endpoints

•  /metrics

•  /healthcheck

•  /configprops

Page 16: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Formatting

•  This is not really readable…

Page 17: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

RESTFul endpoints

17

Page 18: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

1. Meta data

18

Page 19: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Meta data

•  Which application?

–  groupId

–  applicationId

•  Version

–  From Maven

–  From Git

•  Anything!!!

19

Page 20: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Demo time

Page 21: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

2. Health checks

21

Page 22: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Health checks

•  A good way to monitor your application

•  Each check wraps a dependency

•  e.g. a datasource

Page 23: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Health checks

•  Each check returns an Health object

–  Status •  UP

•  DOWN •  UNKWOWN •  OUT_OF_SERVICE

–  Possibly with details

Page 24: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Health checks endpoint

•  /health aggregates all checks

•  Health are objects

–  Serialized in JSON

•  If only one is down, the HTTP code is set to 5xx

Page 25: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Health checks

•  Bean must implement HealthIndicator

•  Doesn’t use Dropwizard HealthCheck

Page 26: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Demo time

Page 27: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

3. Metrics

27

Page 28: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Dropwizard Metrics

•  A metrics model

•  Exporters to backends

•  And more…

Page 29: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Simple metrics

•  Gauge

–  Simple value

•  Counter

–  Incrementable gauge

Page 30: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Dropwizard reporters

•  JMX

•  Graphite

•  (HTTP)

Page 31: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

jconsole

•  JMX-compliant GUI for monitoring JVM

Page 32: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Page 33: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Demo time

Page 34: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Add Dropwizard metrics

<dependency> <groupId>io.dropwizard.metrics</groupId> <artifactId>metrics-graphite</artifactId> <version>4.0.0-SNAPSHOT</version> </dependency>

Page 35: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Send metrics to JMX

@Bean public JmxReporter jmxReporter() {

JmxReporter reporter =

JmxReporter.forRegistry(registry).build(); reporter.start(); return reporter;

}

Page 36: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Graphite

•  Store numeric time-series data

•  Render graphs of this data on demand

Page 37: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Starting carbon if not ready

•  sudo su bin/carbon-cache.py start

Page 38: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Send metrics to Graphite

@Bean public GraphiteReporter graphiteReporter() { Graphite graphite = new Graphite(

new InetSocketAddress("localhost",2003)); GraphiteReporter reporter =

GraphiteReporter.forRegistry(registry)

.prefixedWith("boot").build(graphite);

reporter.start(500, TimeUnit.MILLISECONDS); return reporter;

}

Page 39: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

For development

•  Either define the 2 reporters

–  Set @ConditionalOnMissingBean

–  Use a "Development" profile

•  Or define only the JMX reporter

–  In production, use JMXTrans

Page 40: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Metrics are not only technical

Page 41: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/

Q&A

https://github.com/nfrankel/enhanced-pet-clinic

@nicolas_frankel

http://frankel.in/

http://blog.frankel.ch/

https://leanpub.com/integrationtest/c/SpringOne

-20%

Page 42: Spring Boot for Devops

Unless otherwise indicated, these s l ides are © 2013-2015 Pivotal Software, Inc. and l icensed under a Creat ive Commons Attr ibut ion-NonCommercial l icense: ht tp: / /creat ivecommons.org/ l icenses/by-nc/3.0/ 42

Spring Boot for DevOps

Learn More. Stay Connected.

@springcentral Spring.io/video