Testing for infra code using test-kitchen,docker,chef

14
Testing Infrastructure Code Using Test- kitchen, Docker & Chef-zero Kamalika Majumder https://twitter.com/ mjkamalika

Transcript of Testing for infra code using test-kitchen,docker,chef

  • 1. Testing Infrastructure Code Using Test- kitchen, Docker & Chef- zero Kamalika Majumder https://twitter.com/mjkamalika

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 6. Sample Infra Code Environment Production, Qa,Dev Recipes(run_list) node Recipes(run_list) node Recipes(run_list) node Roles Web, DB, App Chef Workflow Databags 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 9. Example Workflow 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 11. Detailed Demo 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 13. Questions ? https://twitter.com/mjkamalika 14. Thank you @mjkamalika http://www.kamalika.net/ https://twitter.com/mjkamalika