GithubHelp home page GithubHelp logo

jlwestsr / puppet-docker-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from garethr/puppet-docker-example

0.0 2.0 0.0 157 KB

An example of using the Puppet Docker module to manage containers, including Consul for service discovery

Ruby 59.81% Puppet 29.22% Pascal 0.18% Shell 10.79%

puppet-docker-example's Introduction

Docker Puppet Example

The Puppet Docker module is a great way of installing and managing Docker on a host, but it also allows for some basic container management. This repo contains a fairly advanced example using Puppet, Docker, Consul and Vagrant.

Usage

vagrant up --provider virtualbox
vagrant provision

This will take a little time as it launches three virtual machines and downloads lots of software for them.

What happened?

Once up you should be able to access 10.20.1.13 and it should print the text client-appserver-2.

The text is coming from a docker container on the host client-appserver-2, proxied through the nginx on client-webserver-3.

So far, not very interesting.

Next

INSTANCES=4 vagrant up --provider virtualbox
vagrant provision client-webserver-3

Here we're launching a fourth virtual machine, another application server. We're then kicking the webserver to update it's configuration.

Note that you can increase the INSTANCES count until you run out of computer, it will launch alternating webservers and application servers and running provision on the webservers will add any new app servers the proxy.

Visit 10.20.1.13 again and refresh a few times, it should print client-appserver-2 or client-appserber-4, regularly swapping between the two.

Under the hood

  1. The first instance (master-1) acts as a Consul master
  2. The second instance (client-appserver-2) installs docker, downloads the official nginx docker image and runs a container based on that image. It also regisers a service in Consul pointing at the container port
  3. The third instance (client-webserver-3) installs nginx and checks Consul (via the Consul Hiera backend) for any services, automatically creating a proxy if it finds any

For those unfamiliar with the Puppet roles and profiles pattern the interesting Puppet code is found in the application profile and the webserver profile.

Improvements

This could be improved by running Puppet as an agent on each of the machines, which would remove the need for the additional provisioning runs. You could also trigger a Puppet run whenever a new application server is added by watching the Consul API with Confd or similar.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.