Public Repository

Last pushed: 2 years ago
Short Description
Skydns and etcd in a single docker container
Full Description

Go-SkyDNS

Version 1.0.0

SkyDNS is a distributed service for announcement and discovery of services built on
top of etcd. It utilizes DNS queries
to discover available services. This is done by leveraging SRV records in DNS,
with special meaning given to subdomains, priorities and weights.

This Dockerfile project has been designed to run SkyDNS and ETCD within the same docker container as part of a Vagrant Docker project for MoneySupermarket.com.

handsome-vagrant-docker branch of https://github.com/pauldavidgilligan-msm/tru-strap

  • The etcd version fixed at 0.4.6 release.
  • Experimental project for development environments.
  • The Vagrant Docker (handsome-vagrant-docker) project provides all the required shell based provisioning for this image including the configuration of the skydns service.

Docker Build Image

docker build -t="pauldavidgilligan/go-skydns" .

This image is also available on docker hub https://registry.hub.docker.com/u/pauldavidgilligan/go-skydns/.

From Vagrant we need to take care of some boot issues in order to ensure that skydns can both talk to etcd and that etcd can publish its machine(s) to the outside world.

Vagrant Docker

For vagrant as an example we might have:

# -----------------------------------------------------------------------------
# Provision SkyDNS via ETCD
# -----------------------------------------------------------------------------
config.vm.define "#{SKYDNS_NAME}" do |m|
  m.vm.provider "docker" do |vm|
    vm.name            = "#{SKYDNS_NAME}.#{TRUSTRAP_DOMAIN}"
    vm.image           = "pauldavidgilligan/go-skydns"
    vm.has_ssh         = true
    vm.create_args = ["--privileged", "--dns-search=#{TRUSTRAP_DOMAIN}", "--dns=8.8.8.8", "--hostname=#{SKYDNS_NAME}"]
    vm.vagrant_machine = "dockerhost"
    vm.vagrant_vagrantfile = "../../Vagrantfile.proxy"
  end
  m.vm.provision :shell, :path => "bin/shell.sh", :args => "-n #{SKYDNS_NAME} -m config -d #{TRUSTRAP_DOMAIN}"
  m.vm.provision :shell, :path => "bin/shell.sh", :args => "-n #{SKYDNS_NAME} -m hosts -d  #{TRUSTRAP_DOMAIN}"
  m.vm.provision :shell, :path => "bin/shell.sh", :args => "-n #{SKYDNS_NAME} -m start -d  #{TRUSTRAP_DOMAIN}"
end

and the vagrant docker image should be under supervisord control:

CMD ["/usr/bin/supervisord", "--configuration=/etc/supervisord.conf"]

supervisorctl should be configured and both skydns should be set not to autostart, etcd being a database is started when the container starts. This is used to provision the skydns configuration.

m.vm.provision :shell, :path => "bin/shell.sh", :args => "-n #{SKYDNS_NAME} -m config -d #{TRUSTRAP_DOMAIN}"

The finally skydns is started.

m.vm.provision :shell, :path => "bin/shell.sh", :args => "-n #{SKYDNS_NAME} -m start -d  #{TRUSTRAP_DOMAIN}"

Vagrant Docker Shell Provision Steps

Some addtional scripts are used to provision the network discovery and then finally start etcd and skydns.

Environment

Skydns and etcd environment values are not used as after some evaluation it had proved to unreliable, hence the skydns configuration is written into etcd at /skydns/config.

Hosts

An update is need to /etc/hosts to add in the published etcd machine name, this is required by each business node which register their host details with etcd on a regular basis to maintain the short TTL.

#!/bin/bash
#
# Simple script start single container skydns/etcd services.
# 

/usr/bin/supervisorctl start skydns
Docker Pull Command
Owner
pauldavidgilligan

Comments (0)