"How to build powerful CI / CD based on GitLab and Docker", Aleksandr Matkovskiy & Vladislav Anikin

Post on 17-Mar-2018

152 views 2 download

Transcript of "How to build powerful CI / CD based on GitLab and Docker", Aleksandr Matkovskiy & Vladislav Anikin

Continuous Integration & Delivery

To Infinity and Beyond…

How to build powerful CI / CD based on GitLab and Docker

Vladislav Anikin Aleksandr MatkovskiyTeam Leader & Software architect in OrbitLift a Provectus company

Head of IT Department in Provectus

Say Hello!

Уже не Dev :( Вряд ли OPs :)

OrbitLift Department

Before• 3 Developers • 1 QA (manual) • 1 DevOps (part time) • 1 Team LeadService model

Now• 6 Developers • 1 QA (automation) • 1 DevOps (part time) • 1 Team LeadProduct model

+ +

Jenkins GitLab WebHooks

+ +

GitLabDocker Aleksandr

Jenkins + GitLab + WebHooks

✓ Price - it’s free :) ✓ Кастомизация и поддержка плагинов ✓ Устоявшееся CI решение на рынке ✓ Выполняет все необходимые задачи ✓ Интегрируется с Docker

- Price of Setup - it’s NOT free - Ужасный UI / UX - Where is my car memory, dude! - Время на конфигурацию / кастомизацию - Иногда доводит до слез

Pros Cons

How It Works

commit hook build trigger wait…………..

Service Product Model & Git Flow

• Reduce routine costs • Semantic Versioning 2.0.0 • Unit Test & Automation • Clean & Simple QA phase • Ability to Revert • Ability to Revert of Revert

Requirements

Requirements• Поддержка веток: master, hotfix, development, feature, rc • Полная пересборка свежих изменений (commits) • Подержка Tests & Coverage steps • Возможность очистки dev dependencies (housekeeping) • Доступность любого success build с заданным TTL • Fast, Clean, Secure delivery to destination • Удобство управления процессами (pipelines) • Plug & Play features • Lightweight

CI Concept

CI & CD Concept

Как «Я» понял ТЗ от Dev Team

• Проект на PHP • Один репозиторий • Конечное количество веток

• Хранение билдов в абстрактном хранилище

• Возможность развернуть любой билд на одной из площадок (QA, Dev, RC)

• Привязка ветки к площадке для разворачивания

Реали …• 2 различных репозитория • 2 разных проекта: Backend - PHP+nodejs, Frontend - Angular

• Не должно быть ограничений по количеству веток

• Разное окружение на build и execute серверах

• Нет жесткой привязки к веткам

Technology

Why GitLab

• With more than 100,000 organizations self-hosting GitLab • Docker private registry

Source: https://about.gitlab.com/2017/06/29/whats-next-for-gitlab-ci/

executorsGitLab Runner executors:

✓ Shell ✓ Docker ✓ Docker Machine (auto-scaling) ✓ Parallels ✓ VirtualBox ✓ SSH ✓ Kubernetes

Why • Минимальные накладные расходы

(containers vs virtualization) • Изолировання среда • Скажи НЕТ vendor lock • Сдаться облаку - НЕТ • Небывалая простота доставки

Why

Because

Implementation of the concept

Логическая схема Build Server

Логическая схема Execute Server

Capabilities CI/CD ✓ Не зависит от проекта/языка. ✓ Передача переменных Project -> CI/CD через Secret variables (GitLab) ✓ Гибкое управление процессом развертывания ✓ Подготовка окружения для сборки и тестирования ✓ Разное окружение на Execute и Build серверах ✓ Сборка по расписанию

GitLab CI Logic Scheme and PipelineGitLab CI Logical scheme

Pipeline on Feature branch

Pipeline on Develop branch

Cleanup

• Инструкция «пока» НЕ хранится в репозитории проекта

• Dev команда сама решает, как прибраться

• Индивидуальный набор инструкция для каждого проекта

Save build in storage

• Разделение прав - только на запись и только на чтение - AWS IAM • Уникальное имя архива по шаблону _имяВетки-хешКоммита_ • Шифрование архива (Опция) • Перенос старых билдов из S3 в Glacier (Опция)

Требования к CI / CD✓ GitLab v10+ ✓ Storage for builds ✓ Compute capacity : 1vCPU, 1GB RAM, 5GB Storage and more ✓ Software requirements: Docker, Docker-compose, GitLab-Runner on servers

We use:

✓ GitLab - 10.4.1 ✓ Storage - AWS S3 (+AWS Glacier in future) ✓ Compute capacity: AWS EC2 - t2.micro ✓ Software requirements:

✓ Ubuntu 16.04 ✓ Docker version 17.09.0-ce ✓ docker-compose version 1.17.0

SummaryPipelines history

SummaryRun custom pipeline on-demand

SummaryFull control and stop on error

SummarySupporting of Tests & Coverage

SummaryContinuous Delivery and Multiple Destinations

SummaryNightly Builds is our everything

Vision of IPWe can use it anywhere!

etc…

Bugs and Problem

1. Выполнение нескольких Pipeline одновременно. Привет ночным сборкам

2. Миграция cleanup инструкции в репозиторий проекта

3. Сделать CD для CI/CD

Achievements

У меня локально работает Продуктивная атмосфера Счастливые QA

Jenkins VS GitLab

Jenkins GitLab CIAverage Build Time6m 27s 0m 31s

excluding unit tests excluding unit tests

Memory Consumption~1,3Gb per build ~100Mb

AWS Instance (minimal requirement)m3.medium t2.micro

Where is my money?~ 21 build per day

6m 27s 0m 31s$15.65 per hour

(DOU Dec 2017)

$34,27 per day $2,66 per day

$685,4 per month $53,2 per month

$8464,69 per year $657,02 per year

Where is my money?

AWS

m3.medium t2.micro$0.077 per hour

$1.84 per day $0.27 per day

$55.44 per month $8.35 per month

$674.52 per year $101.6 per year

$0.0116 per hour

What’s next?

Revert deployments

Browser Performance Tests

SAST (Static App Security Tests)

Zero Downtime Deployments

Почему все получилось?

Vladislav Anikin Aleksandr MatkovskiyTeam Leader & Software architect in Orbitlift a Provectus company

Head of IT Department in Provectus

Thanks for patience

email: vanikin@provectus.com skype: just__a__man1

email: amatkovsky@provectus.com skype: matkovskiy.aleksandr