SlideShare a Scribd company logo
Adventures in
Containerization
Ryan Hunter
● SRE Lead @ TrueMotion
○ First Backend Engineer 3 years ago
○ Moved to operations in search of new
challenges!
● I’m an automation fanatic!
● When I’m not working to make on-call a
thing of the past, I enjoy:
○ Diving
○ Hiking
○ Building drones and other useless
contraptions in my basement
Pets Cattle A Herd
Servers as...
Infrastructure Evolves with a Company
Why did we Switch to Containers?
November 2016
3.05%
Why did we Switch to Containers?
● Debian based deploys
o Great so long as all you
dependencies were in debians too
● Ansible: Build the server from scratch
o External dependency hell
● Neither flexible or reliable
● Minimum provisioning size was too large
● A more flexible build artifact
● Decouple instance size from
application software
● A common, preloaded AMI could
be used to run all (most) services
Where we started... Where we wanted to go...
What did Docker give us?
●A flexible, portable, runtime artifact
■ Described runtime requirements
■ Memory/CPU requirements
●An ecosystem of tools to manage, version, and
develop these containers
What Docker didn’t give us
●Really nice match for stateless services
●Stateful containers ARE possible, but significantly
complicates scheduling
What Docker didn’t give us
●How do you…
...these containers?
○ schedule
○ provision
○ discover (and monitor)
○ configure
Schedule
Scheduling
Scheduling - Why ECS?
● Very basic (unopinionated)
● Amazon Support
● Amazon platform integration
○ IAM Roles
○ Cloudformation
Provision
Provision
Provision - Why Cloudformation
●Well integrated with AWS
●We can provision both docker containers and
infrastructure in one template (because we use
ECS)
●AWS Supported
●Parameter Validation
Provision - Why Cloudformation
Application CodeDependencies
Docker Container
Cloudformation
Template
Lambda Code
Lambda Zip
Package
Versioned Cloudformation Template
Deployed Cloudformation Stack
Develop
Build
Package
Deploy
Stamp Template
Each Service is deployed via a Cloudformation stack
Provision - Why Cloudformation
stacks:
- name: prod
template: prod-env
region: us-east-1
version: prod
parameters:
EIPList: <redacted>
EnvCIDR: 16
EnvMaturity: prod
PagerDutyKey: {{ pagerduty_key }}
RDSPassword: {{ rds_password }}
- name: prod-etl
template: dw-etl
region: us-east-1
version: "92"
parameters:
DesiredInstanceCount: 6
EnvironmentName: prod
EnvMaturity: prod
...
● Each service pushes a template with a name
and a version to S3
● That template has all the application
dependencies hardcoded (docker container
version, lambdas, etc)
● Each environment has its own repo containing
a deploy.yaml
Discover (and monitor)
Discover (and monitor)
●We use Registrator to join new containers to
consul
●Custom version that supports services without
exposed ports
●Loadbalancers (internal and external) are
configured via consul to route traffic to the
appropriate container
Monitor (Is my service up?)
●Consul Docker exec health checks
are very powerful
●Docker also has a new health check
API!
●Configured via Registrator
Consul Agent
My Service Container
health-check.py
My Service Check
Docker Host
Monitor (Logging)
●Sumo provides a docker log collector
●Wrote a script that fetches containers and assigns
source category based on the container type
●Runs as a container on each docker host
_sourceCategory = <Environment name>/<Service Name>/<Environment Maturity>
Monitor (Whitebox)
●Traffic - Requests per second, trips per second
●Errors - Rate of status codes and error logs
●Latency - How long does the service take to do a
unit of work
●Saturation - How do I know I need to scale out?
●Consul Check (is it up?)
Monitor (Whitebox)
●We have very similar services
■ Webservice (http)
■ Data pipeline (etl, trip processing)
●TruMonitor library
■ Common monitoring tools library
■ UNVERSIONED - controversial
Configure
Last Mile Configuration
●Cloudformation provides
a parameter interface
■ Pass on to container via
Environment Variables
■ AWS infrastructure can be
passed in directly
●Per Company Configs
■ Consul K/V + consul-template
stacks:
- name: prod
template: prod-env
region: us-east-1
version: prod
parameters:
EIPList: <redacted>
EnvCIDR: 16
EnvMaturity: prod
PagerDutyKey: {{ pagerduty_key }}
RDSPassword: {{ rds_password }}
...
Consul + Consul Template
Consul Cluster
Consul
Template
Config File
Application Process
Exec
PublishEntrypoint
Docker Container
● Great for configs to complex
for params
● Git2consul will sync configs
in VCS with cluster
● Parameter validation
matters!
■ Wrote SOME test
coverage using
JSONSchema
What about secrets storage?
●Initially used KMS Encrypted
values decrypted with consul-
template plugin
●DO NOT write consul template
plugins with blocking/high
latency calls
What we did instead
●Borrowed from the ansible-vault concept
●Encrypted “privates” file inside environment repo
●Populate cloudformation parameters using Jinja2
●Works well enough… will not work for per
company config values
Conclusions
●Developer training is hard: example repos work
REALLY well
●Secrets management requires some forethought
●Jenkins Pipelines is very powerful…
●Spend time automating creating and removing ECS
nodes
●Auto Scaling a docker cluster is nuanced!
Want to Help? We’re Hiring!
●I’m looking for backend software engineers with a
passion for automation
●Talk to me!
●… or https://gotruemotion.com/careers/
THANK YOU!
Reference
ECSScheduler
Consul
Registrator
Public LB
(Nginx)
Private LB
(Nginx)
Worker Nodes
Public API
Internal
API
ASG
High Level Arch
EC2 Instance
Today’s Pipeline
Build Scripts
Debian
Pip
Gemfury
Ansible EC2 Instance provision.py
● Inflexible
● Jobs managed
through UI
● Restricted
versioning
convention
● Supports only
specific
distro/version
● Pip doesn’t
enforce
dependencies
for crap!
● Gemfury goes
down!
● Instance config
is in a separate
repo from
service code
● We can’t
version
configuration
against services
● Lots of tight
coupling
between service
roles
● Fails a LOT!
● Services tied to
instance
● Instance type
for a service
defined globally
● Manual process
to provision
instances and
other AWS
resources
● AWS instance
provisioning is
entirely manual
● Difficult to
automate
● Too easy to
create and
forget about
instances
EC2 Instance
Cloudformation/Docker Pipeline
Jenkins
Pipelines
Docker
CF
Template
CF Pipeline
ECS Cluster
Environment
Config
● Resources
defined per
service
● Configs
validated per
service
● Leverage
docker as a
common
runtime
framework
● Build process
definition lives in
service repo
● Common
processes can
be defined via
global library
● Use docker to
provide build
dependencies
● Cloudformation
templates are
used as the
deployment
artifact
● Environment
updates via
code review
● Tight coupling
between resource
requirements and
resources
provisioned
● Ability to use spot
fleet/spot instances

More Related Content

PDF
Swarm migration
PDF
Getting started with kubernetes
PDF
Kubernetes Webinar Series - Understanding Service Discovery
PDF
Looking Under The Hood: containerD
PDF
Kubernetes in Docker
PDF
Kubernetes Webinar - Using ConfigMaps & Secrets
PDF
Enabling Security via Container Runtimes
PDF
Kubernetes Webinar Series - Exploring Daemon Sets and Jobs
Swarm migration
Getting started with kubernetes
Kubernetes Webinar Series - Understanding Service Discovery
Looking Under The Hood: containerD
Kubernetes in Docker
Kubernetes Webinar - Using ConfigMaps & Secrets
Enabling Security via Container Runtimes
Kubernetes Webinar Series - Exploring Daemon Sets and Jobs

What's hot (20)

PDF
A Closer Look at Kubernetes Pods and Replica Sets
PPTX
Kubernetes @ Squarespace: Kubernetes in the Datacenter
PDF
Everything you want to know about Ingress
PDF
Leveraging the Power of containerd Events - Evan Hazlett
PDF
Tupperware: Containerized Deployment at FB
PPTX
Introduction to kubernetes
PDF
Android Meets Docker
PDF
Platform Orchestration with Kubernetes and Docker
PDF
The Fairy Tale of the One Command Build Script
PPTX
Kubernetes and OpenStack at Scale
PDF
The (mutable) config management showdown
PDF
Kubernetes training
PDF
Securing Containerized Applications: A Primer
PDF
Cloud Native TLV Meetup: Securing Containerized Applications Primer
PDF
Ansible, integration testing, and you.
PDF
Scale out, with Kubernetes (k8s)
PPTX
The state of containerd
PPTX
Introduction to kubernetes
PDF
Introduction to Kubernetes Workshop
PPTX
K8s in 3h - Kubernetes Fundamentals Training
A Closer Look at Kubernetes Pods and Replica Sets
Kubernetes @ Squarespace: Kubernetes in the Datacenter
Everything you want to know about Ingress
Leveraging the Power of containerd Events - Evan Hazlett
Tupperware: Containerized Deployment at FB
Introduction to kubernetes
Android Meets Docker
Platform Orchestration with Kubernetes and Docker
The Fairy Tale of the One Command Build Script
Kubernetes and OpenStack at Scale
The (mutable) config management showdown
Kubernetes training
Securing Containerized Applications: A Primer
Cloud Native TLV Meetup: Securing Containerized Applications Primer
Ansible, integration testing, and you.
Scale out, with Kubernetes (k8s)
The state of containerd
Introduction to kubernetes
Introduction to Kubernetes Workshop
K8s in 3h - Kubernetes Fundamentals Training
Ad

Similar to Truemotion Adventures in Containerization (20)

PDF
State of Union - Containerz
PDF
Docker in Production: How RightScale Delivers Cloud Applications
PDF
56k.cloud training
PDF
2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
PDF
Dockercon eu tour 2015 - Devoxx Casablanca
PDF
Best practices in Deploying SUSE CaaS Platform v3
PDF
Docker Online Meetup #3: Docker in Production
PDF
Shipping Applications to Production in Containers with Docker
PDF
Securing the container DevOps pipeline by William Henry
PDF
AWS re:Invent re:Cap - 배포를 더욱 손쉽고 빠르게: Amazon EC2 Container Service - 김일호
PDF
Alibaba Cloud Conference 2016 - Docker Open Source
PDF
Setting up CI/CD Pipeline with Kubernetes and Kublr step by-step
PDF
Setting up CI/CD pipeline with Kubernetes and Kublr step-by-step
PPTX
Docker Demystified - Virtual VMs without the Fat
PPTX
Introduction to AWS and Docker on ECS
PDF
The AWS DevOps combo (January 2017)
PPTX
Docker Roadshow 2016
ODP
Docker in prod
ODP
The journey to container adoption in enterprise
PDF
Modernizing Java Apps with Docker
State of Union - Containerz
Docker in Production: How RightScale Delivers Cloud Applications
56k.cloud training
2016 - Easing Your Way Into Docker: Lessons From a Journey to Production
Dockercon eu tour 2015 - Devoxx Casablanca
Best practices in Deploying SUSE CaaS Platform v3
Docker Online Meetup #3: Docker in Production
Shipping Applications to Production in Containers with Docker
Securing the container DevOps pipeline by William Henry
AWS re:Invent re:Cap - 배포를 더욱 손쉽고 빠르게: Amazon EC2 Container Service - 김일호
Alibaba Cloud Conference 2016 - Docker Open Source
Setting up CI/CD Pipeline with Kubernetes and Kublr step by-step
Setting up CI/CD pipeline with Kubernetes and Kublr step-by-step
Docker Demystified - Virtual VMs without the Fat
Introduction to AWS and Docker on ECS
The AWS DevOps combo (January 2017)
Docker Roadshow 2016
Docker in prod
The journey to container adoption in enterprise
Modernizing Java Apps with Docker
Ad

Recently uploaded (20)

PDF
Well-logging-methods_new................
PDF
PPT on Performance Review to get promotions
PDF
Structs to JSON How Go Powers REST APIs.pdf
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Construction Project Organization Group 2.pptx
PDF
Digital Logic Computer Design lecture notes
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Geodesy 1.pptx...............................................
PPTX
Welding lecture in detail for understanding
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
Sustainable Sites - Green Building Construction
Well-logging-methods_new................
PPT on Performance Review to get promotions
Structs to JSON How Go Powers REST APIs.pdf
Model Code of Practice - Construction Work - 21102022 .pdf
Construction Project Organization Group 2.pptx
Digital Logic Computer Design lecture notes
Operating System & Kernel Study Guide-1 - converted.pdf
Embodied AI: Ushering in the Next Era of Intelligent Systems
CYBER-CRIMES AND SECURITY A guide to understanding
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Internet of Things (IOT) - A guide to understanding
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Geodesy 1.pptx...............................................
Welding lecture in detail for understanding
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Lesson 3_Tessellation.pptx finite Mathematics
Arduino robotics embedded978-1-4302-3184-4.pdf
Sustainable Sites - Green Building Construction

Truemotion Adventures in Containerization

  • 2. Ryan Hunter ● SRE Lead @ TrueMotion ○ First Backend Engineer 3 years ago ○ Moved to operations in search of new challenges! ● I’m an automation fanatic! ● When I’m not working to make on-call a thing of the past, I enjoy: ○ Diving ○ Hiking ○ Building drones and other useless contraptions in my basement
  • 3. Pets Cattle A Herd Servers as... Infrastructure Evolves with a Company
  • 4. Why did we Switch to Containers? November 2016 3.05%
  • 5. Why did we Switch to Containers? ● Debian based deploys o Great so long as all you dependencies were in debians too ● Ansible: Build the server from scratch o External dependency hell ● Neither flexible or reliable ● Minimum provisioning size was too large ● A more flexible build artifact ● Decouple instance size from application software ● A common, preloaded AMI could be used to run all (most) services Where we started... Where we wanted to go...
  • 6. What did Docker give us? ●A flexible, portable, runtime artifact ■ Described runtime requirements ■ Memory/CPU requirements ●An ecosystem of tools to manage, version, and develop these containers
  • 7. What Docker didn’t give us ●Really nice match for stateless services ●Stateful containers ARE possible, but significantly complicates scheduling
  • 8. What Docker didn’t give us ●How do you… ...these containers? ○ schedule ○ provision ○ discover (and monitor) ○ configure
  • 11. Scheduling - Why ECS? ● Very basic (unopinionated) ● Amazon Support ● Amazon platform integration ○ IAM Roles ○ Cloudformation
  • 14. Provision - Why Cloudformation ●Well integrated with AWS ●We can provision both docker containers and infrastructure in one template (because we use ECS) ●AWS Supported ●Parameter Validation
  • 15. Provision - Why Cloudformation Application CodeDependencies Docker Container Cloudformation Template Lambda Code Lambda Zip Package Versioned Cloudformation Template Deployed Cloudformation Stack Develop Build Package Deploy Stamp Template Each Service is deployed via a Cloudformation stack
  • 16. Provision - Why Cloudformation stacks: - name: prod template: prod-env region: us-east-1 version: prod parameters: EIPList: <redacted> EnvCIDR: 16 EnvMaturity: prod PagerDutyKey: {{ pagerduty_key }} RDSPassword: {{ rds_password }} - name: prod-etl template: dw-etl region: us-east-1 version: "92" parameters: DesiredInstanceCount: 6 EnvironmentName: prod EnvMaturity: prod ... ● Each service pushes a template with a name and a version to S3 ● That template has all the application dependencies hardcoded (docker container version, lambdas, etc) ● Each environment has its own repo containing a deploy.yaml
  • 18. Discover (and monitor) ●We use Registrator to join new containers to consul ●Custom version that supports services without exposed ports ●Loadbalancers (internal and external) are configured via consul to route traffic to the appropriate container
  • 19. Monitor (Is my service up?) ●Consul Docker exec health checks are very powerful ●Docker also has a new health check API! ●Configured via Registrator Consul Agent My Service Container health-check.py My Service Check Docker Host
  • 20. Monitor (Logging) ●Sumo provides a docker log collector ●Wrote a script that fetches containers and assigns source category based on the container type ●Runs as a container on each docker host _sourceCategory = <Environment name>/<Service Name>/<Environment Maturity>
  • 21. Monitor (Whitebox) ●Traffic - Requests per second, trips per second ●Errors - Rate of status codes and error logs ●Latency - How long does the service take to do a unit of work ●Saturation - How do I know I need to scale out? ●Consul Check (is it up?)
  • 22. Monitor (Whitebox) ●We have very similar services ■ Webservice (http) ■ Data pipeline (etl, trip processing) ●TruMonitor library ■ Common monitoring tools library ■ UNVERSIONED - controversial
  • 24. Last Mile Configuration ●Cloudformation provides a parameter interface ■ Pass on to container via Environment Variables ■ AWS infrastructure can be passed in directly ●Per Company Configs ■ Consul K/V + consul-template stacks: - name: prod template: prod-env region: us-east-1 version: prod parameters: EIPList: <redacted> EnvCIDR: 16 EnvMaturity: prod PagerDutyKey: {{ pagerduty_key }} RDSPassword: {{ rds_password }} ...
  • 25. Consul + Consul Template Consul Cluster Consul Template Config File Application Process Exec PublishEntrypoint Docker Container ● Great for configs to complex for params ● Git2consul will sync configs in VCS with cluster ● Parameter validation matters! ■ Wrote SOME test coverage using JSONSchema
  • 26. What about secrets storage? ●Initially used KMS Encrypted values decrypted with consul- template plugin ●DO NOT write consul template plugins with blocking/high latency calls
  • 27. What we did instead ●Borrowed from the ansible-vault concept ●Encrypted “privates” file inside environment repo ●Populate cloudformation parameters using Jinja2 ●Works well enough… will not work for per company config values
  • 28. Conclusions ●Developer training is hard: example repos work REALLY well ●Secrets management requires some forethought ●Jenkins Pipelines is very powerful… ●Spend time automating creating and removing ECS nodes ●Auto Scaling a docker cluster is nuanced!
  • 29. Want to Help? We’re Hiring! ●I’m looking for backend software engineers with a passion for automation ●Talk to me! ●… or https://gotruemotion.com/careers/
  • 32. ECSScheduler Consul Registrator Public LB (Nginx) Private LB (Nginx) Worker Nodes Public API Internal API ASG High Level Arch
  • 33. EC2 Instance Today’s Pipeline Build Scripts Debian Pip Gemfury Ansible EC2 Instance provision.py ● Inflexible ● Jobs managed through UI ● Restricted versioning convention ● Supports only specific distro/version ● Pip doesn’t enforce dependencies for crap! ● Gemfury goes down! ● Instance config is in a separate repo from service code ● We can’t version configuration against services ● Lots of tight coupling between service roles ● Fails a LOT! ● Services tied to instance ● Instance type for a service defined globally ● Manual process to provision instances and other AWS resources ● AWS instance provisioning is entirely manual ● Difficult to automate ● Too easy to create and forget about instances
  • 34. EC2 Instance Cloudformation/Docker Pipeline Jenkins Pipelines Docker CF Template CF Pipeline ECS Cluster Environment Config ● Resources defined per service ● Configs validated per service ● Leverage docker as a common runtime framework ● Build process definition lives in service repo ● Common processes can be defined via global library ● Use docker to provide build dependencies ● Cloudformation templates are used as the deployment artifact ● Environment updates via code review ● Tight coupling between resource requirements and resources provisioned ● Ability to use spot fleet/spot instances