Skip to content

Commit 55c830c

Browse files
committed
Merge pull request #14 from totem/develop
0.2 Release: Centralized Logging Support
2 parents 1886fc1 + b213c43 commit 55c830c

File tree

9 files changed

+18
-56
lines changed

9 files changed

+18
-56
lines changed

Dockerfile

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@ ENV DEBIAN_FRONTEND noninteractive
33
ENV ETCDCTL_VERSION v0.4.6
44

55
RUN apt-get update && \
6-
apt-get install -y haproxy/trusty-backports openssh-server nano
6+
apt-get install -y haproxy/trusty-backports nano
77

88
#AWS Cli and Supervisor
99
RUN pip install awscli==1.4.1 supervisor==3.1.2
1010

11-
#Syslog
12-
RUN echo '$PreserveFQDN on' | cat - /etc/rsyslog.conf > /tmp/rsyslog.conf && sudo mv /tmp/rsyslog.conf /etc/rsyslog.conf && \
13-
sed -i 's~^#\$ModLoad immark\(.*\)$~$ModLoad immark \1~' /etc/rsyslog.conf
14-
1511
#Haproxy
1612
RUN mkdir -p /run/haproxy && chown -R haproxy:haproxy /run/haproxy
1713
ADD ./bin/haproxy-wrapper.sh /usr/sbin/haproxy-wrapper.sh
@@ -23,13 +19,6 @@ RUN curl -L https://github.com/coreos/etcd/releases/download/$ETCDCTL_VERSION/et
2319
cp -f /tmp/etcd-$ETCDCTL_VERSION-linux-amd64/etcdctl /usr/local/bin && \
2420
rm -rf /tmp/etcd-$ETCDCTL_VERSION-linux-amd64.tar.gz
2521

26-
##SSH Server (To troubleshoot issues with image factory)
27-
RUN mkdir /var/run/sshd
28-
ADD root/.ssh/authorized_keys /root/.ssh/authorized_keys
29-
RUN chmod -R 400 /root/.ssh/* && \
30-
chmod 500 /root/.ssh && \
31-
chown -R root:root /root/.ssh
32-
3322
#Supervisor
3423
#Supervisor Config
3524
RUN mkdir -p /var/log/supervisor && \
@@ -39,7 +28,7 @@ ADD etc/supervisor/supervisord.conf /etc/supervisor/
3928
RUN ln -sf /etc/supervisor/supervisord.conf /etc/supervisord.conf
4029

4130
#Confd
42-
ENV CONFD_VERSION 0.6.3
31+
ENV CONFD_VERSION 0.7.1
4332
RUN curl -L https://github.com/kelseyhightower/confd/releases/download/v$CONFD_VERSION/confd-${CONFD_VERSION}-linux-amd64 -o /usr/local/bin/confd && \
4433
chmod 555 /usr/local/bin/confd
4534

@@ -61,8 +50,9 @@ ENV ETCD_PROXY_BASE /yoda
6150
ENV PROXY_HOST yoda.local.sh
6251
ENV SYNC_CERTS false
6352
ENV S3_YODA_BUCKET yoda-certs
53+
ENV LOG_IDENTIFIER yoda-proxy
6454

65-
EXPOSE 22 80 443 8081
55+
EXPOSE 80 443 8081
6656

6757
ENTRYPOINT ["/usr/local/bin/supervisord"]
6858
CMD ["-n"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Private Key, Public Key, CA Chain (In this order).
4747
Once ssl bucket is setup, simply run command below to start your proxy:
4848

4949
```
50-
sudo docker run --name yoda --rm -t -i -P -p 80:80 -p 443:443 -p 2022:22 -e AWS_ACCESS_KEY_ID=<<S3_ACCESS_KEY_ID>> -e AWS_SECRET_ACCESS_KEY=<<S3_SECRET_KEY>> -e S3_YODA_BUCKET=<<S3_BUCKET_NAME>> -e SYNC_CERTS=true totem/yoda-proxy
50+
sudo docker run --name yoda --rm -t -i -v /dev/log:/dev/log -P -p 80:80 -p 443:443 -p 2022:22 -e AWS_ACCESS_KEY_ID=<<S3_ACCESS_KEY_ID>> -e AWS_SECRET_ACCESS_KEY=<<S3_SECRET_KEY>> -e S3_YODA_BUCKET=<<S3_BUCKET_NAME>> -e SYNC_CERTS=true totem/yoda-proxy
5151
```
5252

5353
## ETCD Configuration

bin/confd-wrapper.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ $ETCDCTL get $LISTENER_PATH/admin/bind || $ETCDCTL set $LISTENER_PATH/admin/bind
2121
$ETCDCTL get $ETCD_PROXY_BASE/global/acls/public/cidr/src || $ETCDCTL set $ETCD_PROXY_BASE/global/acls/public/cidr/src "0.0.0.0/0"
2222
$ETCDCTL get $ETCD_PROXY_BASE/global/acls/global-black-list/cidr/src || $ETCDCTL set $ETCD_PROXY_BASE/global/acls/global-black-list/cidr/src ""
2323

24-
#Syslog ETCD Entries
25-
$ETCDCTL get $ETCD_PROXY_BASE/syslog/host || $ETCDCTL set $ETCD_PROXY_BASE/syslog/host ""
26-
27-
28-
sed -i -e "s/172.17.42.1[:]4001/$ETCD_URL/g" -e "s|/yoda|$ETCD_PROXY_BASE|g" /etc/confd/confd.toml
24+
sed -i -e "s/172.17.42.1[:]4001/$ETCD_URL/g" -e "s|/yoda|$ETCD_PROXY_BASE|" /etc/confd/confd.toml
2925
#sed -i -e "s|/yoda|$ETCD_PROXY_BASE|g" /etc/confd/conf.d/haproxy.toml
3026
confd

etc/confd/conf.d/10-syslog-central.toml

Lines changed: 0 additions & 11 deletions
This file was deleted.

etc/confd/templates/10-syslog-central.conf.tmpl

Lines changed: 0 additions & 1 deletion
This file was deleted.

etc/confd/templates/haproxy.cfg.tmpl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{/* Template for CIDRS: Required for reuse in Http and Https frontends */}}
22
{{define "CIDR_ACLS"}}{{if ls "/global/acls"}}{{ range $acl := gets "/global/acls/*/cidr/src" }}
3-
acl {{$acl.Key | parent | parent | base}} src {{$acl.Value}}
3+
acl {{$acl.Key | dir | dir | base}} src {{$acl.Value}}
44
{{ end }}{{ end }}{{ end }}
55

66
{{/* Global Black Listing */}}
@@ -14,14 +14,14 @@
1414
{{ end }}{{ end }}
1515

1616
{{/* Template for use_backends. */}}
17-
{{define "USE_BACKENDS"}}{{ range $host := ls "/hosts" }}{{if printf "/hosts/%s/locations" $host | ls }}{{ range $path := printf "/hosts/%s/locations/*/path" $host | gets}}{{ $pathName := $path.Key | parent | base }}
17+
{{define "USE_BACKENDS"}}{{ range $host := ls "/hosts" }}{{if printf "/hosts/%s/locations" $host | ls }}{{ range $path := printf "/hosts/%s/locations/*/path" $host | gets}}{{ $pathName := $path.Key | dir | base }}
1818
{{/* Do not include backends if upstream is empty or if it does not exist */}}
1919
{{ $upstream := printf "/hosts/%s/locations/%s/upstream" $host $pathName | getv}}{{ $endpoints := printf "/upstreams/%s/endpoints" $upstream | ls}}
2020
{{if and $upstream $endpoints}}use_backend {{printf "/hosts/%s/locations/%s/upstream" $host $pathName | getv }} if __host-{{$host}} __path-{{$host}}-{{$pathName}}{{ end }}
2121
{{ end }}{{ end }}{{ end }}{{ end }}
2222

2323
{{/* Template for force ssl */}}
24-
{{define "FORCE_SSL"}}{{ range $host := ls "/hosts" }}{{if printf "/hosts/%s/locations" $host | ls }}{{ range $path := printf "/hosts/%s/locations/*/path" $host | gets}}{{ $pathName := $path.Key | parent | base }}
24+
{{define "FORCE_SSL"}}{{ range $host := ls "/hosts" }}{{if printf "/hosts/%s/locations" $host | ls }}{{ range $path := printf "/hosts/%s/locations/*/path" $host | gets}}{{ $pathName := $path.Key | dir | base }}
2525
{{ if printf "/hosts/%s/locations/%s" $host $pathName | ls}}{{ if printf "/hosts/%s/locations/%s/force-ssl" $host $pathName | ls}}{{ if printf "/hosts/%s/locations/%s/force-ssl" $host $pathName | getv | eq "true"}}
2626
#Force SSL for $host/$pathName
2727
redirect scheme https code 301 if !{ ssl_fc } __host-{{$host}} __path-{{$host}}-{{$pathName}}
@@ -33,7 +33,7 @@
3333
{{ range $host := ls "/hosts" }}
3434
#Host ACL for host:{{$host}}
3535
acl __host-{{$host}} hdr_dom(host) -i -m str {{$host}} {{ if printf "/hosts/%s/aliases" $host | ls }}{{range $alias := printf "/hosts/%s/aliases/*" $host | getvs }}{{$alias}} {{ end }}{{ end }}
36-
{{ range $path := printf "/hosts/%s/locations/*/path" $host | gets}}{{ $pathName := $path.Key | parent | base }}
36+
{{ range $path := printf "/hosts/%s/locations/*/path" $host | gets}}{{ $pathName := $path.Key | dir | base }}
3737
#Path ACL for host:{{$host}} and path:{{$path}}
3838
acl __path-{{$host}}-{{$pathName}} path_beg {{$path.Value}}
3939
{{/* Deny Requests if host, path matches and any of cidrs matches */}}
@@ -56,6 +56,7 @@
5656
global
5757
log /dev/log local0
5858
log /dev/log local1 notice
59+
log-tag {{getenv "LOG_IDENTIFIER"}}
5960
chroot /var/lib/haproxy
6061
stats socket /run/haproxy/admin.sock mode 660 level admin
6162
stats timeout 30s
@@ -184,7 +185,7 @@ backend {{ $upstream }}
184185
{{ $health_interval := printf "%s/interval" $health }}
185186
{{ if $health_uri | ls }}option httpchk GET {{ $health_uri | getv }}{{ end }}
186187
{{ if $health_timeout | ls }}timeout check {{ $health_timeout | getv }}{{ end }}
187-
{{ range $endpoint := printf "/upstreams/%s/endpoints/*" $upstream | gets }}{{ $endpointName := $endpoint.Key | parent | base }}
188+
{{ range $endpoint := printf "/upstreams/%s/endpoints/*" $upstream | gets }}{{ $endpointName := $endpoint.Key | dir | base }}
188189
server {{ $endpointName }} {{ $endpoint.Value }} check inter {{ if $health_interval | ls }}{{$health_interval | getv}}{{ else }}2m{{ end }}
189190
{{ end }}
190191
{{ end }}{{ end }}

etc/supervisor/conf.d/supervisord.conf

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,19 @@ nodaemon=true
55
command=/usr/sbin/haproxy-wrapper.sh
66
autorestart=true
77
startsecs=5
8-
redirect_stderr=true
8+
stderr_logfile=syslog
99
stdout_logfile=syslog
1010

1111
[program:confd]
1212
command=/usr/sbin/confd-wrapper.sh
1313
autorestart=true
1414
startsecs=5
15-
redirect_stderr=true
16-
stdout_logfile=syslog
17-
18-
[program:sshd]
19-
command=/usr/sbin/sshd -D
20-
autorestart=true
21-
startsecs=5
22-
redirect_stderr=true
15+
stderr_logfile=syslog
2316
stdout_logfile=syslog
2417

2518
[program:synccerts]
2619
command=/usr/sbin/sync-certs.sh
2720
autorestart=true
2821
startsecs=5
29-
redirect_stderr=true
30-
stdout_logfile=syslog
31-
32-
[program:rsyslog]
33-
command=rsyslogd -n -c5
34-
autostart=true
35-
autorestart=true
36-
redirect_stderr=true
22+
stderr_logfile=syslog
23+
stdout_logfile=syslog

root/.ssh/authorized_keys

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/integration/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from threading import Thread
1212

1313
DOCKER = os.environ.get('DOCKER_CMD', 'docker -H 127.0.0.1:8283')
14-
ETCD_PROXY_BASE = os.environ.get('ETCD_PROXY_BASE', '/yoda-integration')
14+
ETCD_PROXY_BASE = os.environ.get('ETCD_PROXY_BASE', '/test-yoda-integration')
1515
ETCD_HOST = os.environ.get('ETCD_HOST', 'localhost')
1616
ETCD_PORT = int(os.environ.get('ETCD_PORT', '4001'))
1717
MOCK_TCP_PORT = int(os.environ.get('MOCK_TCP_PORT', '31325'))
@@ -33,6 +33,7 @@ def setup_yoda():
3333
build_yoda()
3434
check_call(
3535
'{DOCKER} run --name yoda-integration -d -P -p 80:80 -p 443:443 '
36+
'-v /dev/log:/dev/log '
3637
'-p {MOCK_TCP_PORT}:{MOCK_TCP_PORT} -e ETCD_PROXY_BASE'
3738
'={ETCD_PROXY_BASE} -h yoda-integration-{USER} totem/yoda-integration'
3839
.format(DOCKER=DOCKER, ETCD_PROXY_BASE=ETCD_PROXY_BASE,

0 commit comments

Comments
 (0)