martin höfling tng technology consulting …...© tng technology consulting gmbh 3 / 54...
TRANSCRIPT
Martin HöflingJohannes Ebke
From Zero to Webscale:Evolving a Continuous Delivery Pipeline
TNG Technology Consulting
2 / 54© TNG Technology Consulting GmbH
What this talk is about
Introduction
►Context
►Challenges
►Technology
Evolution towards fully automatic deployment
Remarks & Conclusions
Overview
3 / 54© TNG Technology Consulting GmbH
Introduction: Context
TNG Technology Consulting GmbH
~230 regular employees,
►> 50% with a PhD
►Physics, Mathematics, Computer Science
Founded in 2001, grown ever since, CAGR ~ 25%
Place of Business: Munich – Heart of Bavaria
Value-based consulting partnership
Focus on high end IT
4 / 54© TNG Technology Consulting GmbH
Startup Characteristics
Few people
Moving targets
No dedicated operations
Motivated tech addicts
Fast decisions - flat hierarchy
Everybody feels responsible(ideally…)
Introduction: Context
5 / 54© TNG Technology Consulting GmbH
The Product
Introduction: Context
6 / 54© TNG Technology Consulting GmbH
Scaling
Introduction: Challenges
…sometimes many, sometimes fewer users
7 / 54© TNG Technology Consulting GmbH
Complexity
Introduction: Challenges
Multiple backend types
Several Databases and Queues
Despite of Complexity: Daily Releases
8 / 54© TNG Technology Consulting GmbH
What Technology are we using?
ReactWebpack
Gulp
TornadoPython3.5 Elasticsearch
MongoDB RedisJenkins
Packer
Docker
SaltStackTerraform
Boto3 AWS
Vagrant
Icinga2 ELK
Backbone
Introduction: Technology
9 / 54© TNG Technology Consulting GmbH
What this talk is about
Introduction
Evolution towards fully automatic deployment
►Phase 1: Starting up
►Phase 2: Automating deployment to the cloud
►Phase 3: Fully automated infrastructure setup
Remarks & Conclusions
Overview
10 / 54© TNG Technology Consulting GmbH
Starting Up
Set up CI pipeline
►Automatic testing
Create deployable artifact
►Deploy „somewhere“:
►Reproducible
Starting Up
11 / 54© TNG Technology Consulting GmbH
Infrastructure at the Beginning
Starting Up
Local Cloud
developers
CI / Jenkinstest instance
production single EC2
SSH
12 / 54© TNG Technology Consulting GmbH
What is SaltStack?
Starting Up
Quoting saltstack.com:
… „scalable and flexible configuration management“
… „event-driven automation of CloudOps, ITOps and DevOps“
13 / 54© TNG Technology Consulting GmbH
Why SaltStack?
Key features:
Declarative configuration state management
Scalability to thousands of managed machines
Event driven reaction and reconfiguration:
►Predictive Orchestration
Nice to have:
Provider agnostic (Cloud-) Ops
Implemented / extensible in Python
Large, friendly community
Starting Up
14 / 54© TNG Technology Consulting GmbH
Declarative Configuration: Salt States
Starting Up
/etc/secrets: file.managed: - mode: 600 - contents: | root:secret
nginx: service.running: - reload: True - watch: - file: /etc/secrets
/etc/secrets: file.managed: - mode: 600 - contents: | root:secret
nginx: service.running: - reload: True - watch: - file: /etc/secrets
ResourceState Function
Parameter
Dependency
15 / 54© TNG Technology Consulting GmbH
Event Driven Orchestration with Salt
Starting Up
Salt Master Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
subscribe
Salt Minion app-42
subscribe
Salt Minion monitoring
subscribe
Master Event Bus
Master - Minion Event Bus
Salt Minion elasticsearch-11
16 / 54© TNG Technology Consulting GmbH
Event Driven Orchestration with Salt
Starting Up
Salt Master Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
subscribe
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
subscribe
Salt Minion monitoring
subscribe
Master Event Bus
Master - Minion Event Bus
Salt Minion elasticsearch-11
From: AWS type: new machine launched machine: elasticsearch-12
Salt Minion elasticsearch-12
17 / 54© TNG Technology Consulting GmbH
Event Driven Orchestration with Salt
Starting Up
Salt Master Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
subscribe
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
subscribe
Salt Minion monitoring
subscribe
Master Event Bus
Master - Minion Event Bus
Salt Minion elasticsearch-11
From: AWS type: new machine launched machine: elasticsearch-12
To: elasticsearch-12 Function: install_es Arguments: -version: 2.1.3
Salt Minion elasticsearch-12
publish job
18 / 54© TNG Technology Consulting GmbH
Event Driven Orchestration with Salt
Starting Up
Salt Master Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
subscribe
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
Salt Minion app-42
subscribe
Salt Minion monitoring
subscribe
Master Event Bus
Master - Minion Event Bus
Salt Minion elasticsearch-11
From: elasticsearch-12 JobId: 3032 Result: OK, installed
To: elasticsearch-12 Function: install_es Arguments: -version: 2.1.3
Salt Minion elasticsearch-12
19 / 54© TNG Technology Consulting GmbH
Event Driven Orchestration with Salt
Starting Up
Salt Master Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
subscribe
Salt Minion app-42
subscribe
Salt Minion monitoring
subscribe
Master Event Bus
Master - Minion Event Bus
Salt Minion elasticsearch-11
From: elasticsearch-12 JobId: 3032 Result: OK, installed
To: app-* Function: add_ES_to_config Arguments: -server: elasticsearch-36
Salt Minion elasticsearch-12
publish job
20 / 54© TNG Technology Consulting GmbH
Event Driven Orchestration with Salt
Starting Up
Salt Master Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
Salt Minion loadbalancer-12
subscribe
Salt Minion app-42
subscribe
Salt Minion monitoring
subscribe
Master Event Bus
Master - Minion Event Bus
Salt Minion elasticsearch-11
From: app-[1..42] JobId: 3034 Result: OK, config
To: app-* Function: add_ES_to_config Arguments: -server: elasticsearch-36
Salt Minion elasticsearch-12
21 / 54© TNG Technology Consulting GmbH
Automating deployment with Salt
Local Clouddevelopers
test instances
production single EC2CI / Jenkins
Salt master
Salt / ØMQ Artifact
Starting Up
22 / 54© TNG Technology Consulting GmbH
Starting Up - Lessons Learned
Keep testing and production in sync
Automate deployment early
►Select and get familiar with your deployment tool
Make the deployment accessible for the team
► Infrastructure as Code from the beginning
Starting Up
23 / 54© TNG Technology Consulting GmbH
What this talk is about
Introduction
Evolution towards fully automatic deployment
►Phase 1: Starting up
►Phase 2: Automating deployment to the cloud
►Phase 3: Fully automated infrastructure setup
Remarks & Conclusions
Overview
24 / 54© TNG Technology Consulting GmbH
Automating Deployment into the Cloud
Rationale:
Cloud Machines are Cattle, not Pets ...
► ... they must be replaceable quickly
(Bill Baker, Microsoft)
Approach:
Automate dynamic resource configuration (e.g. deployment):
► resource allocation, software installation, …
► distributed systems with many moving parts
Manual configuration of static resources:
►VPC, VPN, Firewall, Routing and DNS
Modularize CI/CD
Automating Deployment
25 / 54© TNG Technology Consulting GmbH
Dockerized Jenkins Pipeline
Reasons:
Flexibility
►Versioned and adapting CD pipeline
►Deployability in case of hardware failure
Transparency
►Docker test cluster also runs locally
Rapid feedback
►Scale beyond single machine
►Parallel integration tests
Automating Deployment
26 / 54© TNG Technology Consulting GmbH
Dockerized Jenkins Pipeline – Build
Automating Deployment
Local Clouddevelopers
test instances
production instance
CI
Test / Build
Artifact
27 / 54© TNG Technology Consulting GmbH
Dockerized Jenkins Pipeline – Deploy
Automating Deployment
Local Clouddevelopers
test instances
production instance
Salt / ØMQ CI
Salt master
28 / 54© TNG Technology Consulting GmbH
Salt Cloud – Machine Lifecyle made easy
Cloud Profile
►Different providers possible
Cloud Map
►List instances for each profile
Salt-cloud
►Creates / destroys machines
► Installs Salt
►Attaches machine to salt-master
Automating Deployment
appserver: provider: aws image: ami-bdc9dad1 size: t2.large
loadbalancer: provider: gce image: centos-6 size: n1-standard-1
appserver: provider: aws image: ami-bdc9dad1 size: t2.large
loadbalancer: provider: gce image: centos-6 size: n1-standard-1
loadbalancer: - lb1 - lb2
appserver: - app1 - app2 - app3
loadbalancer: - lb1 - lb2
appserver: - app1 - app2 - app3
29 / 54© TNG Technology Consulting GmbH
Salt Cloud from Dockerized Salt Container
Automating Deployment
Local Clouddevelopers
test instances
production instance
Salt / ØMQ CI
Salt master
Salt Cloud new instance
30 / 54© TNG Technology Consulting GmbH
Distribute your Application
Reasons:
Improved availability
Horizontal scaling
Problems:
Adds complexity to your setup
►Deployment often requires complex orchestration
Automating Deployment
31 / 54© TNG Technology Consulting GmbH
Automating Deployment
How to Create a Distributed Application?
32 / 54© TNG Technology Consulting GmbH
Create Distributed Applications with Salt Cloud
Automating Deployment
Local Clouddevelopers
all-in-one instances
distributed instance
Salt / ØMQ
CI
Salt master
new instance master
new instance
33 / 54© TNG Technology Consulting GmbH
Create Distributed Applications with Salt Cloud
Automating Deployment
Local Clouddevelopers
distributed instance
Salt / ØMQ
CI
Salt master
instance master
trigger salt-cloud
salt cloud
34 / 54© TNG Technology Consulting GmbH
Deployment of a Distributed Application
Separate non critical and critical steps
Non-critical:
►Build and Push Frontend / Backend Package
►Update Instance Master
Critical step
►Apply configuration to (critical) systems
► Independent of local CI
Automating Deployment
35 / 54© TNG Technology Consulting GmbH
Deployment of a Distributed Application
Automating Deployment
Local Clouddevelopers
distributed instance
Salt / ØMQ
CI
Salt master
instance master
36 / 54© TNG Technology Consulting GmbH
Deployment of a Distributed Application
Automating Deployment
Local Clouddevelopers
distributed instance
Salt / ØMQ
CI
Salt master
instance master ELBs
trigger activation
ØMQ
37 / 54© TNG Technology Consulting GmbH
Autoscaling
Goals:
Only use computing resources required at the moment
Automatically replace dead or disconnected instances
Approaches:
Autoscaling solely with Salt
AWS Autoscaling technology
Automating Deployment
38 / 54© TNG Technology Consulting GmbH
Deployment with Autoscaled Application Tier
Automating Deployment
Local Clouddevelopers
distributed instance
CI
Salt master
instance master
Salt / ØMQ app template
trigger activation
39 / 54© TNG Technology Consulting GmbH
Deployment with Autoscaled Application Tier
Automating Deployment
Local Clouddevelopers
distributed instance
CI
Salt master
instance master
ELBs
Salt / ØMQ app template
app AMI
ASGs
trigger activation
Python Salt / Boto3
40 / 54© TNG Technology Consulting GmbH
Deployment – Third Party Services
Automating Deployment
Local Clouddevelopers
distributed instance
CI
Salt master
instance master
ELBs
Salt / ØMQ app template
app AMI
ASGsElasticache
Python Salt / Boto3trigger activation
41 / 54© TNG Technology Consulting GmbH
Automating Deployment – Lessons Learned
Know the capabilities and limits of the different services
►what scales and what does not scale
Integration of Ops tools in CI not trivial
►Salt Return Codes are “surprising”
Frequent deployments
►… are key to Reliability
Reliability
►… is key to frequent deployments
Automating Deployment
42 / 54© TNG Technology Consulting GmbH
What this talk is about
Introduction
Evolution towards fully automatic deployment
►Phase 1: Starting up
►Phase 2: Automating deployment to the Cloud
►Phase 3: Fully automated infrastructure setup
Remarks & Conclusions
Overview
43 / 54© TNG Technology Consulting GmbH
Fully automated Infrastructure Setup
„Click here for New Datacenter“
Trigger:
Separate testing and production into two accounts
►Restricting access to production to a team subset
Goal:
Define static infrastructure as code
Fully automated Infrastructure Setup
44 / 54© TNG Technology Consulting GmbH
Salt for Infrastructure – and its limits
Use and extend Salt fordynamic configuration ofinfrastructure:
DNS, ELB, ASG
Orchestration Scripts:
Deployment, Backup &Restore
Problem:
►Static Infrastructure
Fully automated Infrastructure Setup
#!python
import boto3#!python import boto3
#!python
import boto3
45 / 54© TNG Technology Consulting GmbH
Static Infrastructure (~200 Resources per App Instance)
Fully automated Infrastructure Setup
Local CloudDevOps team
CDN distributions
Route53 DNS Zones
S3 Storage
multiple Acounts
multiple VPCsinternet / NAT / VPN
gateways
VPN connections
routing / subnets
SEIPs, Security Groups
46 / 54© TNG Technology Consulting GmbH
Terraforming the Static Infrastructure
Fully automated Infrastructure Setup
Local CloudDevOps team
CDN distributions
Route53 DNS Zones
S3 Storage
multiple Acounts
multiple VPCs
AWS API
internet / NAT / VPN gateways
VPN connections
routing / subnets
SEIPs, Security Groups
47 / 54© TNG Technology Consulting GmbH
Terraform in Action
Fully automated Infrastructure Setup
$ terraform plan
$ terraform apply
Differences to SaltStack:
Keeps track of state
Implicit dependencies by referencing resources
Plan changes beforehand to avoid disruption
resource "aws_vpc" "main" { cidr_block = "10.1.0.0/16" tags { Name = "Testing" }}
resource "aws_internet_gateway" "gw" { vpc_id = "${aws_vpc.main.id}"}
resource "aws_vpc" "main" { cidr_block = "10.1.0.0/16" tags { Name = "Testing" }}
resource "aws_internet_gateway" "gw" { vpc_id = "${aws_vpc.main.id}"}
48 / 54© TNG Technology Consulting GmbH
Terraform – Lessons Learned
Modularize: Keep testing andproduction as similar as possible
Fully automated Infrastructure Setup
Make sure you check the documentationthat the features you require are there.
Terraform enabled us to easily manage~200 resources and ~500 dependencies.
49 / 54© TNG Technology Consulting GmbH
What this talk is about
Introduction
Evolution towards fully automatic deployment
Remarks & Conclusions
Overview
50 / 54© TNG Technology Consulting GmbH
Distribute Knowledge in the Team
Not all need in depth knowledge
►Two of us focus on CI/CD and infrastructure
Make deployment visible and accessible
► Jenkins pipelines everybody can use
►Check in deployment code into git
Simplify deployment wherever possible
Remarks & Conclusions
51 / 54© TNG Technology Consulting GmbH
Why Automating and DefiningInfrastructure as Code?
In software development...
… you test your code – right?
►Automatic & reproducible
… you review your code?
►Quality and Maintainability
So why is infrastructure often…
… not reviewed?
… not automatically tested?
… so broken?
Remarks & Conclusions
52 / 54© TNG Technology Consulting GmbH
We have the tools!
Let‘s go and fix this!
Automate!
Remarks & Conclusions
53 / 54© TNG Technology Consulting GmbH
Thank you for listening!
Questions?
54 / 54© TNG Technology Consulting GmbH
Contact
Martin Höfling
@martoss13
martinhoefling
Johannes Ebke
JohannesEbke