This document discusses using Test-Kitchen, Docker, and Chef-Zero to test infrastructure code. It begins with an introduction of the speaker and their background in infrastructure automation. The topics to be covered are then outlined: why test-driven development is important for infrastructure code; what Test-Kitchen is; how to provision instances on demand using Test-Kitchen and Docker; how to configure those instances using Chef-Zero; and how to test infrastructure code with Test-Kitchen. Common problems with infrastructure and proposed solutions using infrastructure as code are also briefly discussed.
2. Who Am I
I am an Infrastructure Automation Specialist and a Senior
Consultant with Thoughtworks. Started my career as a
System/Network Administrator for three years, continued the
journey in Infrastructure Automation and Configuration
Management across private and public clouds
(AWS, Openstack). Interested in Infrastructure and Application
Security, IaaS, PaaS and Continuous delivery and usually
present at various conferences.
Read me at : http://www.kamalika.net/
https://twitter.com/mjkamalika
3. Topics to be covered
Why TDD for infra code
What is test-kitchen
Provision instances on demand => kitchen-docker
Configure the instances => Chef-zero
Test the infra code => Test-kitchen
Quick Demo
https://twitter.com/mjkamalika
4. Problems Solutions
https://twitter.com/mjkamalika
What are we trying to solve
I. Manual setups per server.
Each Server becomes a
"work of art".
II. No track of what
changes were made
when.
III. Code works in local host
, not in production.
IV. Testing takes forever.
I. Model server
configs, relationships with
other servers, packages in
code.(Configuration
Management)
II. Infra as Code, Code to be
version controlled.
III. Host production like
environment locally.
IV. Scalable Environment On
Demand .
5. Infrastructure As Code
Treat your infrastructure as Code
Server configuration, packages installed, relationships with
other servers etc should be modeled with code to be
automated, removing manual steps prone to errors.
Use version controlling for that code.
For instance we can (and should!)
tag, branch and release the code that define our servers.
have a lifecycle that covers different stages through the
infrastructure code, ie. dev, QA, production.
continuously test our infrastructure as we make changes.
https://twitter.com/mjkamalika
7. Why Test Driven Development for
Infrastructure Code
Code works in my machine as well as in my
production server.
Quick feedback for testing Infra code.
Faster you test code , faster you deploy in
Production.
Shorter Release Cycle for apps.
https://twitter.com/mjkamalika
8. Some Real World
Scenarios/Examples
Changing web ports
Adding new app metrics
Changing app user
Add a new user
Add basic authentication
Configuring a new machine
Adding additional node to cluster
https://twitter.com/mjkamalika
10. Test-Kitchen:
Test Kitchen is a test harness tool to
execute your configured code on one or
more platforms in isolation.
Drivers for
cloud/virtualization
platforms
Configuration
Management
Support for test
frameworks
https://twitter.com/mjkamalika
12. What do we achieve:
More stable and tested build .
Production like environment on your machine in minutes is a
reality now.
Consistency across all environments.
Automated and Scalable Environment On Demand
Fully Tested Configuration management.
Production go live from 3 weeks to 1 week to multi
deployment per week.
Overall testing time reduction went down by multifold. Build
pipeline time cycle reduction.
https://twitter.com/mjkamalika