docker & ci
TRANSCRIPT
![Page 1: Docker & ci](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/1.jpg)
![Page 2: Docker & ci](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/2.jpg)
CI & Docker
An experience building
complex CI environments
Patxi Gortázar
@fgortazar
![Page 3: Docker & ci](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/3.jpg)
Bio
Project Coordinator at @elastestio EU project
Devops @ Kurento
Teaching Distributed Systems @ URJC
@fgortazar
https://es.linkedin.com/in/franciscogortazar
![Page 4: Docker & ci](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/4.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/5.jpg)
Why
A media server for real time video communication
The software under test
![Page 6: Docker & ci](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/6.jpg)
WebRTC
![Page 7: Docker & ci](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/7.jpg)
Software under test
![Page 8: Docker & ci](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/8.jpg)
Software under test
![Page 9: Docker & ci](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/9.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/10.jpg)
A soup of technologies
![Page 11: Docker & ci](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/11.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/12.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/13.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/14.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/15.jpg)
Simplifying CI with Docker
![Page 16: Docker & ci](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/16.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/17.jpg)
Current Infrastructure
1 VM Jenkins Master
N VMs Jenkins Workers (running Docker)
2 VM configurations
![Page 18: Docker & ci](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/18.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/19.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/20.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/21.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/22.jpg)
Images for builds
What if we need to mix…
• JDK
• Maven
• Node
• Npm
• Bower
… in the same environment?
![Page 23: Docker & ci](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/23.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/24.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/25.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/26.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/27.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/28.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/29.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/30.jpg)
Testing with multiple containers
![Page 31: Docker & ci](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/31.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/32.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/33.jpg)
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](https://reader030.vdocuments.mx/reader030/viewer/2022021503/5a6cf04a7f8b9a22428b4753/html5/thumbnails/34.jpg)
Bio
Coordinator http://elastest.io/
Devops @ Kurento
Teaching Distributed Systems @ URJC
@fgortazar
https://es.linkedin.com/in/franciscogortazar