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.
DevOps Fest 2020. immutable infrastructure as code. True story.
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
DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.
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

PDF
Pietro Di Bello, Paolo D'Incau - Continuous Delivery su progetti Java: cosa a...
PDF
Perl-Critic
PDF
Stackato v6
PPTX
Michigan IT Symposium 2017 - CI/CD Workflow Tutorial
PDF
Automate Thyself
PPTX
Puppetcamp r10kyaml
PDF
PuppetConf 2016: Best Practices for Puppet in the Cloud – Randall Hunt, Amazo...
PDF
2021 04-15 operational verification (with notes)
Pietro Di Bello, Paolo D'Incau - Continuous Delivery su progetti Java: cosa a...
Perl-Critic
Stackato v6
Michigan IT Symposium 2017 - CI/CD Workflow Tutorial
Automate Thyself
Puppetcamp r10kyaml
PuppetConf 2016: Best Practices for Puppet in the Cloud – Randall Hunt, Amazo...
2021 04-15 operational verification (with notes)

What's hot (20)

PDF
Devops with Python by Yaniv Cohen DevopShift
PPTX
Infrastructure as Code for Network
PDF
Puppet overview
PPTX
Continuous integration of_puppet_code
PDF
DevOps Summit 2016 - The immutable Journey
PDF
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...
PDF
Devops For Drupal
ODP
Is Python still production ready ? Ludovic Gasc
PDF
DevTernity - DevOps with smell
PDF
Rule jenkins with configuration as code
PPTX
Immutable Infrastructure: the new App Deployment
PDF
CommandBox & ForgeBox Package Management
PPT
Continuous Deployment with Cloud Foundry, Github and Travis CI
PPT
From VB Script to PowerShell
ZIP
Drupal Deployment
PDF
Puppet Camp Charlotte 2015: Manage Your Switches Like Servers
PPT
PS scripting and modularization
PDF
ContainerCon - Test Driven Infrastructure
KEY
John Adams Puppet Camp 2010
PPTX
Implementing blue-green deployment with Atlassian Bamboo
Devops with Python by Yaniv Cohen DevopShift
Infrastructure as Code for Network
Puppet overview
Continuous integration of_puppet_code
DevOps Summit 2016 - The immutable Journey
PuppetConf 2016: Keynote: Pulling the Strings to Containerize Your Life - Sco...
Devops For Drupal
Is Python still production ready ? Ludovic Gasc
DevTernity - DevOps with smell
Rule jenkins with configuration as code
Immutable Infrastructure: the new App Deployment
CommandBox & ForgeBox Package Management
Continuous Deployment with Cloud Foundry, Github and Travis CI
From VB Script to PowerShell
Drupal Deployment
Puppet Camp Charlotte 2015: Manage Your Switches Like Servers
PS scripting and modularization
ContainerCon - Test Driven Infrastructure
John Adams Puppet Camp 2010
Implementing blue-green deployment with Atlassian Bamboo
Ad

Similar to DevOps Fest 2020. immutable infrastructure as code. True story. (20)

PPTX
Uncover the mysteries of infrastructure as code (iac)!
PPTX
Infrastructure as Code - Getting Started, Concepts & Tools
PDF
Lessons learned from writing over 300,000 lines of infrastructure code
PPTX
Infrastructure as code, using Terraform
PDF
Infrastructure as Code, Theory Crash Course
PDF
Best Practices of Infrastructure as Code with Terraform
PDF
Infrastructure as code managing servers in the cloud Morris
PDF
Infrastructure as code managing servers in the cloud Morris 2024 scribd download
PDF
Infrastructure as code managing servers in the cloud Morris
PPTX
Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...
PPTX
Immutable infrastructure isn’t the answer
PDF
Inrastructure as Code
PPTX
Will hall - Accelerating Infrastructure as Code and Configuration Management ...
PPTX
Accelerating Infrastructure as Code with CI in AWS.
PDF
Infrastructure as Code
PPTX
How to Architect AWS for Mission-Critical Applications
PDF
Cloud infrastructure as code
PPTX
Introduction to DevOps on AWS
PDF
Infrastructure as Code
PDF
Terraform In Action Meap V10 Meap Scott Winkler
Uncover the mysteries of infrastructure as code (iac)!
Infrastructure as Code - Getting Started, Concepts & Tools
Lessons learned from writing over 300,000 lines of infrastructure code
Infrastructure as code, using Terraform
Infrastructure as Code, Theory Crash Course
Best Practices of Infrastructure as Code with Terraform
Infrastructure as code managing servers in the cloud Morris
Infrastructure as code managing servers in the cloud Morris 2024 scribd download
Infrastructure as code managing servers in the cloud Morris
Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...
Immutable infrastructure isn’t the answer
Inrastructure as Code
Will hall - Accelerating Infrastructure as Code and Configuration Management ...
Accelerating Infrastructure as Code with CI in AWS.
Infrastructure as Code
How to Architect AWS for Mission-Critical Applications
Cloud infrastructure as code
Introduction to DevOps on AWS
Infrastructure as Code
Terraform In Action Meap V10 Meap Scott Winkler
Ad

More from Vlad Fedosov (6)

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

Recently uploaded (20)

PDF
Be ready for tomorrow’s needs with a longer-lasting, higher-performing PC
PPTX
Blending method and technology for hydrogen.pptx
PPTX
Slides World Game (s) Great Redesign Eco Economic Epochs.pptx
PDF
Advancements in abstractive text summarization: a deep learning approach
PPTX
Report in SIP_Distance_Learning_Technology_Impact.pptx
PPTX
Information-Technology-in-Human-Society (2).pptx
PPTX
From XAI to XEE through Influence and Provenance.Controlling model fairness o...
PDF
FASHION-DRIVEN TEXTILES AS A CRYSTAL OF A NEW STREAM FOR STAKEHOLDER CAPITALI...
PPTX
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
PDF
Ebook - The Future of AI A Comprehensive Guide.pdf
PDF
Revolutionizing recommendations a survey: a comprehensive exploration of mode...
PPTX
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
PDF
Decision Optimization - From Theory to Practice
PDF
Introduction to c language from lecture slides
PPT
Overviiew on Intellectual property right
PDF
Peak of Data & AI Encore: Scalable Design & Infrastructure
PPTX
Information-Technology-in-Human-Society.pptx
PDF
substrate PowerPoint Presentation basic one
PDF
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
PPTX
From Curiosity to ROI — Cost-Benefit Analysis of Agentic Automation [3/6]
Be ready for tomorrow’s needs with a longer-lasting, higher-performing PC
Blending method and technology for hydrogen.pptx
Slides World Game (s) Great Redesign Eco Economic Epochs.pptx
Advancements in abstractive text summarization: a deep learning approach
Report in SIP_Distance_Learning_Technology_Impact.pptx
Information-Technology-in-Human-Society (2).pptx
From XAI to XEE through Influence and Provenance.Controlling model fairness o...
FASHION-DRIVEN TEXTILES AS A CRYSTAL OF A NEW STREAM FOR STAKEHOLDER CAPITALI...
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
Ebook - The Future of AI A Comprehensive Guide.pdf
Revolutionizing recommendations a survey: a comprehensive exploration of mode...
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
Decision Optimization - From Theory to Practice
Introduction to c language from lecture slides
Overviiew on Intellectual property right
Peak of Data & AI Encore: Scalable Design & Infrastructure
Information-Technology-in-Human-Society.pptx
substrate PowerPoint Presentation basic one
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
From Curiosity to ROI — Cost-Benefit Analysis of Agentic Automation [3/6]

DevOps Fest 2020. 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.
  • 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.
  • 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
  • 36. Terraform CI Try now: https://www.runatlantis.io/ https://app.terraform.io/
  • 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 [email protected] Or just scan it: