aboutsummaryrefslogtreecommitdiff
path: root/docker/centos/binary/hautoproxy
diff options
context:
space:
mode:
authorPaul Bourke <paul.bourke@oracle.com>2015-06-17 11:14:59 +0000
committerPaul Bourke <paul.bourke@oracle.com>2015-06-19 17:12:05 +0000
commit897337cdd61f1702aa7e68da0466804bf0d21a86 (patch)
treed8489ef0f286ff69f10ebe0b42eca6cf8b1cc123 /docker/centos/binary/hautoproxy
parentc2b05b576f45ddf432571f817be45e6bcb188f75 (diff)
downloadkolla-897337cdd61f1702aa7e68da0466804bf0d21a86.tar.gz
kolla-897337cdd61f1702aa7e68da0466804bf0d21a86.zip
Symlink all non Dockerfile resources in images
The only files in the docker image directories that differ majorly between distros are the Dockerfiles (e.g. different package manager mechanisms, different repo sources, etc). The supporting files such as the start.sh/check.sh and config files should largely stay the same between base images. This change moves these files up into a "common" directory, and symlinks them in the same way that the build script is managed. This means when adding a new base distro only new Dockerfiles need to be created. Also, if a distro does happen to require a vastly different start.sh script for example, one can choose to simply not symlink to the common and instead drop in a custom one. Implements: blueprint refactor-base-image-layout Change-Id: Ic4db69d31ff54a1fb95af4853a2e5ae490064284
Diffstat (limited to 'docker/centos/binary/hautoproxy')
l---------[-rw-r--r--]docker/centos/binary/hautoproxy/haproxy.cfg.tmpl27
l---------[-rwxr-xr-x]docker/centos/binary/hautoproxy/start.py66
2 files changed, 2 insertions, 91 deletions
diff --git a/docker/centos/binary/hautoproxy/haproxy.cfg.tmpl b/docker/centos/binary/hautoproxy/haproxy.cfg.tmpl
index cd1174b21..dc3f45c31 100644..120000
--- a/docker/centos/binary/hautoproxy/haproxy.cfg.tmpl
+++ b/docker/centos/binary/hautoproxy/haproxy.cfg.tmpl
@@ -1,26 +1 @@
-global
- daemon
- maxconn 4096
- pidfile /var/run/haproxy.pid
-
-defaults
- mode tcp
- timeout connect 5s
- timeout client 1m
- timeout server 1m
- option redispatch
- balance roundrobin
-
-listen stats :1936
- mode http
- stats enable
- stats hide-version
- #stats realm Haproxy\ Statistics
- stats uri /
- #stats auth Username:Password
-
-{% for service in services %}
-listen {{ service.service_name }}
- bind 127.0.0.1:{{service.local_port}}
- server {{ service.remote_name }} {{ service.remote_addr }}:{{ service.remote_port}} check inter 2s rise 3 fall 2
-{% endfor %}
+../../../common/hautoproxy/haproxy.cfg.tmpl \ No newline at end of file
diff --git a/docker/centos/binary/hautoproxy/start.py b/docker/centos/binary/hautoproxy/start.py
index 877b22157..f89efa2f8 100755..120000
--- a/docker/centos/binary/hautoproxy/start.py
+++ b/docker/centos/binary/hautoproxy/start.py
@@ -1,65 +1 @@
-#!/usr/bin/python
-
-'''This script configures and starts a local haproxy instances, bound to
-127.0.0.1, that forwards connections all of the discovered
-docker/kubernetes environment variables.'''
-
-import argparse
-import os
-import sys
-from jinja2 import Environment, FileSystemLoader
-import re
-import urlparse
-
-re_url = re.compile(
- '^(?P<name>.*)_PORT_(?P<port>\d+)_(?P<proto>(UDP|TCP))$')
-
-def parse_args():
- p = argparse.ArgumentParser()
- p.add_argument('--output', '-o',
- default='/etc/haproxy/haproxy.cfg')
- p.add_argument('--no-start', '-n',
- action='store_true')
- p.add_argument('--template-dir', '-t',
- default='/etc/haproxy/templates')
- return p.parse_args()
-
-def discover_services():
- services = []
- for k in os.environ:
- mo = re_url.match(k)
-
- if mo:
- parts = urlparse.urlparse(os.environ[k])
- remote_host,remote_port = parts.netloc.split(':')
- service_name = '%(name)s-%(port)s' % mo.groupdict()
-
- services.append({
- 'remote_name': mo.group('name'),
- 'remote_addr': remote_host,
- 'remote_port': remote_port,
- 'remote_proto': parts.scheme,
- 'local_port': mo.group('port'),
- 'service_name': service_name,
- })
-
- return services
-
-def main():
- args = parse_args()
- services = discover_services()
-
- env = Environment(loader=FileSystemLoader(['.',
- args.template_dir]))
- template = env.get_template('haproxy.cfg.tmpl')
- with open(args.output, 'w') as fd:
- fd.write(template.render(services=services))
-
- if args.no_start:
- return
-
- os.execlp('haproxy', 'haproxy', '-f', args.output, '-db')
-
-if __name__ == '__main__':
- main()
-
+../../../common/hautoproxy/start.py \ No newline at end of file