Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/garethr/puppet-docker-example
An example of using the Puppet Docker module to manage containers, including Consul for service discovery
https://github.com/garethr/puppet-docker-example
Last synced: 2 months ago
JSON representation
An example of using the Puppet Docker module to manage containers, including Consul for service discovery
- Host: GitHub
- URL: https://github.com/garethr/puppet-docker-example
- Owner: garethr
- Created: 2015-01-05T15:42:49.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-09-24T18:06:48.000Z (about 9 years ago)
- Last Synced: 2024-10-03T12:38:25.133Z (3 months ago)
- Language: Ruby
- Size: 153 KB
- Stars: 35
- Watchers: 4
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Docker Puppet Example
The [Puppet Docker module](https://forge.puppetlabs.com/garethr/docker)
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 provisionThis 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](http://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-3Here 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](http://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](https://github.com/lynxman/hiera-consul/))
for any services, automatically creating a proxy if it finds anyFor those unfamiliar with the Puppet roles and profiles pattern the
interesting Puppet code is found in the [application
profile](modules/profiles/manifests/application.pp) and the [webserver
profile](modules/profiles/manifests/webserver.pp).## 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](https://github.com/kelseyhightower/confd) or similar.