34

Docker & ci

Embed Size (px)

Citation preview

Page 1: Docker & ci
Page 2: Docker & ci

CI & Docker

An experience building

complex CI environments

Patxi Gortázar

[email protected]

@fgortazar

Page 3: Docker & ci

Bio

Project Coordinator at @elastestio EU project

Devops @ Kurento

Teaching Distributed Systems @ URJC

@fgortazar

https://es.linkedin.com/in/franciscogortazar

Page 4: Docker & ci

Consultancy / Training

Cloud Computing

Distributed Systems

Web Technologies

Extreme Programming

Testing / Git / Jenkins

Software Architectures

Concurrent Programming

Open source elastic platformfor end to end testing

http://codeurjc.es http://elastest.io

Advanced log management

Test orchestration

Test execution comparison

Web and Mobile testing

Security testing

IoT testing

Performance testing

Page 5: Docker & ci

Why

A media server for real time video communication

The software under test

Page 6: Docker & ci

WebRTC

Page 7: Docker & ci

Software under test

Page 8: Docker & ci

Software under test

Page 9: Docker & ci

Software under test

So Kurento is…

• A media server

• APIs for managing connections in a WebRTC communication

• Tutorials

• Applications

• Testing

– Under many scenarios

– Even more testing in different environments

Page 10: Docker & ci

A soup of technologies

Page 11: Docker & ci

Some numbers

• 30 code repositories

• ~400 Jenkins jobs

• +1,000 tests

• +20 different environments to test

• +80 artifacts to be deployed at release time

Page 12: Docker & ci

Feasible infrastructures

Cloud

• Public or private

• 20 environments = 20 different VMs

• Cost increases with each new environment!!

• Effort increases with each new environment to

configure (ops)!!

• Time-to-market increases also!!

Page 13: Docker & ci

Kurento’s CI Infrastructure

Building Debian packages

• 2 Ubuntu Trusty VMs

• 4 Ubuntu Xenial VMs

• 2 Ubuntu latest VMs

Building clients

• 1 node mvn & jdk 7 & node 4

• 1 node mvn & jdk 7 & node 6

• 1 node mvn & jdk 8 & node 4

• 1 node mvn & jdk 8 & node 6

Page 14: Docker & ci

Further problems

• Developers are pushing hard towards ops/devopsto include changes in infrastructure

• Changes can hardly be reverted (possible, but…)

• Hard to test locally

– Works in my machine effect

• Wasted resources

• And at the same time, insufficient resources

Can we do better?

Page 15: Docker & ci

Simplifying CI with Docker

Page 16: Docker & ci

How

• Leverage Jenkins Pipeline

– CI configuration hosted within code repositories

– Docker support out-of-the-box

– Jenkins jobs launch containers on top of VMs

– VMs have all the same minimum configuration:

Docker

Page 17: Docker & ci

Current Infrastructure

1 VM Jenkins Master

N VMs Jenkins Workers (running Docker)

2 VM configurations

Page 18: Docker & ci

Where are my environments?

• The different environments are encapsulated as Docker images

• Docker images can be used in any of the workers

• Docker images can be used in your laptop

• Docker images are versioned, easy to maintain, easy to build

• Any version can be used

• Several environments can be run in parallel in the same VM: isolation

Page 19: Docker & ci

Which environments do I need?

You need images for your builds

You need images for your applications

You need images for your tests

Page 20: Docker & ci

Images for builds

• Heavy images (> 400Mb)

• One image per tool version: jdk7, jdk8

• Download ahead of time

– As opposed to downloading at build time

– E.g., downloading images in a nightly job

Page 21: Docker & ci

Images for builds

With Docker it’s easier to tame matrix envs

• Consider building a project using…

– Ubuntu

• Trusty

• Xenial

• Zesty

– Java

• JDK 7

• JDK 8

• JDK 9

Page 22: Docker & ci

Images for builds

What if we need to mix…

• JDK

• Maven

• Node

• Npm

• Bower

… in the same environment?

Page 23: Docker & ci

Images for applications

You're ready to ship your application as a

container (optional)

• Choose lightweight containers

– Docker is focusing on lightweight containers

leveraging Alpine Linux

• Include just what your application needs

– Leverage new multi-stage build in Docker

• Think about dependencies (databases, caching...)

Page 24: Docker & ci

Images for testing

• You can run browsers within a container

– https://github.com/SeleniumHQ/docker-selenium

• Available images

– selenium/hub

– selenium/node-chrome

– selenium/node-firefox

– selenium/node-chrome-debug

– selenium/node-firefox-debug

Page 25: Docker & ci

Images for testing

• Unfortunately they're a bit out of date

– See https://github.com/SeleniumHQ/docker-

selenium/issues/229#issuecomment-253334224

• Don't worry

– It's easy to build them with the latest browser

– We can test against latest release, beta and canary

• Alternatives

– TestContainers: https://www.testcontainers.org/

Page 26: Docker & ci

Testing with multiple containers

Orchestration...

• docker compose

– Require to know the number of containers in

advance

• Otherwise, docker run

• Cleaning containers and images with spotify-gc

Page 27: Docker & ci

Testing with multiple containers

Orchestration...

• End-to-end tests

– 1-5 browsers

– Test scenario is run several times with different

configurations

• Chrome (stable, beta, canary)

• Firefox (stable, beta)

• …

Page 28: Docker & ci

Testing with multiple containers

Orchestration...

• Tests can include a Docker client for flexibility:

– Start & stop containers

– Container inspection

– Gathering logs

– Managing Volumes

– Managing environment variables

Page 29: Docker & ci

Testing with multiple containers

Orchestration...

• Network topologies

– Specific network plugins

– Handcrafted networks

• docker run --net=none … Ugly hack!!

• Better use network plugins

Page 30: Docker & ci

Testing with multiple containers

Page 31: Docker & ci

Challenges

• Gathering data

– Logs from several containers

– Metrics (CPU, memory, network…)

– Files generated (browser recording)

• Integrating data with test execution

– Comparing some data across several executions

– Data integration

Page 32: Docker & ci

Challenges

• Reproducing real-world conditions

– Failing nodes

– Failing networks

– Network bandwidth (4G, 5G, DSL)

– Network topologies (NAT traversal, firewalls, …)

– High loads (bursting CPUs)

Page 33: Docker & ci

Consultancy / Training

Cloud Computing

Distributed Systems

Web Technologies

Extreme Programming

Testing / Git / Jenkins

Software Architectures

Concurrent Programming

Open source elastic platformfor end to end testing

http://codeurjc.es http://elastest.io

Advanced log management

Test orchestration

Test execution comparison

Web and Mobile testing

Security testing

IoT testing

Performance testing

Page 34: Docker & ci

Bio

Coordinator http://elastest.io/

Devops @ Kurento

Teaching Distributed Systems @ URJC

@fgortazar

https://es.linkedin.com/in/franciscogortazar