SlideShare a Scribd company logo
1 of 52
Immutable Infrastructure as Code.
True story.
Vladlen Fedosov, Director of R&D @Namecheap, Inc
Vladlen Fedosov
Director of R&D @Namecheap
TL;DR:

• 10 years in the industry

• Went path from Junior to Architect 

• Amateur DevOps evangelist 

• AWS ninja

• Believe in self-organized, cross-functional teams
“Opening the door for
everyone to a free and
open Internet”
The beginning
Disclaimer: Here I’m talking mostly about my experience and part of the infrastructure that my team
was responsible for. So further statements may not apply to every department in the company. Timeline for the things
mentioned below was changes to simplify storytelling.
Project takeover from outsourcing company
Brave New World
For a small dev team with no infra support / capabilities
So what do we have now?
State of the project after takeover
● Half broken Chef cookbooks

● Sketchy CD pipelines

● Fault tolerance in place

● And… Everything went down after failure of the single (out of 3)
etcd node. We realized that we have fault tolerance only on paper
After some refactoring… We’ve got typical setup
Issues we noticed
- Multiple apps were sharing same OS, language versions, dependencies
- Horizontal scaling was hard

- Sometimes failing chef scripts on random instances mostly due to network
errors & configuration differences
Configuration Synchronisation problem, in short
martinfowler.com/bliki/ConfigurationSynchronization.html
Issues we noticed
- Manual sync of the AWS setup between environments

- Manually configured CI/CD

- Easy to break something and hard to repair or modify anything
Blue sky vision
● Immutable infrastructure
● Everything as code
○ Infrastructure as code

○ CI/CD as code
Blue sky vision
● Hard to break
● Easy to repair
● Easy to modify
Immutable infrastructure
+ extra takeaways
What is immutable infrastructure?
martinfowler.com/bliki/ImmutableServer.html
Why go Immutable?
● Forget about change flow, only “create” matters

● Defeat Configuration Drift

● Use much simpler tools

● Build highly available systems easier

● Fix issues faster
How to achieve this?
● Complexity → Docker (or AMI) images

● OS → Docker runtime only

● App/OS configuration methods:

○ K8s pod definitions (or similar)

○ “cloud-init”

● Terraform to define “datacenter config”
Main tools we use
● AMI images & Docker images

● Cloud-Init (98%)

● Hashicorp Packer (2%)

● Terraform, Terraform everywhere
Single fact you could memorise here
Immutable Infrastructure allows you to significantly simplify
management steps and consequently reduce number of
bugs your customers will face with. Work with images rather
than servers.
CI/CD as code
Everything as code: full list
● Everything as code, it supports:
○ job steps definition as code (via pipelines)

○ jobs creation as code (via job dsl)

○ system configuration as code (via groovy API, XML configs & CasC yml)

● Shared libraries, ability to share common steps between apps
P.S: Talk to me if know better alternative ;)
Other factors influenced the choice
● Has deployment dashboard so we can see the state of all the
environments
● Highly extensible
● Elastic EC2 instances as agents
Nowadays
● It went beyond one project and now almost every team at Namecheap uses it

● 300+ pipelines

● Around 38 projects

● We expect even more in the future
Nowadays: CI
@Library('namecheap/common') _
node('CommonCLarge') {
ciJavascript.servicePipeline {
productName = "ProductA"
serviceName = "Apps.Api"
}
}
Nowadays: CD
@Library('namecheap/common') _
properties([parameters([
string(name: 'image', description: 'Application container name'),
string(name: 'version', description: 'Application container tag'),
choice(choices: ['production', 'sandbox'], description: 'Environment', name: 'env')
])])
node() {
def authToken = "XXXX"
stage('Deploy') {
deployToOKD(params, authToken)
}
}
Lessons learned
● Hide all complexity inside. Provide as much logic as you can in a form of
Shared Libraries. 

● Documentation & examples are crucial for developers

● If possible - provide standardized pipelines invoked as Shared Library
function

● It takes about 1.5 months for 2 people to setup Jenkins properly for the first
time
Single fact you could memorise here
Always keep your CI/CD configuration, written as code,
near the app, in the same repo. It will give an understanding
to everyone in your company on how to build & deploy any
app.
Infrastructure as code: Terraform
How Terraform is different to Ansible/Chef/Puppet
Terraform is not a configuration management tool. It focuses on the higher-level
abstraction of the datacenter (or cloud provider), without sacrificing the ability to
use configuration management tools to do what they do best: bootstrapping
and initializing resources.
resource "aws_instance" "web" {
ami = "ami-dbc3b9aa"
instance_type = "t2.micro"
}
Imperative VS Declarative infrastructure code
Declarative
“Can I have a cup of coffee on my
desk at 9AM on Monday morning?”
Imperative
“Go to that machine, then get the
glass jar, then fill it with water, then
put it back in the machine” 

…you get the idea...
Why go Declarative?
Key challenges this approach solves for us:

● Dealing with “Configuration Drift” / State management

● Idempotency

● Dependency graph management, correct order of operations
Terraform CI
Try now:

https://www.runatlantis.io/ 

https://app.terraform.io/
Deploy with Terraform
What we had:
1. Write TF configs

2. Run TF to create infrastructure

3. Take TF outputs & enter them to
Jenkins

4. Deploy app itself with Jenkins
What we wanted to have:
1. Write TF configs

2. Deploy app
Deploy with Terraform
Deploy with Terraform
!"" vars <-- Environment specific variables
# !"" production.tfvars
# !"" staging.tfvars
!"" main.tf
!"" io.tf
!"" db.tf
!"" etc.tf
Single fact you could memorize here
Try to have as much declarative infrastructure configs as
you can, avoid imperative scripts at all cost.
Learnings & further improvements
Tests for infrastructure code
The more infrastructure code you have - the more bugs you see.
Chaos monkey
We wrote a Lambda that randomly reboots every instance once a day. This
simple tweak ensures that:

● Apps you launch can survive instance failure

● Updates to the cluster setup is easy as you’re sure that you won’t harm
anyone by killing outdated machines

● Problem resolution can be simpler sometimes. You can always reboot/kill any
instance that behaves abnormally as a first action

Apply this to control fleet too
No SSH keys distribution over instances
● If you’re using AWS - simply install SSM agent to your instances and disable
SSH daemon. You will be able to use SSH console to perform your
administrative actions.

● If you’re not in AWS - you can use Hashicorp Vault. It provides you with
SSH backend that allows central management & audit of the login identities.
Things that work for 3 teams - doesn’t work for 10
Issues
# of users
Key learnings here:
● Operational work grows exponentially the more teams you add 

● 1 new tool/approach for devs at a time

● Conduct educational courses for big new things like Docker, AWS, Terraform

● Gain trust within the team you’re challenging with a change first

● Documentation is paramount, start it as early as possible
Things that work for 3 teams - doesn’t work for 10
DevOps on Call & transparent SLAs
● We’ve established “on call” schedule 

● Agreed on SLAs & shared then among the teams

● Created chat room & Jira board

Result: significant reduction of the distraction level, better productivity, happier
teams
Even you’re doing good now, you can make it even better with this practice
Encourage feedback
● Ask for it proactively, show that it's important for you

● Public retrospectives

● Respond to the feedback
Summing up
What we’ve achieved
● Immutable infrastructure (done)
○ ECS with immutable data plane

○ Immutable EC2 instances for stateful instances

● Everything as code (done)
○ Infrastructure as code: Terraform, Cloud-init

○ CI/CD as code: Jenkins

Now it’s hard to break & easy to repair things as well as

easy to track changes.
Vlad Fedosov
Director of R&D
@Namecheap, Inc
vlad.fedosov@gmail.com
Or just scan it:
Evolving Terraform experience

More Related Content

What's hot

Devops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShiftDevops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShiftYaniv cohen
 
Infrastructure as Code for Network
Infrastructure as Code for NetworkInfrastructure as Code for Network
Infrastructure as Code for NetworkDamien Garros
 
Puppet overview
Puppet overviewPuppet overview
Puppet overviewjoshbeard
 
Continuous integration of_puppet_code
Continuous integration of_puppet_codeContinuous integration of_puppet_code
Continuous integration of_puppet_codeDevoteam Revolve
 
DevOps Summit 2016 - The immutable Journey
DevOps Summit 2016 - The immutable JourneyDevOps Summit 2016 - The immutable Journey
DevOps Summit 2016 - The immutable Journeysmalltown
 
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...Puppet
 
DevTernity - DevOps with smell
DevTernity - DevOps with smellDevTernity - DevOps with smell
DevTernity - DevOps with smellAntons Kranga
 
Rule jenkins with configuration as code
Rule jenkins with configuration as codeRule jenkins with configuration as code
Rule jenkins with configuration as codeChristian Rasp
 
Immutable Infrastructure: the new App Deployment
Immutable Infrastructure: the new App DeploymentImmutable Infrastructure: the new App Deployment
Immutable Infrastructure: the new App DeploymentAxel Fontaine
 
CommandBox & ForgeBox Package Management
CommandBox & ForgeBox Package ManagementCommandBox & ForgeBox Package Management
CommandBox & ForgeBox Package ManagementOrtus Solutions, Corp
 
Continuous Deployment with Cloud Foundry, Github and Travis CI
Continuous Deployment with Cloud Foundry, Github and Travis CIContinuous Deployment with Cloud Foundry, Github and Travis CI
Continuous Deployment with Cloud Foundry, Github and Travis CIPlatform CF
 
Drupal Deployment
Drupal DeploymentDrupal Deployment
Drupal DeploymentJeff Eaton
 
Puppet Camp Charlotte 2015: Manage Your Switches Like Servers
Puppet Camp Charlotte 2015: Manage Your Switches Like ServersPuppet Camp Charlotte 2015: Manage Your Switches Like Servers
Puppet Camp Charlotte 2015: Manage Your Switches Like ServersPuppet
 
ContainerCon - Test Driven Infrastructure
ContainerCon - Test Driven InfrastructureContainerCon - Test Driven Infrastructure
ContainerCon - Test Driven InfrastructureYury Tsarev
 
John Adams Puppet Camp 2010
John Adams Puppet Camp 2010John Adams Puppet Camp 2010
John Adams Puppet Camp 2010Puppet
 
Implementing blue-green deployment with Atlassian Bamboo
Implementing blue-green deployment with Atlassian BambooImplementing blue-green deployment with Atlassian Bamboo
Implementing blue-green deployment with Atlassian BambooDave Clark
 

What's hot (20)

Devops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShiftDevops with Python by Yaniv Cohen DevopShift
Devops with Python by Yaniv Cohen DevopShift
 
Infrastructure as Code for Network
Infrastructure as Code for NetworkInfrastructure as Code for Network
Infrastructure as Code for Network
 
Puppet overview
Puppet overviewPuppet overview
Puppet overview
 
Continuous integration of_puppet_code
Continuous integration of_puppet_codeContinuous integration of_puppet_code
Continuous integration of_puppet_code
 
DevOps Summit 2016 - The immutable Journey
DevOps Summit 2016 - The immutable JourneyDevOps Summit 2016 - The immutable Journey
DevOps Summit 2016 - The immutable Journey
 
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...
 
Devops For Drupal
Devops  For DrupalDevops  For Drupal
Devops For Drupal
 
Is Python still production ready ? Ludovic Gasc
Is Python still production ready ? Ludovic GascIs Python still production ready ? Ludovic Gasc
Is Python still production ready ? Ludovic Gasc
 
DevTernity - DevOps with smell
DevTernity - DevOps with smellDevTernity - DevOps with smell
DevTernity - DevOps with smell
 
Rule jenkins with configuration as code
Rule jenkins with configuration as codeRule jenkins with configuration as code
Rule jenkins with configuration as code
 
Immutable Infrastructure: the new App Deployment
Immutable Infrastructure: the new App DeploymentImmutable Infrastructure: the new App Deployment
Immutable Infrastructure: the new App Deployment
 
CommandBox & ForgeBox Package Management
CommandBox & ForgeBox Package ManagementCommandBox & ForgeBox Package Management
CommandBox & ForgeBox Package Management
 
Continuous Deployment with Cloud Foundry, Github and Travis CI
Continuous Deployment with Cloud Foundry, Github and Travis CIContinuous Deployment with Cloud Foundry, Github and Travis CI
Continuous Deployment with Cloud Foundry, Github and Travis CI
 
From VB Script to PowerShell
From VB Script to PowerShellFrom VB Script to PowerShell
From VB Script to PowerShell
 
Drupal Deployment
Drupal DeploymentDrupal Deployment
Drupal Deployment
 
Puppet Camp Charlotte 2015: Manage Your Switches Like Servers
Puppet Camp Charlotte 2015: Manage Your Switches Like ServersPuppet Camp Charlotte 2015: Manage Your Switches Like Servers
Puppet Camp Charlotte 2015: Manage Your Switches Like Servers
 
PS scripting and modularization
PS scripting and modularizationPS scripting and modularization
PS scripting and modularization
 
ContainerCon - Test Driven Infrastructure
ContainerCon - Test Driven InfrastructureContainerCon - Test Driven Infrastructure
ContainerCon - Test Driven Infrastructure
 
John Adams Puppet Camp 2010
John Adams Puppet Camp 2010John Adams Puppet Camp 2010
John Adams Puppet Camp 2010
 
Implementing blue-green deployment with Atlassian Bamboo
Implementing blue-green deployment with Atlassian BambooImplementing blue-green deployment with Atlassian Bamboo
Implementing blue-green deployment with Atlassian Bamboo
 

Similar to Immutable Infrastructure as Code True Story

Successful DevOps implementation for small teams a true story
Successful DevOps implementation for small teams  a true storySuccessful DevOps implementation for small teams  a true story
Successful DevOps implementation for small teams a true storyJakub Paweł Głazik
 
Using Docker EE to Scale Operational Intelligence at Splunk
Using Docker EE to Scale Operational Intelligence at SplunkUsing Docker EE to Scale Operational Intelligence at Splunk
Using Docker EE to Scale Operational Intelligence at SplunkDocker, Inc.
 
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...Richard Bullington-McGuire
 
Meetup 2020 - Back to the Basics part 101 : IaC
Meetup 2020 - Back to the Basics part 101 : IaCMeetup 2020 - Back to the Basics part 101 : IaC
Meetup 2020 - Back to the Basics part 101 : IaCDamienCarpy
 
DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...
DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...
DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...Haggai Philip Zagury
 
Product! - The road to production deployment
Product! - The road to production deploymentProduct! - The road to production deployment
Product! - The road to production deploymentFilippo Zanella
 
Continuos Integration and Delivery: from Zero to Hero with TeamCity, Docker a...
Continuos Integration and Delivery: from Zero to Hero with TeamCity, Docker a...Continuos Integration and Delivery: from Zero to Hero with TeamCity, Docker a...
Continuos Integration and Delivery: from Zero to Hero with TeamCity, Docker a...Lean IT Consulting
 
The "Holy Grail" of Dev/Ops
The "Holy Grail" of Dev/OpsThe "Holy Grail" of Dev/Ops
The "Holy Grail" of Dev/OpsErik Osterman
 
JUST EAT: Embracing DevOps
JUST EAT: Embracing DevOpsJUST EAT: Embracing DevOps
JUST EAT: Embracing DevOpsPeter Mounce
 
Kubernetes, Toolbox to fail or succeed for beginners - Demi Ben-Ari, VP R&D @...
Kubernetes, Toolbox to fail or succeed for beginners - Demi Ben-Ari, VP R&D @...Kubernetes, Toolbox to fail or succeed for beginners - Demi Ben-Ari, VP R&D @...
Kubernetes, Toolbox to fail or succeed for beginners - Demi Ben-Ari, VP R&D @...Demi Ben-Ari
 
Scalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUs
Scalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUsScalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUs
Scalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUsIndrajit Poddar
 
Confoo-Montreal-2016: Controlling Your Environments using Infrastructure as Code
Confoo-Montreal-2016: Controlling Your Environments using Infrastructure as CodeConfoo-Montreal-2016: Controlling Your Environments using Infrastructure as Code
Confoo-Montreal-2016: Controlling Your Environments using Infrastructure as CodeSteve Mercier
 
How Percolate uses CFEngine to Manage AWS Stateless Infrastructure
How Percolate uses CFEngine to Manage AWS Stateless InfrastructureHow Percolate uses CFEngine to Manage AWS Stateless Infrastructure
How Percolate uses CFEngine to Manage AWS Stateless InfrastructurePercolate
 
Drupal 8 DevOps . Profile and SQL flows.
Drupal 8 DevOps . Profile and SQL flows.Drupal 8 DevOps . Profile and SQL flows.
Drupal 8 DevOps . Profile and SQL flows.Andrii Podanenko
 
Normalizing x pages web development
Normalizing x pages web development Normalizing x pages web development
Normalizing x pages web development Shean McManus
 
[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...
[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...
[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...Ambassador Labs
 
Devops interview questions 1 www.bigclasses.com
Devops interview questions  1  www.bigclasses.comDevops interview questions  1  www.bigclasses.com
Devops interview questions 1 www.bigclasses.combigclasses.com
 

Similar to Immutable Infrastructure as Code True Story (20)

Successful DevOps implementation for small teams a true story
Successful DevOps implementation for small teams  a true storySuccessful DevOps implementation for small teams  a true story
Successful DevOps implementation for small teams a true story
 
Docker in Production at the Aurora Team
Docker in Production at the Aurora TeamDocker in Production at the Aurora Team
Docker in Production at the Aurora Team
 
Using Docker EE to Scale Operational Intelligence at Splunk
Using Docker EE to Scale Operational Intelligence at SplunkUsing Docker EE to Scale Operational Intelligence at Splunk
Using Docker EE to Scale Operational Intelligence at Splunk
 
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
 
Meetup 2020 - Back to the Basics part 101 : IaC
Meetup 2020 - Back to the Basics part 101 : IaCMeetup 2020 - Back to the Basics part 101 : IaC
Meetup 2020 - Back to the Basics part 101 : IaC
 
DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...
DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...
DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...
 
Old Is the New New
Old Is the New NewOld Is the New New
Old Is the New New
 
Product! - The road to production deployment
Product! - The road to production deploymentProduct! - The road to production deployment
Product! - The road to production deployment
 
Continuos Integration and Delivery: from Zero to Hero with TeamCity, Docker a...
Continuos Integration and Delivery: from Zero to Hero with TeamCity, Docker a...Continuos Integration and Delivery: from Zero to Hero with TeamCity, Docker a...
Continuos Integration and Delivery: from Zero to Hero with TeamCity, Docker a...
 
The "Holy Grail" of Dev/Ops
The "Holy Grail" of Dev/OpsThe "Holy Grail" of Dev/Ops
The "Holy Grail" of Dev/Ops
 
JUST EAT: Embracing DevOps
JUST EAT: Embracing DevOpsJUST EAT: Embracing DevOps
JUST EAT: Embracing DevOps
 
Kubernetes, Toolbox to fail or succeed for beginners - Demi Ben-Ari, VP R&D @...
Kubernetes, Toolbox to fail or succeed for beginners - Demi Ben-Ari, VP R&D @...Kubernetes, Toolbox to fail or succeed for beginners - Demi Ben-Ari, VP R&D @...
Kubernetes, Toolbox to fail or succeed for beginners - Demi Ben-Ari, VP R&D @...
 
Scalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUs
Scalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUsScalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUs
Scalable TensorFlow Deep Learning as a Service with Docker, OpenPOWER, and GPUs
 
Confoo-Montreal-2016: Controlling Your Environments using Infrastructure as Code
Confoo-Montreal-2016: Controlling Your Environments using Infrastructure as CodeConfoo-Montreal-2016: Controlling Your Environments using Infrastructure as Code
Confoo-Montreal-2016: Controlling Your Environments using Infrastructure as Code
 
How Percolate uses CFEngine to Manage AWS Stateless Infrastructure
How Percolate uses CFEngine to Manage AWS Stateless InfrastructureHow Percolate uses CFEngine to Manage AWS Stateless Infrastructure
How Percolate uses CFEngine to Manage AWS Stateless Infrastructure
 
Drupal 8 DevOps . Profile and SQL flows.
Drupal 8 DevOps . Profile and SQL flows.Drupal 8 DevOps . Profile and SQL flows.
Drupal 8 DevOps . Profile and SQL flows.
 
Normalizing x pages web development
Normalizing x pages web development Normalizing x pages web development
Normalizing x pages web development
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...
[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...
[KubeCon NA 2018] Telepresence Deep Dive Session - Rafael Schloming & Luke Sh...
 
Devops interview questions 1 www.bigclasses.com
Devops interview questions  1  www.bigclasses.comDevops interview questions  1  www.bigclasses.com
Devops interview questions 1 www.bigclasses.com
 

More from Vlad Fedosov

OdessaJs 2020 - How to build your first micro frontend in a matter of minutes
OdessaJs 2020 - How to build your first micro frontend in a matter of minutesOdessaJs 2020 - How to build your first micro frontend in a matter of minutes
OdessaJs 2020 - How to build your first micro frontend in a matter of minutesVlad Fedosov
 
Maximizing your professional value, from junior to leader
Maximizing your professional value, from junior to leaderMaximizing your professional value, from junior to leader
Maximizing your professional value, from junior to leaderVlad Fedosov
 
XP Days 2019: First secret delivery for modern cloud-native applications
XP Days 2019: First secret delivery for modern cloud-native applicationsXP Days 2019: First secret delivery for modern cloud-native applications
XP Days 2019: First secret delivery for modern cloud-native applicationsVlad Fedosov
 
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendVlad Fedosov
 
LvivCSS: Web Components as a foundation for Design System
LvivCSS: Web Components as a foundation for Design SystemLvivCSS: Web Components as a foundation for Design System
LvivCSS: Web Components as a foundation for Design SystemVlad Fedosov
 
KharkivJS: Flaws of the Web Components in 2019 and how to address them
KharkivJS: Flaws of the Web Components in 2019 and how to address themKharkivJS: Flaws of the Web Components in 2019 and how to address them
KharkivJS: Flaws of the Web Components in 2019 and how to address themVlad Fedosov
 

More from Vlad Fedosov (6)

OdessaJs 2020 - How to build your first micro frontend in a matter of minutes
OdessaJs 2020 - How to build your first micro frontend in a matter of minutesOdessaJs 2020 - How to build your first micro frontend in a matter of minutes
OdessaJs 2020 - How to build your first micro frontend in a matter of minutes
 
Maximizing your professional value, from junior to leader
Maximizing your professional value, from junior to leaderMaximizing your professional value, from junior to leader
Maximizing your professional value, from junior to leader
 
XP Days 2019: First secret delivery for modern cloud-native applications
XP Days 2019: First secret delivery for modern cloud-native applicationsXP Days 2019: First secret delivery for modern cloud-native applications
XP Days 2019: First secret delivery for modern cloud-native applications
 
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontend
 
LvivCSS: Web Components as a foundation for Design System
LvivCSS: Web Components as a foundation for Design SystemLvivCSS: Web Components as a foundation for Design System
LvivCSS: Web Components as a foundation for Design System
 
KharkivJS: Flaws of the Web Components in 2019 and how to address them
KharkivJS: Flaws of the Web Components in 2019 and how to address themKharkivJS: Flaws of the Web Components in 2019 and how to address them
KharkivJS: Flaws of the Web Components in 2019 and how to address them
 

Recently uploaded

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 

Recently uploaded (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

Immutable Infrastructure as Code True Story

  • 1. Immutable Infrastructure as Code. True story. Vladlen Fedosov, Director of R&D @Namecheap, Inc
  • 2. Vladlen Fedosov Director of R&D @Namecheap TL;DR: • 10 years in the industry • Went path from Junior to Architect  • Amateur DevOps evangelist  • AWS ninja • Believe in self-organized, cross-functional teams
  • 3. “Opening the door for everyone to a free and open Internet”
  • 4. The beginning Disclaimer: Here I’m talking mostly about my experience and part of the infrastructure that my team was responsible for. So further statements may not apply to every department in the company. Timeline for the things mentioned below was changes to simplify storytelling.
  • 5.
  • 6. Project takeover from outsourcing company
  • 7. Brave New World For a small dev team with no infra support / capabilities
  • 8. So what do we have now?
  • 9. State of the project after takeover ● Half broken Chef cookbooks ● Sketchy CD pipelines ● Fault tolerance in place ● And… Everything went down after failure of the single (out of 3) etcd node. We realized that we have fault tolerance only on paper
  • 10. After some refactoring… We’ve got typical setup
  • 11. Issues we noticed - Multiple apps were sharing same OS, language versions, dependencies - Horizontal scaling was hard - Sometimes failing chef scripts on random instances mostly due to network errors & configuration differences
  • 12. Configuration Synchronisation problem, in short martinfowler.com/bliki/ConfigurationSynchronization.html
  • 13. Issues we noticed - Manual sync of the AWS setup between environments - Manually configured CI/CD - Easy to break something and hard to repair or modify anything
  • 14. Blue sky vision ● Immutable infrastructure ● Everything as code ○ Infrastructure as code ○ CI/CD as code
  • 15. Blue sky vision ● Hard to break ● Easy to repair ● Easy to modify
  • 17. What is immutable infrastructure? martinfowler.com/bliki/ImmutableServer.html
  • 18. Why go Immutable? ● Forget about change flow, only “create” matters ● Defeat Configuration Drift ● Use much simpler tools ● Build highly available systems easier ● Fix issues faster
  • 19. How to achieve this? ● Complexity → Docker (or AMI) images ● OS → Docker runtime only ● App/OS configuration methods: ○ K8s pod definitions (or similar) ○ “cloud-init” ● Terraform to define “datacenter config”
  • 20. Main tools we use ● AMI images & Docker images ● Cloud-Init (98%) ● Hashicorp Packer (2%) ● Terraform, Terraform everywhere
  • 21. Single fact you could memorise here Immutable Infrastructure allows you to significantly simplify management steps and consequently reduce number of bugs your customers will face with. Work with images rather than servers.
  • 23.
  • 24.
  • 25. Everything as code: full list ● Everything as code, it supports: ○ job steps definition as code (via pipelines) ○ jobs creation as code (via job dsl) ○ system configuration as code (via groovy API, XML configs & CasC yml) ● Shared libraries, ability to share common steps between apps P.S: Talk to me if know better alternative ;)
  • 26. Other factors influenced the choice ● Has deployment dashboard so we can see the state of all the environments ● Highly extensible ● Elastic EC2 instances as agents
  • 27. Nowadays ● It went beyond one project and now almost every team at Namecheap uses it ● 300+ pipelines ● Around 38 projects ● We expect even more in the future
  • 28. Nowadays: CI @Library('namecheap/common') _ node('CommonCLarge') { ciJavascript.servicePipeline { productName = "ProductA" serviceName = "Apps.Api" } }
  • 29. Nowadays: CD @Library('namecheap/common') _ properties([parameters([ string(name: 'image', description: 'Application container name'), string(name: 'version', description: 'Application container tag'), choice(choices: ['production', 'sandbox'], description: 'Environment', name: 'env') ])]) node() { def authToken = "XXXX" stage('Deploy') { deployToOKD(params, authToken) } }
  • 30. Lessons learned ● Hide all complexity inside. Provide as much logic as you can in a form of Shared Libraries. ● Documentation & examples are crucial for developers ● If possible - provide standardized pipelines invoked as Shared Library function ● It takes about 1.5 months for 2 people to setup Jenkins properly for the first time
  • 31. Single fact you could memorise here Always keep your CI/CD configuration, written as code, near the app, in the same repo. It will give an understanding to everyone in your company on how to build & deploy any app.
  • 33. How Terraform is different to Ansible/Chef/Puppet Terraform is not a configuration management tool. It focuses on the higher-level abstraction of the datacenter (or cloud provider), without sacrificing the ability to use configuration management tools to do what they do best: bootstrapping and initializing resources. resource "aws_instance" "web" { ami = "ami-dbc3b9aa" instance_type = "t2.micro" }
  • 34. Imperative VS Declarative infrastructure code Declarative “Can I have a cup of coffee on my desk at 9AM on Monday morning?” Imperative “Go to that machine, then get the glass jar, then fill it with water, then put it back in the machine” …you get the idea...
  • 35. Why go Declarative? Key challenges this approach solves for us: ● Dealing with “Configuration Drift” / State management ● Idempotency ● Dependency graph management, correct order of operations
  • 37. Deploy with Terraform What we had: 1. Write TF configs 2. Run TF to create infrastructure 3. Take TF outputs & enter them to Jenkins 4. Deploy app itself with Jenkins What we wanted to have: 1. Write TF configs 2. Deploy app
  • 39. Deploy with Terraform !"" vars <-- Environment specific variables # !"" production.tfvars # !"" staging.tfvars !"" main.tf !"" io.tf !"" db.tf !"" etc.tf
  • 40. Single fact you could memorize here Try to have as much declarative infrastructure configs as you can, avoid imperative scripts at all cost.
  • 41. Learnings & further improvements
  • 42. Tests for infrastructure code The more infrastructure code you have - the more bugs you see.
  • 43. Chaos monkey We wrote a Lambda that randomly reboots every instance once a day. This simple tweak ensures that: ● Apps you launch can survive instance failure ● Updates to the cluster setup is easy as you’re sure that you won’t harm anyone by killing outdated machines ● Problem resolution can be simpler sometimes. You can always reboot/kill any instance that behaves abnormally as a first action Apply this to control fleet too
  • 44. No SSH keys distribution over instances ● If you’re using AWS - simply install SSM agent to your instances and disable SSH daemon. You will be able to use SSH console to perform your administrative actions. ● If you’re not in AWS - you can use Hashicorp Vault. It provides you with SSH backend that allows central management & audit of the login identities.
  • 45. Things that work for 3 teams - doesn’t work for 10 Issues # of users
  • 46. Key learnings here: ● Operational work grows exponentially the more teams you add ● 1 new tool/approach for devs at a time ● Conduct educational courses for big new things like Docker, AWS, Terraform ● Gain trust within the team you’re challenging with a change first ● Documentation is paramount, start it as early as possible Things that work for 3 teams - doesn’t work for 10
  • 47. DevOps on Call & transparent SLAs ● We’ve established “on call” schedule ● Agreed on SLAs & shared then among the teams ● Created chat room & Jira board Result: significant reduction of the distraction level, better productivity, happier teams Even you’re doing good now, you can make it even better with this practice
  • 48. Encourage feedback ● Ask for it proactively, show that it's important for you ● Public retrospectives ● Respond to the feedback
  • 50. What we’ve achieved ● Immutable infrastructure (done) ○ ECS with immutable data plane ○ Immutable EC2 instances for stateful instances ● Everything as code (done) ○ Infrastructure as code: Terraform, Cloud-init ○ CI/CD as code: Jenkins Now it’s hard to break & easy to repair things as well as
 easy to track changes.
  • 51. Vlad Fedosov Director of R&D @Namecheap, Inc vlad.fedosov@gmail.com Or just scan it: