Adds confd support!

This commit is contained in:
pierreozoux 2014-10-10 18:08:14 +01:00
parent dca19440a6
commit c92a39ea60
19 changed files with 261 additions and 84 deletions

3
.gitignore vendored
View file

@ -1 +1,2 @@
.vagrant
.vagrant
docker-haproxy-confd

2
Vagrantfile vendored
View file

@ -40,6 +40,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
core.vm.hostname = HOSTNAME
core.hostsupdater.aliases = ["example.dev"]
core.vm.network :private_network, ip: "#{BASE_IP_ADDR}.#{i+1}"
core.vm.synced_folder ".", "/data/infrastructure"
core.vm.synced_folder "/data/per-user", "/data/per-user"
@ -47,6 +48,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
core.vm.synced_folder "/data/per-user", "/data/per-user", id: "coreos-per-user", :nfs => true, :mount_options => ['nolock,vers=3,udp']
core.vm.provision :file, source: "./config/user-data", destination: "/tmp/vagrantfile-user-data"
core.vm.provision :shell, path: "./scripts/setup.sh"
core.vm.provision :shell, inline: "etcdctl set /services/default '{\"app\":\"nginx\", \"hostname\":\"#{HOSTNAME}\"}'"
core.vm.provision :shell, path: "./scripts/approve-user.sh", args: [HOSTNAME, "nginx"]
end
end

View file

@ -3,3 +3,9 @@
coreos:
update:
reboot-strategy: best-effort
etcd:
addr: $public_ipv4:4001
peer-addr: $public_ipv4:7001
units:
- name: etcd.service
command: start

View file

@ -3,29 +3,3 @@
# Start service for new site (and create the user)
systemctl enable $2@$1.service
systemctl start $2@$1.service
sleep 10
# Configure new site in HAproxy
IP=`docker inspect --format '{{.NetworkSettings.IPAddress}}' $2-$1`
echo IP address of new container \'$2-$1\' is \'$IP\'
if [ -f /data/per-user/$1/combined.pem ]; then
echo Importing cert from /data/per-user/$1/combined.pem
echo TODO: enforce validity check at this point!
echo Please run scripts/check-cert.sh $1 to make sure it\'s OK
mkdir -p /data/server-wide/haproxy/approved-certs
cp /data/per-user/$1/combined.pem /data/server-wide/haproxy/approved-certs/$1.pem
echo /haproxy-override/approved-certs/$1.pem $1 >> /data/server-wide/haproxy/certs/list.txt
sed s/%HOSTNAME%/$1/g /data/infrastructure/templates/haproxy-cert.part >> /data/server-wide/haproxy/certs.part
else
echo WARNING: TLS cert /data/per-user/$1/combined.pem not found! Not enabling SNI for this domain.
fi
sed s/%HOSTNAME%/$1/g /data/infrastructure/templates/haproxy-frontend.part >> /data/server-wide/haproxy/frontends.part
sed s/%HOSTNAME%/$1/g /data/infrastructure/templates/haproxy-backend.part | sed s/%IP%/$IP/g >> /data/server-wide/haproxy/backends.part
cat /data/server-wide/haproxy/haproxy-1.part /data/server-wide/haproxy/hostname.part /data/server-wide/haproxy/haproxy-2.part /data/server-wide/haproxy/certs.part /data/server-wide/haproxy/haproxy-3.part /data/server-wide/haproxy/hostname.part /data/server-wide/haproxy/haproxy-4.part /data/server-wide/haproxy/frontends.part /data/server-wide/haproxy/backends.part > /data/server-wide/haproxy/haproxy.cfg
systemctl reload haproxy.service

View file

@ -8,21 +8,13 @@ cp /data/infrastructure/unit-files/* /etc/systemd/system
systemctl daemon-reload
# Pull relevant docker images
docker pull pierreozoux/haproxy-confd
docker pull tutum/mysql
docker pull tutum/wordpress-stackable
docker pull tutum/nginx
# Configure and start HAproxy
docker pull dockerfile/haproxy
mkdir -p /data/server-wide/haproxy/certs
touch /data/server-wide/haproxy/certs/list.txt
cp /data/infrastructure/templates/haproxy-*.part /data/server-wide/haproxy/
rm /data/server-wide/haproxy/*.part
#rm /etc/systemd/system/multi-user.target.wants/*
touch /data/server-wide/haproxy/certs.part
touch /data/server-wide/haproxy/frontends.part
touch /data/server-wide/haproxy/backends.part
hostname > /data/server-wide/haproxy/hostname.part
cp /data/infrastructure/templates/haproxy-*.part /data/server-wide/haproxy/
mkdir -p /data/server-wide/haproxy/approved-certs
cp /data/infrastructure/scripts/unsecure-certs/*.pem /data/server-wide/haproxy/approved-certs
systemctl enable haproxy.service
systemctl start haproxy.service

View file

@ -0,0 +1,83 @@
-----BEGIN CERTIFICATE-----
MIIFjDCC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WwZ6djtCLQmSaKws+TvypFYbBPldwNCaEsubW6Lhv/LRQl3r
xR1KlHdQyC757eS1VTuundW1LLTeYTFbhe3lHsRnM8ahfCQJOwcgvhBu2VgLy3Fd
fEZ2BCvhlC+UR4wBhjm1KR5dsz+Xx9IT6SI/7oZysYfYRNEf2q+n2sK0a4lGH2ar
5G16QQJBf6WAZsa7SfGcgqn7eMnCZytg456CzN6qEEYMz1z6kI+6450yzboFJ+i8
jr3n7Mtcas0NMW4cKf477AcNkB9UZVLT2YbCY3LNKSpgpKqNUuozdgW51/+D/HLb
r2vRXVHbJqUXOj2m7vQZgw34lwRXPtLBAoIBAChJgVltpcWKUWqltYXCQsdPPbb4
DQMb4bb2vV2iON2kl+UlcCdhr0f5yWoAyKjs49lcHBN2Ny4zVR0vIu/IDeX47Fx7
n0OfcFgcnqiqiFhXkWGcfU2JHq/q5tmk5M04aCgkFM8IyEsG6ZLoi849Km9r8quu
VfclpJ6SsMGnWo/A2eIVP9GsfqRys9ZWKJ9inZRP5Lmx6pCZa12Mn6ey0h/kxOqh
ruJQDdV0O4PsvZhTQFhahSVyNmSKnLguq3zsyBwKRsNI9TVXMv/hs0nnwfFgtBK1
K61c7AL4+9dtAWEnuwqy/1srZEeBr/jgTqyFyr+GQFYUMuE/uXNKCDWlIRI=
-----END RSA PRIVATE KEY-----

View file

@ -1,20 +0,0 @@
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
user haproxy
group haproxy
defaults
log global
mode http
option httplog
option dontlognull
retries 3
timeout connect 5000
timeout client 50000
timeout server 50000
frontend https-in
mode http
bind *:443 ssl crt-list /haproxy-override/certs/list.txt crt /haproxy-override/approved-certs/

View file

@ -1,4 +0,0 @@
/combined.pem
reqadd X-Forwarded-Proto:\ https

View file

@ -1 +0,0 @@
default_backend

View file

@ -1,4 +0,0 @@
frontend http-in
bind *:80

View file

@ -1,7 +0,0 @@
# %HOSTNAME%:
backend %HOSTNAME%
cookie SERVERID insert nocache indirect
option httpclose
option forwardfor
server Server %IP%:80 cookie Server

View file

@ -1,4 +0,0 @@
# %HOSTNAME%:
acl https_%HOSTNAME% hdr_end(host) -i %HOSTNAME%
use_backend %HOSTNAME% if https_%HOSTNAME%

View file

@ -1,4 +0,0 @@
# %HOSTNAME%:
acl is_%HOSTNAME% hdr_end(host) -i %HOSTNAME%
use_backend %HOSTNAME% if is_%HOSTNAME%

View file

@ -12,8 +12,8 @@ ExecStart=/usr/bin/docker run\
--name %p\
-p 80:80\
-p 443:443\
-v /data/server-wide/%p:/haproxy-override\
dockerfile/haproxy
-v /data/server-wide/haproxy/approved-certs/:/etc/haproxy/approved-certs\
pierreozoux/haproxy-confd
ExecReload=/usr/bin/docker restart %p
ExecStop=/usr/bin/docker stop %p

View file

@ -0,0 +1,36 @@
[Unit]
Description=%p for %i etcd registration
# Requirements
Requires=etcd.service
Requires=nginx@%i.service
# Dependency ordering and binding
After=etcd.service
After=nginx@%i.service
BindsTo=nginx@%i.service
[Service]
EnvironmentFile=/etc/environment
TimeoutStartSec=0
# Start
## Test whether service is accessible and then register useful information
ExecStart=/bin/bash -c '\
sleep 3; \
while true; do \
app=`echo %p | cut -d"-" -f1`; \
ip=`docker inspect --format \'{{.NetworkSettings.IPAddress}}\' $app-%i`; \
curl -f $ip; \
if [ $? -eq 0 ]; then \
etcdctl set /services/$app/%i \'{"ip":"\'$ip\'", "port":"80"}\' --ttl 30; \
else \
etcdctl rm /services/$app/%i; \
fi; \
sleep 20; \
done'
# Stop
ExecStop=/bin/bash -ceux '\
app=`echo %p | cut -d"-" -f1`;\
/usr/bin/etcdctl rm /services/$app/%i

View file

@ -2,8 +2,11 @@
Description=%p-%i
After=docker.service
Requires=docker.service
Requires=etcd.service
Requires=%p-importer@%i.service
After=%p-importer@%i.service
Requires=%p-discovery@%i.service
Before=%p-discovery@%i.service
[Service]
Restart=always

View file

@ -0,0 +1,36 @@
[Unit]
Description=%p for %i etcd registration
# Requirements
Requires=etcd.service
Requires=wordpress@%i.service
# Dependency ordering and binding
After=etcd.service
After=wordpress@%i.service
BindsTo=wordpress@%i.service
[Service]
EnvironmentFile=/etc/environment
TimeoutStartSec=0
# Start
## Test whether service is accessible and then register useful information
ExecStart=/bin/bash -c '\
sleep 3; \
while true; do \
app=`echo %p | cut -d"-" -f1`; \
ip=`docker inspect --format \'{{.NetworkSettings.IPAddress}}\' $app-%i`; \
curl -f $ip; \
if [ $? -eq 0 ]; then \
etcdctl set /services/$app/%i \'{"ip":"\'$ip\'", "port":"80"}\' --ttl 30; \
else \
etcdctl rm /services/$app/%i; \
fi; \
sleep 20; \
done'
# Stop
ExecStop=/bin/bash -ceux '\
app=`echo %p | cut -d"-" -f1`;\
/usr/bin/etcdctl rm /services/$app/%i

View file

@ -1,11 +1,16 @@
[Unit]
Description=%p-%i
After=docker.service
Requires=etcd.service
Requires=docker.service
Requires=mysql@%i.service
After=mysql@%i.service
Requires=%p-importer@%i.service
Requires=%p-discovery@%i.service
After=%p-importer@%i.service
Before=%p-discovery@%i.service
[Service]
Restart=always