39,59 €
Learn about configuration management and gain complete control of your Docker containers using Puppet
This book is designed for system administrators who are looking to explore containerization. Intermediate experience and expertise with Puppet is presumed.
This book teaches you how to take advantage of the new benefits of containerization systems such as Docker, Kubernetes, Docker Swarm, and Docker UCP, without losing the panoptical power of proper configuration management.
You will learn how to integrate your containerized applications and modules with your Puppet workflow. You will also understand how to manage, monitor, and orchestrate hosts to keep deployed containers running seamlessly. With the help of this book, you can efficiently automate and document with containers, as a part of your system.
The book will also cover use cases of deploying Puppet within a containerized environment.
This book uniquely focuses on the pain point of making containerization part of a bigger, established workflow of system administration. It will begin with the presumption that one has a use for Docker containers, and a background in system administration. Then, step by step, it takes you through the concepts and methods necessary to integrate this new time-saving technology into a well-managed configuration run by Puppet.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 165
Veröffentlichungsjahr: 2016
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: May 2016
Production reference: 1130516
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78588-328-6
www.packtpub.com
Author
Scott Coulton
Reviewer
Ajeet Singh Raina
Commissioning Editor
Sarah Crofton
Acquisition Editor
Rahul Nair
Content Development Editor
Sumeet Sawant
Technical Editor
Dhiraj Chandanshive
Copy Editor
Neha Vyas
Project Coordinator
Shweta H Birwatkar
Proofreader
Safis Editing
Indexer
Rekha Nair
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
Scott Coulton is a solutions architect with 10 years of experience in the field of managed services and hosting space. He has extensive experience in architecture and in rolling out systems and network solutions for national and multinational companies with a wide variety of technologies including AWS, Puppet, Docker, Cisco, VMware, Microsoft, and Linux. His design strengths are in cloud computing, automation, and security space.
You can find him at https://www.linkedin.com/in/scott-coulton-22864813. You can find him on Twitter at @scottcoulton and on GitHub at https://github.com/scotty-c.
Ajeet Singh Raina is a Docker Captain (https://www.docker.com/community/docker-captains) as well as technical lead engineer at Dell India R&D. He has picked up a variety of skills in his career, from having worked as an IT consultant and systems administrator to system integration testing. He received a certification as a VMware Certified Professional (VCP 4.1) while he was a part of the VMQA GOS validation team at VMware and has more than 8 years of industry experience. He is currently working with Enterprise Solution Group at Dell India R&D and has solid understanding of diverse range of topics, such as IT infrastructures, systems management, system integration engineering, and quality assurance.
Ajeet has a great passion for upcoming trends and technologies. He loves contributing toward open source space through writing and blogging at http://www.collabnix.com. He is currently busy evaluating and building up containers and microservices for his organization. Last year, he reviewed PowerCLI Cookbook,Packt Publishing.
This book would not have been a success without direct and indirect help from many people. Thanks to my wife and 7-year old kid for putting up with me, for all the missing family time, and for providing me with love and encouragement throughout the reviewing period. Thanks to my parents and family members for all their love, guidance, and encouragement during the tough times. Thanks to all my past and present colleagues and mentors at VMware and Dell Inc. for the insightful knowledge they shared with me.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
To Halen,
Dream big and work hard. There is nothing in your life that you won't be able to achieve.
Love,
Dad
This book teaches you how to take advantage of the new benefits of containerization systems such as Docker, Kubernetes, Docker Swarm, and Docker UCP, without losing the panoptical power of proper configuration management. You will learn to integrate your containerized applications and modules with your Puppet workflow.
Chapter 1, Installing Docker with Puppet, covers how to create a development environment with Docker using Puppet. We will look at how to install Vagrant and VirtualBox. Then, we will look at Puppet Forge and how to search for modules and their dependencies. We will briefly touch upon r10k to be our transport mechanism from the Puppet Forge to our environment. Then, we build our environment with Puppet.
Chapter 2, Working with Docker Hub, covers a lot about the Docker Hub ecosystem: what are official images, how automated builds work, and of course, working with images in three different ways.
Chapter 3, Building a Single Container Application, contains our first Puppet module to create a Docker container. In this chapter, we will look at writing rspec-puppet unit tests to make sure that our module does what it's meant to do. We will know how to map our Puppet module dependencies with our metadata.json and fixtures.yml files.
Chapter 4, Building Multicontainer Applications, introduces Docker Compose. We will look at the docker-compose .yaml file construct. We will then take that knowledge and create a Puppet template (.erb file) and wrap that into a module. We will also touch on the Docker Compose functionality that will let us scale containers.
Chapter 5, Configuring Service Discovery and Docker Networking, introduces two very important topics when working with containers. First, we will look at service discovery, what it is, why do we need it, and lastly, the different types of service discovery.
Chapter 6, Multinode Applications, introduces all the skills that you've learned in the book so far. We are really going to step it up a notch. In this chapter, we are going to deploy four servers, and we are going to look at how to Consul cluster. In this chapter, we are going to look at the two ways to network our containers. Firstly, using the stand host IP network, that our Consul cluster will communicate on. We will also install the ELK (Elasticsearch, Logstash, and Kibana) stack.
Chapter 7, Container Schedulers, covers container schedulers such as Docker Swarm and Kubernetes. Then, we will build a dev environment containing four servers, three cluster nodes, and a master. We will also build a Docker network and service discovery framework.
Chapter 8, Logging, Monitoring, and Recovery Techniques, will take the environment that we created in the last chapter and add monitoring, logging, and recovery techniques to it. This will make our applications robust and ready for production.
Chapter 9, Best Practices for the Real World, focuses more on the best practices for deploying Puppet itself within a containerized environment using all the new skills that you learned in the previous chapters. By the end of this journey, readers will be able to master Puppet and Docker and apply them in the real world.
For this book we need Intel i5 or above, 8 GB of ram (16 preferable), 50 GB of free disk space, and any OS that can run Vagrant.
This book is designed for system administrators who are looking to explore containerization. Intermediate experience and expertise of Puppet is presumed.
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The other change that we have made to the servers.yaml file is we have added entries to the /etc/hosts directory."
Any command-line input or output is written as follows:
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "The next thing we need to do is click on the Create button."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
You can download the code files by following these steps:
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/PuppetforContainerization_ColorImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.
In this chapter, we will be setting up our development environment so that we can develop our first container application. To do this, we will use Vagrant. In our first topic, we will look at how to install Vagrant. We will look at how a Vagrantfile is constructed using Puppet as the provisioner. We will also look at how to get Puppet modules from the Puppet Forge using a puppetfile and r10k. In the last topic, we will install Docker on a Centos 7 box with Puppet. The following are the topics that we will cover in this chapter:
You may ask, why are we using Vagrant for our development environment?
Vagrant is a must-have for Puppet development. The idea that you can spin up environments for development locally in minutes was a revolution in Vagrant's early releases. The product has now grown in leaps and bounds, with multiple provisioners such as Chef and Salt. Paired with multiple virtualization backends such as VirtualBox, VMware Workstation/Fusion, KVM, and we are going to use VirtualBox and Puppet as your provisioner.
Let's install Vagrant. Firstly, we will need our virtualization backend, so let's download and install VirtualBox. At the time of writing, we use VirtualBox 5.0.10 r104061. If that's outdated by the time you read this book, just grab the latest version.
You can download VirtualBox from https://www.virtualbox.org/wiki/Downloads. Choose the version for your OS, as shown in the following screenshot:
Once the package is downloaded, follow the given installation process for your OS.
Follow these steps to install Vagrant on Mac OSX:
The installer will then check whether the software is compatible with the Mac OSX version.
After this, click on Continue. Once the check is successful, we can move on to the next step:We then choose the default location for the installation and click on Install.Then, enter your admin password and click on Install Software:The installation is now complete. The following screenshot shows what the screen looks like after completing the installation:
Now that we have the virtualization backend, we can install Vagrant:
At the time of writing this book, we are going to use Vagrant 1.7.4; if that is no longer the latest version, please grab the latest one. You can find this version of Vagrant at https://www.vagrantup.com/downloads.html. Again, download the installation package for your OS.
Here, we are just going to complete a standard installation. Follow these steps to do so:
Now that we have a fully working Vagrant environment, we can start with and look at how Vagrant works and how we are going to provision our machines. As this book is not about Vagrant, we won't be writing a Vagrantfile from scratch. Instead, I have created a Vagrantfile that we will be using throughout the book:
You can download or Git pull the repo from https://github.com/scotty-c/vagrant-template.
Let's look at the Vagrantfile construct:
As you can see from the preceding screenshot, the Vagrantfile is actually a Ruby file. As it is Ruby, it opens up a world of opportunities for us to make our code elegant and efficient. So, in this Vagrantfile, we have extracted all the low-level configurations and replaced them with a few parameters. Why are we doing this? The reason is to split up our logic from our configuration and also iterate our configuration in order to stop replication of our code. So, where is all the configuration stored? The answer is in the servers.yaml file. This is where we set the vagrant box that we want to deploy, the number of CPUs for the box, the internal network's IP, the hostname, the forwarded ports between the guest and host, and the RAM and shell provider for bash commands that we need to get the environment ready for Puppet to run, for example, downloading modules and their dependencies from the Puppet Forge:
The benefit of this approach is also that any developer using a Vagrantfile does not need to actually modify the logic in the Vagrantfile. They only need to update the configuration in servers.yaml. As we go through the book, we will work with the other files in the repository, such as Puppetfile, hieradata, and manifests. Now that we have set up our Vagrant environment, let's look at how to get our Puppet modules from the Puppet Forge.
