code, ci, infrastructure - the gophers way

65
Code, CI, Infrastructure - the gophers way Alex Baitov Senior backend developer 2gis.com

Upload: alex-baitov

Post on 21-Jan-2017

118 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Code, ci, infrastructure - the gophers way

Code, CI, Infrastructure - the gophers way

Alex BaitovSenior backend developer

2gis.com

Page 2: Code, ci, infrastructure - the gophers way

About 2GISInternational tech company, developing software for convenient city living

2GIS City Information Service (most successful product)

● combines a map with a city directory

● used by over 40 million people

● covers over 300 cities in 9 different countries

info.2gis.com/index_en.html

Page 3: Code, ci, infrastructure - the gophers way

Content

1. Application written in golang

2. Ordinary infrastructure

3. Unified infrastructure

4. Gitlab CI as a glue

5. Benefits of using one language

Page 4: Code, ci, infrastructure - the gophers way

How did we come

to golang in production?

Page 5: Code, ci, infrastructure - the gophers way

Problem of losing packages

Applicationbackend server

Mainstatisticsserver

Page 6: Code, ci, infrastructure - the gophers way

Asynchronous reverse proxy with buffer

Applicationbackend server

Mainstatisticsserver

Asynchronous reverse proxy

with bufferon golang

Page 7: Code, ci, infrastructure - the gophers way

What infrastructure

to choose?

Page 8: Code, ci, infrastructure - the gophers way

Team infrastructures

Monolith

Microservice

Page 9: Code, ci, infrastructure - the gophers way

Team infrastructures

Monolith

Microservice

Page 10: Code, ci, infrastructure - the gophers way

Team infrastructures

Ordinary infrastructure

Monolith

Microservice

Page 11: Code, ci, infrastructure - the gophers way

Team infrastructures

Ordinary infrastructure

Monolith

Microservice

Page 12: Code, ci, infrastructure - the gophers way

Team infrastructures

Ordinary infrastructure

Monolith

Microservice

Page 13: Code, ci, infrastructure - the gophers way

Team infrastructures

Ordinary infrastructure

Unified infrastructure

Monolith

Microservice

Page 14: Code, ci, infrastructure - the gophers way

Team infrastructures

Ordinary infrastructure

Unified infrastructure

Monolith

Microservice

Microservice (other teams)

Page 15: Code, ci, infrastructure - the gophers way

Why did we switch

to another infrastructure?

Page 16: Code, ci, infrastructure - the gophers way

Software development life cycle

SDLC

PlanningPlanning

Develop-ment

Develop-ment

TestingTestingDeliveryDelivery

Mainte-nance

Mainte-nance

Infrastructure

is the core

of SDLC

Page 17: Code, ci, infrastructure - the gophers way

SDLC: substages

PlanningPlanning

Develop-ment

Develop-ment

TestingTestingDeliveryDelivery

Mainte-nance

Mainte-nance

Application

SDLC

Page 18: Code, ci, infrastructure - the gophers way

SDLC: substages

PlanningPlanning

Develop-ment

Develop-ment

TestingTestingDeliveryDelivery

Mainte-nance

Mainte-nance

Application

Unit

Functional

SDLC

Page 19: Code, ci, infrastructure - the gophers way

SDLC: substages

PlanningPlanning

Develop-ment

Develop-ment

TestingTestingDeliveryDelivery

Mainte-nance

Mainte-nance

Application

UnitDeploy

Configuring Functional

SDLC

Page 20: Code, ci, infrastructure - the gophers way

SDLC: substages

PlanningPlanning

Develop-ment

Develop-ment

TestingTestingDeliveryDelivery

Mainte-nance

Mainte-nance

Application

UnitDeploy

Configuring Functional

Metrics and Alerting

Logging

Monitoring

Init andkeeping alive

SDLC

Page 21: Code, ci, infrastructure - the gophers way

SDLC: substage tools

PlanningPlanning

Develop-ment

Develop-ment

TestingTestingDeliveryDelivery

Mainte-nance

Mainte-nance

Application

UnitDeploy

Configuring Functional

Metrics and Alerting

Logging

Monitoring

Init andkeeping alive

SDLC

jenkins / rundeck / heat templates in openstack

chef / ansible

zabbix / sensu

application sends by protocol / beaver

kibana

upstart / systemd / monit

openstack / own testing frameworks

test modules

framework /package manager / standards

Page 22: Code, ci, infrastructure - the gophers way

Disadvantages of lots of tools

● High entry barrier

Page 23: Code, ci, infrastructure - the gophers way

Disadvantages of lots of tools

● High entry barrier

● Simultaneous studying of all this tools takes a long time

Page 24: Code, ci, infrastructure - the gophers way

Disadvantages of lots of tools

● High entry barrier

● Simultaneous studying of all this tools takes a long time

● Difficult integration

Page 25: Code, ci, infrastructure - the gophers way

Disadvantages of lots of tools

● High entry barrier

● Simultaneous studying of all this tools takes a long time

● Difficult integration

● Specific debugging of each tool

Page 26: Code, ci, infrastructure - the gophers way

Disadvantages of lots of tools

● High entry barrier

● Simultaneous studying of all this tools takes a long time

● Difficult integration

● Specific debugging of each tool

● Human factor (sometimes forget something)

Page 27: Code, ci, infrastructure - the gophers way

What if you need to look inside a tools or

write a custom module for it?

You need to know tool’s language

Page 28: Code, ci, infrastructure - the gophers way

SDLC: substage tools languages

PlanningPlanning

Develop-ment

Develop-ment

TestingTestingDeliveryDelivery

Mainte-nance

Mainte-nance

Application

UnitDeploy

Configuring Functional

Metrics and Alerting

Logging

Monitoring

Init andkeeping alive

SDLC

java / heat templates yaml

ruby / python

c, php / ruby

application language / python

javascript

c

php / scala

php / scala / go

php / scala

Page 29: Code, ci, infrastructure - the gophers way

Disadvantages of different languages of lots of tools

● Different error reporting for each language

Page 30: Code, ci, infrastructure - the gophers way

Disadvantages of different languages of lots of tools

● Different error reporting for each language

● Harder understanding of how the tool works

Page 31: Code, ci, infrastructure - the gophers way

Disadvantages of different languages of lots of tools

● Different error reporting for each language

● Harder understanding of how the tool works

● Studying different languages to write custom modules

Page 32: Code, ci, infrastructure - the gophers way

Advantages of this approach

● Wider knowledge about familiar tools

● Familiar tools help to fast build of minimum viable product (MVP)

Page 33: Code, ci, infrastructure - the gophers way

Disadvantages of this approach

● Too much support for one team

● Too much tools for building microservices

● Long everyday releases

● Expensive development process

Page 34: Code, ci, infrastructure - the gophers way

How to improve it?

Page 35: Code, ci, infrastructure - the gophers way

Unified infrastructure

● DEIS - platform as a service that deploys and scales containers

● Docker - pack, ship and run any application as a lightweight, portable,

self-sufficient container

● Prometheus - metrics and alerting system

● Grafana - metrics visualization

Page 36: Code, ci, infrastructure - the gophers way

Unified infrastructure

● DEIS - platform as a service that deploys and scales containers

● Docker - pack, ship and run any application as a lightweight, portable,

self-sufficient container

● Prometheus - metrics and alerting system

● Grafana - metrics visualization

All of them are:

● open-source● written on go

Page 37: Code, ci, infrastructure - the gophers way

Unified infrastructure

● DEIS -> DEIS 2 ( Workflow / Kubernetes )

● Docker - pack, ship and run any application as a lightweight, portable,

self-sufficient container

● Prometheus - metrics and alerting system

● Grafana - metrics visualization

All of them are:

● open-source● written on go

Page 38: Code, ci, infrastructure - the gophers way

How do we use mostly golang

infrastructure in production?

Page 39: Code, ci, infrastructure - the gophers way

SDLC: substage tools

PlanningPlanning

Develop-ment

Develop-ment

TestingTestingDeliveryDelivery

Mainte-nance

Mainte-nance

Application

SDLC

native /framework /vendoring / standards

Page 40: Code, ci, infrastructure - the gophers way

SDLC: substage tools

PlanningPlanning

Develop-ment

Develop-ment

TestingTestingDeliveryDelivery

Mainte-nance

Mainte-nance

Application

Unit

Functional

SDLC

docker-compose / test library

test library

native /framework /vendoring / standards

Page 41: Code, ci, infrastructure - the gophers way

SDLC: substage tools

PlanningPlanning

Develop-ment

Develop-ment

TestingTestingDeliveryDelivery

Mainte-nance

Mainte-nance

Application

UnitDeploy

Configuring Functional

SDLC

gitlab-ci / deis

gitlab-ci / deis (via environment variables)

docker-compose / test library

test library

native /framework /vendoring / standards

Page 42: Code, ci, infrastructure - the gophers way

SDLC: substage tools

PlanningPlanning

Develop-ment

Develop-ment

TestingTestingDeliveryDelivery

Mainte-nance

Mainte-nance

Application

UnitDeploy

Configuring Functional

Metrics and Alerting

Logging

Monitoring

Init andkeeping alive

SDLC

gitlab-ci / deis

gitlab-ci / deis (via environment variables)

prometheus

deis captures application output

deis (via checking health)

kibana / grafana

docker-compose / test library

test library

native /framework /vendoring / standards

Page 43: Code, ci, infrastructure - the gophers way

SDLC: substage tools languages

PlanningPlanning

Develop-ment

Develop-ment

TestingTestingDeliveryDelivery

Mainte-nance

Mainte-nance

Application

UnitDeploy

Configuring Functional

Metrics and Alerting

Logging

Monitoring

Init andkeeping alive

SDLC

go / gitlab-ci yaml

go / gitlab-ci yaml

go

go

go / javascript

go

go

go

go

Page 44: Code, ci, infrastructure - the gophers way

This infrastructureis also used for

Scala, Node.js and C#applications

Page 45: Code, ci, infrastructure - the gophers way

Comparison of SDLCs

Ordinary infrastructure

Tools (quantity)

Golang infrastructure

Languages (quantity)

15 + 8

7 3

Page 46: Code, ci, infrastructure - the gophers way

How do we use it together?

Page 47: Code, ci, infrastructure - the gophers way

Gitlab workflow

● 2 shared runners with docker: 16 GB, 32 CPU

● Gitlab-ci job isolation with docker or docker-compose

● Latest branch docker images of application - in entire

docker registry

● That allows to rollback

● Job parallelisation

Page 48: Code, ci, infrastructure - the gophers way

Gitlab pipeline

Page 49: Code, ci, infrastructure - the gophers way

Everything in code

● Application● Tests

Page 50: Code, ci, infrastructure - the gophers way

Everything in code

● Application● Tests● Deploy● Configuration

Page 51: Code, ci, infrastructure - the gophers way

Everything in code

● Application● Tests● Deploy● Configuration● Metrics● Alerts rules

Page 52: Code, ci, infrastructure - the gophers way

Everything in code

● Application● Tests● Deploy● Configuration● Metrics● Alerts rules

Review everything via merge requestsEasy to resolve problem

Page 53: Code, ci, infrastructure - the gophers way

What are benefits

from using golang

in application and infrastructure?

Page 54: Code, ci, infrastructure - the gophers way

Benefits of language coincidence

First official tool client goes on its native language: go

Page 55: Code, ci, infrastructure - the gophers way

Benefits of language coincidence

First official tool client goes on its native language: go

Easy to read and understand tools logic

Page 56: Code, ci, infrastructure - the gophers way

Benefits of language coincidence

First official tool client goes on its native language: go

Easy to read and understand tools logic

Easy to contribute in infrastructure

Page 57: Code, ci, infrastructure - the gophers way

Benefits of language coincidence

First official tool client goes on its native language: go

Easy to read and understand tools logic

Easy to contribute in infrastructure

Concentrate on one language

Page 58: Code, ci, infrastructure - the gophers way

Benefits of language coincidence

First official tool client goes on its native language: go

Easy to read and understand tools logic

Easy to contribute in infrastructure

Concentrate on one language

Fast maintenance reaction

Page 59: Code, ci, infrastructure - the gophers way

Benefits of language coincidence

First official tool client goes on its native language: go

Easy to read and understand tools logic

Easy to contribute in infrastructure

Concentrate on one language

Fast maintenance reaction

Fast mvp

Page 60: Code, ci, infrastructure - the gophers way

Conclusion

Everything in code

Mostly one language

Golang is good for infrastructure tools

Golang is production proved

Page 61: Code, ci, infrastructure - the gophers way

Alex Baitov [email protected]

[email protected]

slides & links : goo.gl / LKPmvi

2gis.ru

Thank you!

Page 62: Code, ci, infrastructure - the gophers way

Extras

Page 63: Code, ci, infrastructure - the gophers way

DockerAn open-source project that automates the deployment of Linux applications inside software containers

Also use:

● Docker-compose● Docker registry

Page 64: Code, ci, infrastructure - the gophers way

DeisAn open-source platform as a service (PaaS) that makes it easy to deploy and manage applications on your own servers.

Deis builds upon Docker and CoreOS to provide a lightweight PaaS with a Heroku-inspired workflow.

Built-in:

● Logging● Scaling● Routing● Fault-tolerance

Page 65: Code, ci, infrastructure - the gophers way

PrometheusAn open-source metrics and alerting system:

● Implements a highly dimensional model data● Flexible querying language● Built-in visualisation● Federation system● Push or pull data mining● Alert manager● Many client libraries