Orchestrating Docker using Puppet

Dockers containers are revolutionizing the cloud computing world, spreading everywhere and powering developers world-wide to automate deployment of applications as a portable self-sufficient containers. In this blog post we will see how Puppet can be used as an orchestration tool in order to provision, deploy, and manage your servers with Docker running on them.

Docker is a lightweight containerization technology that has gained widespread popularity in cloud and application packaging world. It is an open source framework that automates the deployment of applications in lightweight and portable containers. It uses a host of the Linux kernel’s features such as namespaces, cgroups, AppArmor profiles, and so on, to sandbox processes into configurable virtual environments. Though the concept of container virtualization isn’t new but it’s getting attention lately with bigwigs like Red Hat, Microsoft, VMware, SaltStack, IBM, HP etc. trying to throw their support behind newcomer Docker. Start-ups are betting their fortunes on Docker as well. CoreOS, Drone.io, and Shippable are some of the start-ups that are modeled such that they provide services based around Docker. Red Hat has already included it as a primary supported container format for Red Hat Enterprise Linux 7. Recently, Google collaborated with CoreOS team for an open source system that manages containerized application across multiple hosts which they call as “Kubernetes”.

One of the major driving factor for Docker’s popularity is in terms of speed, ease of use and largely free. In terms of performance, they have even been called comparable to KVM. A container-based approach, in which applications can run in isolation and without relying on a separate operating system, can really save huge amounts of hardware resources. Industry experts have started looking at it as hardware multi-tenancy for applications. Instead of having 100s of VMs running per server, what if it is possible to have 1000s of hardware-isolated applications.

On the other hand, Puppet has already matured as a robust configuration management system that allows you to define the state of your IT infrastructure, then automatically enforces the correct state. Whether you’re managing just a few servers or thousands of physical and virtual machines, Puppet automates tasks that system administrators often do manually, freeing up time and mental space so they can work on the projects that deliver greater business value. Puppet enforces states of resources defined in a puppet manifest. A resource can be anything that has a state, including files, daemons, databases and custom services. The exact implementation of how to manipulate a resource and what are the possible states of a resource are defined in modules. It runs in a master-agent (server-client) architecture, where agents periodically check in at the master and ask for the manifest.

While moving into the cloud, today scaling has become a whole lot easier as one could go from a single machine to hundreds without breaking a sweat. But this also meant configuring and maintaining these machines. Configuration management tools such as Puppet arose from the need to automate deploying applications in public/private clouds. Today, Puppet is popular everywhere and being used by start-ups and corporates all over the world to manage their cloud environments.
Though Puppet has matured well as a robust orchestration tool but it is very slow to execute at the same time. Docker can fill this gap as it is extremely fast to spin a new container based on an existing image. The idea is to use Puppet to provision a complete service into a Docker image, then use this image on the agents to start the services.
To illustrate how Puppet can automate the provisioning of Docker containers, I assume that you have puppetmaster and agents configured properly.

Setting up the Puppetmaster

1. Docker installation on the puppet master requires puppetlabs-stdlibs library module. Install the required puppet module as shown below:

#puppet module install puppetlabs/stdlib
Notice: Preparing to install into /etc/puppet/modules …
Notice: Downloading from https://forgeapi.puppetlabs.com …
Notice: Installing — do not interrupt …
/etc/puppet/modules
+– puppetlabs-stdlib (v4.5.1)

2. Docker needs EPEL repo to be enabled in order to install Docker successfully. A quick way to install EPEL repo is installing the module directly.

#puppet module install –force stahnma-epel
Notice: Preparing to install into /etc/puppet/modules …
Notice: Downloading from https://forgeapi.puppetlabs.com …
Notice: Installing — do not interrupt …
/etc/puppet/modules
+– stahnma-epel (v1.0.2)

3. It’s time to install Docker. Installation of Docker is very easy with the excellent puppet module provided by Gareth R. (https://github.com/garethr/garethr-docker). Run the following command to pull the docker module from puppetforge as shown:

#puppet module install garethr/docker –ignore-dependencies
Notice: Preparing to install into /etc/puppet/modules …
Notice: Downloading from https://forgeapi.puppetlabs.com …
Notice: Installing — do not interrupt …
/etc/puppet/modules
+– garethr-docker (v3.5.0)
[root@puppetmaster ~]#

4. Open /etc/puppet/manifests folder and create site.pp if not available. If newly created, the site.pp should look like as shown below:

#cat /etc/puppet/manifests/site.pp

node “aster.collabnix.com” {
include ‘docker’

5. Let us apply the puppet module in order to get docker installed on the puppet master.

#puppet apply site.pp

Notice: Compiled catalog for master.collabnix.com in environment production in 1.75 seconds
Notice: /Stage[main]/Docker::Service/File[/etc/sysconfig/docker-storage]/content: content changed ‘{md5}ab8c4963d7da2df915a052babb0e1b89’ to ‘{md5}a6d7017ae0cf60008ff76ce39f3a4245’
Notice: /Stage[main]/Docker::Service/File[/etc/sysconfig/docker]/content: content changed ‘{md5}670c789326a6013f8a4de5340cb44d95’ to ‘{md5}54701e57c4b50c02936fa990b9c463f5’
Notice: /Stage[main]/Docker::Service/Service[docker]/ensure: ensure changed ‘stopped’ to ‘running’
Notice: Finished catalog run in 3.04 seconds

6. Verify if docker installation went fine through the following command:

#docker version
Client version: 1.4.1
Client API version: 1.16
Go version (client): go1.3.3
Git commit (client): 5bc2ff8/1.4.1
OS/Arch (client): linux/amd64

This installs docker on the puppetmaster through the docker module.

Setting up the Puppetagents

I assume that Puppetagents are running smoothly and configured to work with the puppetmaster. Follow the steps to configure puppetagent for installing docker.
1. Open /etc/puppet/manifests/site.pp and make an entry for puppetagents as shown below:
node “agent1.collabnix.com” {
include ‘docker’
2. Run the below command to get docker configured on the puppetagents.

#puppet agent –t
Hence, we have Puppet master and client configured with Docker installation.

Writing Puppet manifest to run containers on Docker

Next, it’s time to write a Puppet manifests to run containers on Docker. The following puppet manifests starts ajeetraina/collabnix container:

#installation
include ‘docker’

#download and install a docker image
docker::image { ‘ubuntu’:
image_tag: ‘precise’
}

# Once we have an image we can run commands within a container managed by #Docker
docker::run { ‘collabnix-puppet’:
image => ‘ajeetraina/collabnix’,
commands => ‘/usr/sbin/apache2 –D FOREGROUND’,
ports => ’80’,

}

The first non-comment statement include docker module. The statement docker::image { ‘ubuntu’: image_tag: ‘precise’ is equivalent to running the $ docker pull ubuntu:precise command in the console. Considering that ajeetraina/collabnix image carries apache2 packages, it will try to run the httpd service.

The above code is similar to Dockerfile:

#cat Dockerfile

FROM Ubuntu:precise
MAINTAINER Ajeet Raina aj********@gm***.com

RUN yum install -y httpd
RUN chkconfig httpd on
EXPOSE 80
CMD [“/usr/sbin/apache2”, “-D”, “FOREGROUND”]

The above puppet manifests entry should be added to etc/puppet/manifests/site.pp for the puppet agent node. Remember that the docker::run takes care of build process and hence the container can be run flawlessly.

Hence, the above puppet module automates the creation of Docker container and installs and configures the services on the puppet agent nodes successfully.

To end up, we saw that how easy is it to integrate Docker with Puppet, build Puppet-enabled Docker images, and create containers that leverage our Puppet modules. We also learnt how to configure and manage our Docker containers with Puppet.

References:

https://forge.puppetlabs.com/garethr/docker
https://docs.docker.com/articles/puppet/
https://puppetlabs.com/presentations/using-docker-puppet-james-turnbull-kickstarter

[Note: This article was selected for publication under OSFY 2015 India May Edition.]

Please follow and like us:
1

69 thoughts on “Orchestrating Docker using Puppet

  1. Hi there very cool site!! Man .. Beautiful .. Wonderful .. I’ll bookmark your website and take the feeds additionallyKI’m satisfied to search out so many helpful information here within the submit, we need develop extra strategies in this regard, thanks for sharing. . . . . .

  2. I’m not sure exactly why but this website is loading extremely slow for me. Is anyone else having this problem or is it a issue on my end? I’ll check back later and see if the problem still exists.

  3. Heya i am for the primary time here. I came across this board and I find It really helpful & it helped me out a lot. I am hoping to provide one thing back and help others such as you helped me.

  4. Great awesome things here. I?¦m very satisfied to see your article. Thank you so much and i’m looking forward to contact you. Will you please drop me a e-mail?

  5. Does your blog have a contact page? I’m having problems locating it but, I’d like to send you an email. I’ve got some suggestions for your blog you might be interested in hearing. Either way, great website and I look forward to seeing it develop over time.

  6. Thanks for sharing superb informations. Your website is very cool. I am impressed by the details that you have on this site. It reveals how nicely you perceive this subject. Bookmarked this web page, will come back for more articles. You, my friend, ROCK! I found just the info I already searched everywhere and just couldn’t come across. What an ideal web site.

  7. Howdy just wanted to give you a quick heads up and let you know a few of the pictures aren’t loading properly. I’m not sure why but I think its a linking issue. I’ve tried it in two different browsers and both show the same outcome.

  8. I and my friends were studying the excellent pointers found on the blog then all of the sudden came up with a terrible feeling I never thanked the web blog owner for those secrets. Most of the young men came as a consequence stimulated to learn them and already have certainly been making the most of those things. Thank you for indeed being very kind as well as for making a choice on variety of helpful subjects most people are really needing to learn about. My personal sincere regret for not expressing appreciation to you earlier.

  9. I precisely wanted to thank you so much once again. I’m not certain the things that I might have accomplished without the entire ideas contributed by you about my theme. It was a frightening difficulty for me, however , understanding a skilled fashion you handled the issue forced me to jump for joy. I am happier for the guidance and even sincerely hope you find out what a powerful job that you are accomplishing training many others thru a web site. More than likely you haven’t got to know any of us.

  10. After study a few of the blog posts on your website now, and I truly like your way of blogging. I bookmarked it to my bookmark website list and will be checking back soon. Pls check out my web site as well and let me know what you think.

  11. Sweet blog! I found it while surfing around on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Many thanks

  12. hello there and thanks to your info – I’ve definitely picked up something new from right here. I did on the other hand expertise several technical issues the use of this website, since I experienced to reload the website a lot of instances previous to I may just get it to load properly. I were wondering if your web host is OK? Not that I am complaining, however sluggish loading instances times will very frequently affect your placement in google and could injury your high-quality rating if ads and ***********|advertising|advertising|advertising and *********** with Adwords. Anyway I’m adding this RSS to my email and could look out for a lot extra of your respective intriguing content. Make sure you update this once more very soon..

  13. I have been surfing online more than three hours these days, yet I never found any attention-grabbing article like yours. It is lovely price sufficient for me. In my view, if all site owners and bloggers made excellent content material as you probably did, the internet can be much more helpful than ever before.

  14. Hey I am so delighted I found your site, I really found you by mistake, while I was researching on Digg for something else, Nonetheless I am here now and would just like to say many thanks for a tremendous post and a all round exciting blog (I also love the theme/design), I don’t have time to look over it all at the moment but I have saved it and also added your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the excellent work.

  15. Very nice info and right to the point. I don’t know if this is actually the best place to ask but do you folks have any ideea where to employ some professional writers? Thx 🙂

  16. Woah! I’m really digging the template/theme of this site. It’s simple, yet effective. A lot of times it’s tough to get that “perfect balance” between usability and visual appeal. I must say that you’ve done a awesome job with this. Also, the blog loads extremely quick for me on Firefox. Superb Blog!

  17. Thanks for sharing superb informations. Your site is so cool. I am impressed by the details that you have on this site. It reveals how nicely you understand this subject. Bookmarked this web page, will come back for extra articles. You, my friend, ROCK! I found simply the info I already searched everywhere and simply could not come across. What a perfect site.

  18. We’re a group of volunteers and starting a new scheme in our community. Your web site provided us with valuable information to work on. You’ve done an impressive job and our whole community will be grateful to you.

  19. What i do not realize is if truth be told how you are not actually much more well-liked than you might be now. You’re very intelligent. You understand therefore considerably in terms of this matter, made me in my view believe it from a lot of various angles. Its like women and men don’t seem to be fascinated until it is something to do with Lady gaga! Your personal stuffs excellent. All the time maintain it up!

  20. Fantastic blog! Do you have any tips for aspiring writers? I’m planning to start my own site soon but I’m a little lost on everything. Would you suggest starting with a free platform like WordPress or go for a paid option? There are so many choices out there that I’m totally overwhelmed .. Any recommendations? Many thanks!

  21. After study a couple of of the blog posts on your website now, and I really like your method of blogging. I bookmarked it to my bookmark web site record and will probably be checking back soon. Pls try my web site as properly and let me know what you think.

  22. Wonderful paintings! That is the kind of info that are meant to be shared around the internet. Shame on the search engines for now not positioning this submit upper! Come on over and visit my site . Thank you =)

  23. Microsoft Azure is an operating system that allows you to create web applications and store data in the cloud.Azure admin training in hyderabad visit our link to get more information:-https://azuretrainings.in/

  24. I’ll immediately grasp your rss as I can not find your email subscription link or newsletter service. Do you’ve any? Kindly allow me understand in order that I could subscribe. Thanks.

  25. Can I just say what a relief to find someone who actually knows what theyre talking about on the internet. You definitely know how to bring an issue to light and make it important. More people need to read this and understand this side of the story. I cant believe youre not more popular because you definitely have the gift.

  26. Just about all of the things you say happens to be astonishingly appropriate and that makes me ponder why I had not looked at this in this light before. Your piece truly did turn the light on for me personally as far as this specific subject matter goes. However at this time there is actually one particular point I am not really too cozy with so while I make an effort to reconcile that with the core idea of the issue, allow me observe just what the rest of your subscribers have to say.Well done.

  27. Family xnxx Full HD 4K Porno video izle. işportacıya am
    veriyor bahçede sevişiyorlar kapalı bayan ceren seks türk anal porn fenasikerim
    pornosu. En Yeni Pornolar Orospu üvey annesi yaşlı kocası sikmeyince oğluna sardı Üvey ablası yoksunluk çeken genç adam ona yardımcı oldu.

  28. Hey would you mind stating which blog platform you’re using? I’m planning to start my own blog in the near future but I’m having a hard time choosing between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style seems different then most blogs and I’m looking for something completely unique. P.S Sorry for getting off-topic but I had to ask!

  29. I’ve learned some new things through the blog post. One other thing I have noticed is that in most cases, FSBO sellers are going to reject anyone. Remember, they would prefer not to ever use your companies. But if you maintain a gradual, professional connection, offering help and remaining in contact for about four to five weeks, you will usually manage to win a business interview. From there, a listing follows. Thanks

  30. Attractive portion of content. I just stumbled upon your website and in accession capital to claim that I get in fact enjoyed account your blog posts. Any way I’ll be subscribing on your augment and even I achievement you get admission to consistently rapidly.

  31. That is the suitable weblog for anybody who needs to seek out out about this topic. You notice so much its nearly laborious to argue with you (not that I truly would want…HaHa). You undoubtedly put a new spin on a topic thats been written about for years. Great stuff, just nice!

Leave a Reply to Anonymous Cancel reply