Skip to content

Commit bdbf50b

Browse files
committed
Merge pull request #969 from deis/multiple_routers
feat(router): support for multiple routers
2 parents e26eb39 + f330bfd commit bdbf50b

6 files changed

Lines changed: 57 additions & 10 deletions

File tree

Makefile

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ ifndef DEIS_NUM_INSTANCES
1010
DEIS_NUM_INSTANCES = 1
1111
endif
1212

13+
ifndef DEIS_NUM_ROUTERS
14+
DEIS_NUM_ROUTERS = 1
15+
endif
16+
17+
ifndef DEIS_FIRST_ROUTER
18+
DEIS_FIRST_ROUTER = 1
19+
endif
20+
1321
# TODO refactor to support non-vagrant installations, since this Makefile
1422
# is now used by the various contrib/ scripts.
1523
define ssh_all
@@ -34,8 +42,8 @@ endef
3442

3543
# due to scheduling problems with fleet 0.2.0, start order of components
3644
# is fragile. hopefully this can be changed soon...
37-
ALL_COMPONENTS=builder cache controller database logger registry router
38-
START_COMPONENTS=registry logger cache database router
45+
ALL_COMPONENTS=builder cache controller database logger registry
46+
START_COMPONENTS=registry logger cache database
3947

4048
ALL_UNITS = $(foreach C, $(ALL_COMPONENTS), $(wildcard $(C)/systemd/*))
4149
START_UNITS = $(foreach C, $(START_COMPONENTS), $(wildcard $(C)/systemd/*))
@@ -67,10 +75,22 @@ pull:
6775

6876
restart: stop start
6977

78+
routers:
79+
$(call echo_yellow,"Starting $(DEIS_NUM_ROUTERS) router(s)...")
80+
@router_num=$(DEIS_FIRST_ROUTER) ; \
81+
i=1 ; while [ $$i -le $(DEIS_NUM_ROUTERS) ] ; do \
82+
cp router/systemd/deis-router.service ./deis-router.$$router_num.service ; \
83+
fleetctl --strict-host-key-checking=false submit ./deis-router.$$router_num.service ; \
84+
fleetctl --strict-host-key-checking=false start ./deis-router.$$router_num.service ; \
85+
rm -f ./deis-router.$$router_num.service ; \
86+
i=`expr $$i + 1` ; \
87+
router_num=`expr $$router_num + 1` ; \
88+
done
89+
7090
run: install start
7191

72-
start: check-fleet
73-
@# registry logger cache database (router)
92+
start: check-fleet routers
93+
@# registry logger cache database
7494
$(call echo_yellow,"Starting Deis! Deis will be functional once all services are reported as running... ")
7595
fleetctl --strict-host-key-checking=false start $(START_UNITS)
7696
$(call echo_yellow,"Waiting for deis-registry to start (this can take some time)... ")

docs/operations/configure-dns.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66
Configure DNS
77
-------------
88

9-
For a one-node cluster, both deis-router and deis-controller will run on the same host. For convenience, we've created the DNS record ``local.deisapp.com`` which resolves to the IP of the first VM, 172.17.8.100.
10-
You can use ``local.deisapp.com`` to both log into the controller and to access applications that you've deployed (they will be subdomains of ``local.deisapp.com``, like ``happy-unicorn.local.deisapp.com``).
9+
For local one-node Vagrant clusters, we've created the DNS record ``local.deisapp.com`` which resolves to the IP of the first VM, 172.17.8.100.
10+
You can use ``local.deisapp.com`` to both log into the controller and to access applications that you've deployed (they will be subdomains of ``local.deisapp.com``, like ``happy-unicorn.local.deisapp.com``). So, no further DNS configuration is necessary.
1111

12-
On a multi-node cluster, however, the router and controller will likely be scheduled on separate machines. Since we cannot know the IP addresses ahead of time, you'll need to setup resolution yourself using your own domain (unfortunately, wildcard hostnames are not permitted in ``/etc/hosts``). The records should be as follows:
12+
For a non-local one-node cluster, we schedule and launch one router, and deis-router and deis-controller will run on the same host. So, both DNS records can be configured to point to this one machine.
1313

14+
On a multi-node cluster, however, there are probably multiple routers, and the controller will likely be scheduled on a separate machine. As mentioned in :ref:`configure-load-balancers`, a load balancer is recommended in this scenario.
15+
16+
Note that the controller will eventually live behind the routers so that all external traffic will flow through the load balancer - configuring a DNS record which points to a service whose IP could change is less than ideal.
17+
18+
Necessary DNS records
19+
---------------------
20+
21+
The DNS records for Deis should be configured as such:
1422
* ``deis.example.org`` should resolve to the IP of the machine that runs ``deis-controller``
15-
* ``*.deis.example.org`` (a wildcard DNS entry) should resolve to the IP of the machine that runs ``deis-router``
23+
* ``*.deis.example.org`` (a wildcard DNS entry) should point to the load balancer (or the same machine for 1-node Vagrant, or any single instance of ``deis-router`` if one likes to live life on the edge)
1624

17-
These records are necessary for multi-node Vagrant as well as any other multi-node deployments of Deis (EC2, Rackspace, etc.).
25+
These records are necessary for all deployments of Deis (EC2, Rackspace, multi-node Vagrant) except for a local, one-node Vagrant setup, which can use ``local.deisapp.com``.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
:title: Configure load balancers
2+
:description: Configure load balancers for your Deis Cluster
3+
4+
.. _configure-load-balancers:
5+
6+
Configure load balancers
7+
------------------------
8+
9+
For a one-node Deis cluster, there is one router and one controller, so load balancing is unnecessary. You can proceed with the next section: :ref:`configure-dns`.
10+
11+
On a multi-node cluster, however, there are probably multiple routers scheduled to the cluster, and these can potentially move hosts. Therefore, it is recommended that you configure a load balancer to operate in front of the Deis cluster to serve application traffic. A simple configuration is one that has all Deis machines listed in its configuration file, but a host is only considered 'healthy' when it is serving traffic on port 80. This enables the load balancer to serve trafic to whichever hosts happen to be running the deis-router component at any one time.
12+
13+
The load balancer is also the suggested SSL termination point, as SSL is not currently supported between Deis components.
14+
15+
Further documentation around load balancers is planned for Deis 1.0.

docs/operations/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ Operations Guide
1515
provision-controller
1616
register-admin-user
1717
manage-controller
18+
configure-load-balancers
1819
configure-dns

router/bin/boot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ set -eo pipefail
1212
# configure etcd
1313
export ETCD_PORT=${ETCD_PORT:-4001}
1414
export ETCD="$HOST:$ETCD_PORT"
15-
export ETCD_PATH=${ETCD_PATH:-/deis/router}
15+
export ETCD_PATH=${ETCD_PATH:-/deis/router/$HOST}
1616
export ETCD_TTL=${ETCD_TTL:-10}
1717

1818
# wait for etcd to be available

router/systemd/deis-router.service

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ ExecStop=/usr/bin/docker rm -f deis-router
1111

1212
[Install]
1313
WantedBy=multi-user.target
14+
15+
[X-Fleet]
16+
X-Conflicts=deis-router.*.service

0 commit comments

Comments
 (0)