Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und...

22
Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter Entwicklertag, 21.02.2018

Transcript of Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und...

Page 1: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Continuous Integration und Delivery von Microservices mit GitLab CI

Christine Koppelt, Philipp Haußleiter

Frankfurter Entwicklertag, 21.02.2018

Page 2: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Continuous Integration (CI) & Microservices

Page 3: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Continuous Integration (CI)

Source Repository

CI ServerBauen Testen Paketieren

Server mit Anwendung

Entwicklungsteam

Sourcecode Deploybare Anwendung

Feedback

Page 4: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Microservices● Mehrere eigenständige Services bilden ein Gesamtsystem

○ Unterteilt nach Bounded Contexts (Domain Driven Design)○ Eigenständige Anwendungen (Frontend, Backend, Datenhaltung)○ Eigenständig deploybare Einheiten

● Eigenständige Entwicklungsteams○ Komplette Verantwortung für einen Service○ Extremfall: “You build it you run it”○ Freiheiten bei technischen und organisatorischen Entscheidungen

Page 5: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Microservices & CI

Branches

Datenbanken

Messaging

Testinfrastruktur

Mehrere Services

Unterschiedliche Buildtools

Mehrere Plattformen

Mehrere VersionenDocker-basierte

Deployments

A/B Testing

Unterschiedliche Entwicklungs-

prozesse

Microservices

Page 6: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Microservices & InfrastrukturDO

Entkopplung Infra-Team und Entwicklung

Entwickler konfigurieren CI Jobs und Staging Umgebung selbständig

Kapselung der Buildumgebung

DON’T

Modifikation der Konfiguration des CI Servers für einzelne Projekte

Adminrechte für Entwickler

Langwierige Abstimmungen zwischen Infra-Team und Entwicklung

Page 7: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Self Service

Page 8: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

GitLab

Page 9: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

GitLab● Gestartet als Web-Basierter Git Repository Manager● Mittlerweile: Umfangreiche Softwareentwicklungssuite

○ Issue Tracker integriert○ CI Server integriert○ Bauen von Merge Requests und Branches integriert○ Anlegen von Jobs über eine deklarative Konfiguration mittels Yaml ○ Builds innerhalb Docker

=> Sinnvolle Konventionen, modularer Ansatz

● Open Source, kommerzielle und Cloud Versionen

Page 11: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Beispiel

Page 12: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

CI Pipeline

build_jar

build

build_docker_image

package

deploy_staging

deploy

Job

Stage

Versand von Benachrichtigungen bei Problemen

Sourcecodeauschecken Kompilieren Testen Paketieren Deployen

test

int_test1

int_test2

Page 13: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Demo

Page 14: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Bau eines Java Projektesstages: - build

build_jar: stage: build image: maven:3-jdk-8 script: - mvn install artifacts: paths: - target/*.jar

build

test

deploy

package

Page 15: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Cachingstages: - build

variables: MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"

cache: paths: - .m2/repository

build_jar: ...

build

test

deploy

package

Page 16: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Services einbinden am Beispiel PostgreSQL...variables: POSTGRES_DB: enco POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres

int_test1: stage: test image: maven:3-jdk-8 services: - postgres:9.6 script: - mvn install -P integration-test1 artifacts: paths: - target/reports/*

build

test

deploy

package

Page 17: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Docker Image bauen & pushenstages: - build - test - package...

build_docker_image: stage: package image: docker:latest services: - docker:dind script: - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - docker build -t $CI_REGISTRY_IMAGE:latest . - docker push $CI_REGISTRY_IMAGE:latest

build

test

deploy

package

Page 18: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Branch-Spezifische Jobsstages: - build - test - package...

build_docker_image: stage: package image: docker:latest services: - docker:dind script: - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - docker build -t $CI_REGISTRY_IMAGE:latest . - docker push $CI_REGISTRY_IMAGE:latest only: - master

build

test

deploy

package

Page 19: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Deployment bei AWS Beanstalkdeploy_staging: ... script: - aws elasticbeanstalk create-application-version \ --application-name "$EB_APP_NAME" \ --version-label "$CI_COMMIT_SHA" \ --description "$CI_COMMIT_SHA" \ --source-bundle S3Bucket="$S3_BUCKET", \ S3Key="$CI_COMMIT_SHA.zip" - aws elasticbeanstalk update-environment \ --application-name "$EB_APP_NAME" \ --environment-name $EB_ENVIRONMENT \ --version-label "$CI_COMMIT_SHA" environment: name: staging url: $DEPLOYMENT_URL

build

test

deploy

package

Page 20: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Fragen?

Page 21: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

Vielen [email protected]@innoq.com

Page 22: Continuous Integration und Delivery von Microservices mit ... · Continuous Integration und Delivery von Microservices mit GitLab CI Christine Koppelt, Philipp Haußleiter Frankfurter

https://unsplash.com/photos/OhPhtHVt3FU

https://unsplash.com/photos/c53HvA-blYQ

https://unsplash.com/photos/7EHHidt3wyc

https://unsplash.com/photos/gq8V_6N3fNo

https://www.pexels.com/photo/shallow-focus-photography-of-black-microphone-164960/

Bildquellen