Skip to content

Commit 787d857

Browse files
committed
fix(services): manage dependencies manually
Since fleet's dependency management cross-cluster is lacking (see coreos/fleet#338), we resort to starting the services in a certain order. We also remove Requires=/After= if the dependency could potentially exist on another server in the cluster. We're essentially waiting for X-Requires/X-After to be implemented in fleet. Also, we make the contrib/ scripts use this Makefile to start services so we don't repeat logic. Lastly, fleet version checking is added to the Makefile so that it will error if fleetctl locally is a different version than the server - many unstable/incomplete changes are in master. fixes #810, #805
1 parent 0a8e71b commit 787d857

9 files changed

Lines changed: 88 additions & 121 deletions

File tree

Makefile

Lines changed: 77 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,104 @@
22
# Deis Makefile
33
#
44

5+
ifndef FLEETCTL_TUNNEL
6+
$(error You need to set FLEETCTL_TUNNEL to the IP address of a server in the cluster.)
7+
endif
8+
59
ifndef DEIS_NUM_INSTANCES
6-
DEIS_NUM_INSTANCES = 1
10+
DEIS_NUM_INSTANCES = 1
711
endif
812

13+
# TODO refactor to support non-vagrant installations, since this Makefile
14+
# is now used by the various contrib/ scripts.
915
define ssh_all
10-
i=1 ; while [ $$i -le $(DEIS_NUM_INSTANCES) ] ; do \
11-
vagrant ssh deis-$$i -c $(1) ; \
12-
i=`expr $$i + 1` ; \
13-
done
16+
i=1 ; while [ $$i -le $(DEIS_NUM_INSTANCES) ] ; do \
17+
vagrant ssh deis-$$i -c $(1) ; \
18+
i=`expr $$i + 1` ; \
19+
done
1420
endef
1521

16-
# ordered list of deis components
17-
# we don't manage the router if we're setting up a local cluster
22+
define echo_yellow
23+
@echo "\033[0;33m$(subst ",,$(1))\033[0m"
24+
endef
25+
26+
# due to scheduling problems with fleet 0.2.0, start order of components
27+
# is fragile. hopefully this can be changed soon...
28+
ALL_COMPONENTS=builder cache controller database logger registry router
29+
1830
ifeq ($(DEIS_NUM_INSTANCES),1)
19-
COMPONENTS=builder cache controller database logger registry router
31+
export SKIP_ROUTER=false
32+
START_COMPONENTS=registry logger cache database router
2033
else
21-
COMPONENTS=builder cache controller database logger registry
34+
export SKIP_ROUTER=true
35+
START_COMPONENTS=registry logger cache database
2236
endif
2337

24-
UNIT_FILES = $(foreach C, $(COMPONENTS), $(wildcard $(C)/systemd/*))
38+
ALL_UNITS = $(foreach C, $(ALL_COMPONENTS), $(wildcard $(C)/systemd/*))
39+
START_UNITS = $(foreach C, $(START_COMPONENTS), $(wildcard $(C)/systemd/*))
2540

2641
all: build run
2742

28-
pull:
29-
$(call ssh_all,'for c in $(COMPONENTS); do docker pull deis/$$c; done')
30-
3143
build:
32-
$(call ssh_all,'cd share && for c in $(COMPONENTS); do cd $$c && docker build -t deis/$$c . && cd ..; done')
44+
$(call ssh_all,'cd share && for c in $(ALL_COMPONENTS); do cd $$c && docker build -t deis/$$c . && cd ..; done')
3345

34-
install:
35-
fleetctl --strict-host-key-checking=false submit $(UNIT_FILES)
46+
check-fleet:
47+
@LOCAL_VERSION=`fleetctl -version`; \
48+
REMOTE_VERSION=`ssh core@$(FLEETCTL_TUNNEL) fleetctl -version`; \
49+
if [ "$$LOCAL_VERSION" != "$$REMOTE_VERSION" ]; then \
50+
echo "Your fleetctl client version should match the server. Local version: $$LOCAL_VERSION, server version: $$REMOTE_VERSION. Uninstall your local version and install the latest build from https://github.com/coreos/fleet/releases"; exit 1; \
51+
fi
52+
53+
clean: uninstall
54+
$(call ssh_all,'for c in $(ALL_COMPONENTS); do docker rm -f deis-$$c; done')
3655

37-
uninstall: stop
38-
fleetctl --strict-host-key-checking=false destroy $(UNIT_FILES)
56+
full-clean: clean
57+
$(call ssh_all,'for c in $(ALL_COMPONENTS); do docker rmi deis-$$c; done')
3958

40-
start:
41-
echo "\033[0;33mStarting services can take some time... grab some coffee!\033[0m"
42-
fleetctl --strict-host-key-checking=false start $(UNIT_FILES)
59+
install: check-fleet
60+
fleetctl --strict-host-key-checking=false submit $(START_UNITS)
4361

44-
stop:
45-
fleetctl --strict-host-key-checking=false stop $(UNIT_FILES)
62+
pull:
63+
$(call ssh_all,'for c in $(ALL_COMPONENTS); do docker pull deis/$$c; done')
4664

4765
restart: stop start
4866

4967
run: install start
5068

51-
clean: uninstall
52-
$(call ssh_all,'for c in $(COMPONENTS); do docker rm -f deis-$$c; done')
69+
start: check-fleet
70+
fleetctl --strict-host-key-checking=false start $(START_UNITS)
71+
$(call echo_yellow,"Use 'make status' to monitor these services")
72+
$(call echo_yellow,"Run 'make start-builder' to continue once all are running")
5373

54-
full-clean: clean
55-
$(call ssh_all,'for c in $(COMPONENTS); do docker rmi deis-$$c; done')
74+
start-builder: check-fleet
75+
fleetctl --strict-host-key-checking=false submit builder/systemd/*
76+
fleetctl --strict-host-key-checking=false start builder/systemd/*
77+
$(call echo_yellow,"Use 'make status' to monitor the service")
78+
$(call echo_yellow,"Run 'make start-controller' to continue once the service is running")
79+
80+
start-controller: check-fleet
81+
fleetctl --strict-host-key-checking=false submit controller/systemd/*
82+
fleetctl --strict-host-key-checking=false start controller/systemd/*
83+
$(call echo_yellow,"Use 'make status' to monitor the service")
84+
@if [ "$$SKIP_ROUTER" == true ]; then \
85+
echo "\033[0;33mYou'll need to configure DNS and start the router manually for multi-node clusters.\033[0m" ; \
86+
echo "\033[0;33mRun 'make start-router' to schedule and start deis-router.\033[0m" ; \
87+
else \
88+
echo "\033[0;33mYour Deis cluster is ready to go once the controller is live! Follow the README to login and use Deis.\033[0m" ; \
89+
fi
90+
91+
start-router: check-fleet
92+
fleetctl --strict-host-key-checking=false submit router/systemd/*
93+
fleetctl --strict-host-key-checking=false start router/systemd/*
94+
$(call echo_yellow,"Use 'make status' to monitor the service and note the IP it has been scheduled to.")
95+
$(call echo_yellow,"Create a wildcard DNS domain which resolves to this host and use that domain when creating clusters/apps in the README.")
96+
$(call echo_yellow,"Your Deis cluster is ready to go! Follow the README to login and use Deis.")
97+
98+
status: check-fleet
99+
fleetctl --strict-host-key-checking=false list-units
100+
101+
stop: check-fleet
102+
fleetctl --strict-host-key-checking=false stop $(ALL_UNITS)
103+
104+
uninstall: check-fleet stop
105+
fleetctl --strict-host-key-checking=false destroy $(ALL_UNITS)

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ Trying out Deis? Continue following these instructions for a local cluster setup
2626
## Install prerequisites
2727
On your workstation:
2828
* Install [Vagrant](http://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
29-
* Install [Go](http://golang.org/doc/install) and configure your GOPATH, if necessary
30-
* Install the fleetctl client: `go get github.com/coreos/fleet && go install github.com/coreos/fleet/fleetctl`
29+
* Install the fleetctl client: Install v0.2.0 from the [fleet GitHub page](https://github.com/coreos/fleet/releases).
3130
* Install the Docker client if you want to run Docker commands locally (optional)
3231

3332
## Additional setup for a multi-node cluster

builder/systemd/deis-builder.service

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
[Unit]
22
Description=deis-builder
3-
Requires=deis-registry.service
4-
After=deis-registry.service
53

64
[Service]
75
TimeoutStartSec=20m
@@ -13,5 +11,7 @@ ExecStop=/usr/bin/docker rm -f deis-builder
1311
[Install]
1412
WantedBy=multi-user.target
1513

14+
# We only need this so that when we start controller, it's guaranteed to be scheduled
15+
# (If logger and builder are on separate machines, controller can never be scheduled)
1616
[X-Fleet]
17-
X-ConditionMachineOf=deis-controller.service
17+
X-ConditionMachineOf=deis-logger.service

contrib/ec2/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ Please wait for it to come up, then run ./initialize-ec2-cluster.sh
4848

4949
## Initialize the cluster
5050
Once the cluster is up, get the hostname of any of the machines from EC2, set
51-
FLEETCTL_TUNNEL, then run [the init script][init-script] to bootstrap the cluster
52-
remotely:
51+
FLEETCTL_TUNNEL, and issue a `make run` from the project root:
5352
```console
5453
$ ssh-add ~/.ssh/id_rsa
5554
$ export FLEETCTL_TUNNEL=ec2-12-345-678-90.us-west-1.compute.amazonaws.com
56-
$ ./initialize-ec2-cluster.sh
55+
$ cd ../.. && make run
5756
The authenticity of host '54.215.248.50:22' can't be established.
5857
RSA key fingerprint is 86:10:74:b9:6a:ee:3b:21:d0:0f:b4:63:cc:10:64:c9.
5958
Are you sure you want to continue connecting (yes/no)? yes
@@ -92,4 +91,3 @@ email: info@opdemand.com
9291
[template]: https://s3.amazonaws.com/coreos.com/dist/aws/coreos-alpha.template
9392
[cf-params]: cloudformation.json
9493
[pro-script]: provision-ec2-cluster.sh
95-
[init-script]: initialize-ec2-cluster.sh

contrib/ec2/initialize-ec2-cluster.sh

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

contrib/rackspace/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ $ DEIS_NUM_INSTANCES=5 ./provision-rackspace-cluster.sh deis-key
4848
```
4949

5050
### Initialize the cluster
51-
Once the cluster is up, get the IP address for any of the machines in the cluster, set
52-
FLEETCTL_TUNNEL, and run [the init script](initialize-rackspace-cluster.sh) to bootstrap the cluster
53-
remotely:
51+
Once the cluster is up, get the hostname of any of the machines from EC2, set
52+
FLEETCTL_TUNNEL, and issue a `make run` from the project root:
5453
```console
5554
$ export FLEETCTL_TUNNEL=23.253.219.94
56-
$ ./initialize-rackspace-cluster.sh
55+
$ cd ../.. && make run
5756
The authenticity of host '23.253.219.94:22' can't be established.
5857
RSA key fingerprint is ce:3a:c1:3a:ad:11:bd:60:84:8e:60:a8:2f:19:1a:a6.
5958
Are you sure you want to continue connecting (yes/no)? yes

contrib/rackspace/initialize-rackspace-cluster.sh

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

contrib/rackspace/provision-rackspace-cluster.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fi
3232

3333
i=1 ; while [[ $i -le $DEIS_NUM_INSTANCES ]] ; do \
3434
echo_yellow "Provisioning deis-$i..."
35-
supernova production boot --image 6bdbd558-e66c-49cc-9ff3-126e7411f602 --flavor $FLAVOR --key-name $1 --user-data ../coreos/user-data --config-drive true deis-$i ; \
35+
supernova production boot --image c431c19c-4c09-48ef-a7c1-f4a43f65a1de --flavor $FLAVOR --key-name $1 --user-data ../coreos/user-data --config-drive true deis-$i ; \
3636
((i = i + 1)) ; \
3737
done
3838

controller/systemd/deis-controller.service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ WantedBy=multi-user.target
1414

1515
[X-Fleet]
1616
X-ConditionMachineOf=deis-logger.service
17+
X-ConditionMachineOf=deis-builder.service

0 commit comments

Comments
 (0)