spring boot on kubernetes/openshift

38
1 @kamesh_sampath [email protected] bit.ly/springboot-on-openshift

Upload: kamesh-sampath

Post on 21-Jan-2018

105 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Spring Boot on Kubernetes/OpenShift

1

@kamesh_sampath [email protected]

bit.ly/springboot-on-openshift

Page 2: Spring Boot on Kubernetes/OpenShift

developers.redhat.com

Page 3: Spring Boot on Kubernetes/OpenShift

Who am I ?

● Active Open Source Contributor

● Creator vert.x-maven-plugin →

https://vmp.fabric8.io/

● Contributor fabric8 platform → https://fabric8.io/

kameshsampath

Kamesh SampathDirector of Developer Experience at Red Hat

@kamesh_sampath

[email protected]

Page 4: Spring Boot on Kubernetes/OpenShift

The microservice architectural style is an approach to developing a single application as a

suite of small services, each running in its own process and communicating with lightweight

mechanisms, often an HTTP resource API.

These services are built around business capabilities and independently deployable by fully

automated deployment machinery. There is a bare minimum of centralized management of

these services, which may be written in different programming languages and use different

data storage technologies.

Martin Fowler

What is a microservice ?

Page 5: Spring Boot on Kubernetes/OpenShift

Microservices Properties

MyService

Monitoring

Tracing

Discovery

API

Invocation

Resilience

Pipeline

Authentication

Logging Elasticity

Page 6: Spring Boot on Kubernetes/OpenShift

Short History of Microservices

Continuous

Integration

via XP

1999

AWS EC2

2006

DropWizard

May 2011

Agile

Manifesto

Feb

2001

NETFLIX

to AWS

2010

Ribbon

March 2012

Hystrix

March 2012

Eureka

July 2012

Microservices

Access

Thoughtworks

Radar

March 2012

Spring Boot

Sept 2013

Microservices

Defined

Thoughtworks

Fowler, Lewis

March 2014

Kubernetes

June 2014

Java EE6

2009

DevOps

2009Containers

Docker

2013

Page 7: Spring Boot on Kubernetes/OpenShift

java -jar myapp.jar

DropWizard

www.dropwizard.io

JAX-RS API

First to market

DropWizard Metrics

Embeddable

servers:

Jetty

Spring Boot

projects.spring.io/spring-

boot

Spring API

(@RestController)

‘Starter’ POMs:

start.spring.io

Embeddable servers:Tomcat, Jetty, Undertow

WildFly Swarm

wildfly-swarm.io

Java EE 7 APIs

‘Starter’ POMs:

wildfly-

swarm.io/generator

Embeddable

servers:

WildFly (Undertow)

Vert.x

vertx.io

Reactive

Async/non-blocking

vertx run myhttp.java

HTTP, HTTP/2, TCP,

UDP, Websockets,

etc. (out of the box)

Page 8: Spring Boot on Kubernetes/OpenShift

@kamesh_sampath

Java Microservices Platform circa 2014

Config Server

NETFLIX Ribbon

Page 9: Spring Boot on Kubernetes/OpenShift

@kamesh_sampath

Caveman’s Spring BootHow to ScaleHow to avoid

Port conflicts

Manage on

multiple hosts

How to manage

when hosts in

trouble ?

How to update

them ?

How to keep up

Desired vs Actual

states?

Where are my

containers ??

Page 10: Spring Boot on Kubernetes/OpenShift

@kamesh_sampath

Page 11: Spring Boot on Kubernetes/OpenShift

Open Container Initiative (OCI)

ImageSpecRuntime Spec (cri-o)

https://cri-o.io

https://www.opencontainers.org/

https://www.opencontainers.org/image-spec

e.g. Docker , rkt e.g. Docker formatted Images

docker.io/busybox

The Runtime Specification outlines

how to run a “filesystem bundle”

that is unpacked on disk

A container image package with

required metadata that will be used by

runtimes to run the container images

Page 12: Spring Boot on Kubernetes/OpenShift

▪ Greek for “Helmsman,” also the root of the

word “Governor” (from latin: gubernator)

▪ Container orchestrator

▪ Supports multiple cloud and bare-metal

environments

▪ Inspired by Google’s experience with containers

▪ Open source, written in Go

▪ Manage applications, not machines

Meet Kubernetes

Page 13: Spring Boot on Kubernetes/OpenShift

Pods

A group of whales is commonly referred to as a pod and a pod usually consists a

group of whales that have bonded together either because of biological reasons

or through friendships developed between two or more whales.

In many cases a typical whale pod consists of anywhere from 2 to 30 whales or

more.*

*http://www.whalefacts.org/what-is-a-group-of-whales-called/

Page 14: Spring Boot on Kubernetes/OpenShift

OpenShift is Enterprise Kubernetes

Page 15: Spring Boot on Kubernetes/OpenShift

PodReplication

Controller/

Deployment

Service Label

✓ 1+ containers

✓ Shared IP

✓ Shared storage volume

✓ Shared resources

✓ Shared lifecycle

✓ Ensures that a

specified

number of pod

replicas are

running at any

one time

✓ Grouping of

pods (acting as

one) has stable

virtual IP and

DNS name

✓ Key/Value pairs

associated with

Kubernetes objects

(env=production)

Kubernetes Cluster

Page 16: Spring Boot on Kubernetes/OpenShift

My Boot is Kube Awesome

JVM Configurations

Operating System

MyApp.jar

OCI

Page 17: Spring Boot on Kubernetes/OpenShift

DEMO (Hello Boot k8s deployment)

Page 18: Spring Boot on Kubernetes/OpenShift

@kamesh_sampath

Better Spring Boot Microservices Platform circa 2016

Config Server

NETFLIX Ribbon

Page 19: Spring Boot on Kubernetes/OpenShift

▪ Service Discovery

Spring Discovery Client using Kubernetes Service

Discovery

▪ ConfigMap Property Source

How to use Kubernetes ConfigMap as Spring

Property source

▪ Zipkin Service Discovery

Using Zipkin with Kubernetes for distributed tracing

Spring Cloud Kubernetes

Page 20: Spring Boot on Kubernetes/OpenShift

@kamesh_sampath

How to add to My Project?

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-kubernetes-discovery</artifactId>

<version>0.2.0.RELEASE</version>

</dependency>

Spring Cloud Kubernetes Discovery Spring Cloud Kubernetes Config

Spring Cloud Kubernetes ArchaiusSpring Cloud Kubernetes Netflix

Spring Cloud Kubernetes Zipkin

https://github.com/spring-cloud-incubator/spring-cloud-kubernetes

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-kubernetes-config</artifactId>

<version>0.2.0.RELEASE</version>

</dependency>

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-kubernetes-archaius</artifactId>

<version>0.2.0.RELEASE</version>

</dependency>

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-kubernetes-netflix</artifactId>

<version>0.2.0.RELEASE</version>

</dependency>

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-kubernetes-config</artifactId>

<version>0.2.0.RELEASE</version>

</dependency>

Page 21: Spring Boot on Kubernetes/OpenShift

DEMO (Discovery)

Page 22: Spring Boot on Kubernetes/OpenShift

@kamesh_sampath

Better Spring Boot Microservices Platform circa 2017

Config Server

NETFLIX Ribbon

Page 23: Spring Boot on Kubernetes/OpenShift

@kamesh_sampath

Better Spring Boot Microservices Platform circa 2018

Config Server

NETFLIX Ribbon

Jaeger

Istio

Page 24: Spring Boot on Kubernetes/OpenShift

Canary release is a technique to reduce the risk of introducing a new

software version in production by slowly rolling out the change to a

small subset of users before rolling it out to the entire infrastructure and

making it available to everybody.

Source: https://martinfowler.com/bliki/CanaryRelease.html

Microservice Architecture - Principles

Canary Release

Page 25: Spring Boot on Kubernetes/OpenShift
Page 26: Spring Boot on Kubernetes/OpenShift

Canary Deployment

DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS

SCM

Page 27: Spring Boot on Kubernetes/OpenShift

Canary Deployment

DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS

SCM

Page 28: Spring Boot on Kubernetes/OpenShift

Canary Deployment

DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS

SCM

Page 29: Spring Boot on Kubernetes/OpenShift

Canary Deployment

DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS

SCM

Page 30: Spring Boot on Kubernetes/OpenShift

Canary Deployment

DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS

SCM

Page 31: Spring Boot on Kubernetes/OpenShift

Canary Deployment

DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS

SCM

Page 32: Spring Boot on Kubernetes/OpenShift

Canary Deployment

DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS

SCM

Page 33: Spring Boot on Kubernetes/OpenShift

Canary Deployment

DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS

SCM

Page 34: Spring Boot on Kubernetes/OpenShift

Canary Deployment

DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS

SCM

Page 35: Spring Boot on Kubernetes/OpenShift

Canary Deployment

DEVELOPMENT QA STAGING PRODUCTION ROUTER USERS

SCM

Page 36: Spring Boot on Kubernetes/OpenShift

Demo

Page 37: Spring Boot on Kubernetes/OpenShift

▪ Minishift and Minikube

▪ Fabric8 Maven Plugin

▪ Eureka & Ribbon not required with Kubernetes

▪ Demos

○bit.ly/springboot-on-openshift

○Spring Cloud Brewery Application Migration

■bit.ly/green-cloud-demo

■bit.ly/green-cloud-demo-sources

○Stateful Canary leveraging Infinispan

■bit.ly/popdemo

●Open Containers Initiative

○ Runtime Spec - http://cri-o.io/

○ Image Spec – https://github.com/opencontainers/image-spec

Summary @kamesh_sampath

Page 38: Spring Boot on Kubernetes/OpenShift

38

@kamesh_sampath [email protected]

bit.ly/springboot-on-openshift