puzzle itc talk @docker ch meetup ci cd_with_openshift_0.2

31
Continuous Delivery with OpenShift Docker Meetup 31.5.2016 Thomas Philipona CTO

Upload: amrita-prasad

Post on 15-Jan-2017

118 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Continuous Deliverywith OpenShift

Docker Meetup 31.5.2016

Thomas PhiliponaCTO

Page 2: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Agenda

1. OpenShift v3

2. CI / CD

3. Key Concepts

4. OpenShift CI /CD Pipeline with Jenkins

Page 3: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

OpenShift v3

1

Page 4: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

OpenShift v3

“next generation PaaS” OpenShift v3 by Red Hat

V3 new implementation based on « de facto » standard technologies

Page 5: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Based on reliable open source concepts

Docker Kubernetes

Page 6: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

OpenShift v3

Container Platform as a Service (PaaS)

Multinode platform, Docker container runtime

Docker build platform

Docker registry

One platform runs it all!

Fancy CLI und GUI (self-service)

Container security enabled

Page 7: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Workflows● Docker build

● Prebuilt image

● Custom builder

● Source To Image

Page 8: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Workflow: Source To Image (S2I)

Git ?

s2i builder imageeg. openshift/ruby-22-centos7

code

code

My App

1.push code to git2. trigger webhook3.clone repo4.evaluate builder5.assemble image6.push to registry and deploy

12

3

4

5

MyApplicationMyApplication MyApp

6

Ruby, Java, PHP, NodeJs, ...

Page 9: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

CI / CD

2

Page 10: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Continuous Integration

● SCM

● compile and test

● software integration

● reporting

● deployment to test environment

● extension of CI

● one artifact on all environments

● fully automated deployment with a single click

● prod release with a single click

● each release is deployed to production

● rolling deployments necessary

● blue - green deployments

Continuous Delivery Continuous Deployment

Page 11: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

If It Hurts, Do It More Frequently, and Bring the Pain Forward

Source: Jez Humble, David Farley, Continuous Delivery, Pearson Education, Inc. 2011

Page 12: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

CI / CD Workflow Overview

Git

code

Compile, Unit-tests

Integration Tests, Package

Deploy to Dev

Acceptance Tests

Deploy to UAT env

Manual Tests

Deploy to Prod

Page 13: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Key Concepts

3

Page 14: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Maven / ArtefactrepositoryMaven versioning doesn't work well with continuous delivery

Each commit is a potential release candidate SNAPSHOT versions do not exist

Maven release plugin is integrated into the Maven lifecycle. All or nothing

mvn release:prepare mvn release:perform→

Many releases artifactrepository clean up→

Page 15: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Rolling Updates

OpenShift supports rolling updates.

The application notifies the platform when it’s ready for requests.

The routing layer then forwards requests to the new containers.

Page 16: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Automated Database Migration

DB Migrationscripts are part of the deployed application and executed during startup.

$ php bin/console doctrine:schema:update

$ rake db:migrate

Page 17: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Automated Database Migration

Database knows the current schema version

During application startup / deployment lifecycle hook, the DB migration is executed

Rolling update

DB must be backward compatible

Page 18: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Concepts: Automated Database Migration

V41 V42 V43

dropColumn

dropColumn

dropTable

dropTable

MyApplicationMyApplication App

DB

Page 19: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Concepts: Automated Database Migration

App.v41 App.v42

... oldColumn newColumn ...

guild42 guild42

DB Trigger

Page 20: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

OpenShift CI /CD Pipeline with Jenkins

4

Page 21: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Java Maven Example (1)

Git

code

Jenkins

code

Artefact Repo

artefact

checkout build release deploy

Jenkins

code

Jenkins

artefactcfg

+ Unit test+ Integration test+ Code analyse

Page 22: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Workflow: deploy

1.Jenkins buildmvn clean installtrigger build on OSE

2.custom builddownload artefactbuild docker image

3.deploy container

Jenkins

artifact

1 2

MyApplicationMyApplication MyApp

Custom builder image

3

My App

cfg

Page 23: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Java Maven Example (2)

acceptance tests

Jenkins

test

Jenkins

artefactcfg

deploy to UAT manual test

Jenkins

artefactcfg

deploy to Prod

Page 24: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Jenkins Pipeline Plugin

Build jobs written as Groovy scripts.

Build job script is next to source code in git repository

Jenkins provides the environment

● Git / Artifactory / OpenShift Accounts

https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Plugin

Page 25: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Example Build Script// Stage Checkout

stage 'Checkout'

git url: 'https://gitlab.puzzle.ch/tphilipona/appuio-javaee-example.git'

// Stage Build

stage 'Build'

sh "${mvnHome}/bin/mvn clean install"

Page 26: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Stage View

Page 27: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Conclusion

5

Page 28: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Key Factors: Automation and Fast Feedback

Customer,PO Dev Production

DeploymentIdea, Feature, Bug

Fast, qualified Feedback

Page 29: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Resources

https://docs.openshift.com

Page 30: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Q & A

01.6.2016 in BE15.6.2016 in ZH

Free APPUiO OpenShift Techlab

Page 31: Puzzle ITC Talk @Docker CH meetup CI CD_with_Openshift_0.2

Thank You!