|
2 | 2 | # Deis Makefile |
3 | 3 | # |
4 | 4 |
|
| 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 | + |
5 | 9 | ifndef DEIS_NUM_INSTANCES |
6 | | - DEIS_NUM_INSTANCES = 1 |
| 10 | + DEIS_NUM_INSTANCES = 1 |
7 | 11 | endif |
8 | 12 |
|
| 13 | +# TODO refactor to support non-vagrant installations, since this Makefile |
| 14 | +# is now used by the various contrib/ scripts. |
9 | 15 | 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 |
14 | 20 | endef |
15 | 21 |
|
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 | + |
18 | 30 | 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 |
20 | 33 | else |
21 | | - COMPONENTS=builder cache controller database logger registry |
| 34 | + export SKIP_ROUTER=true |
| 35 | + START_COMPONENTS=registry logger cache database |
22 | 36 | endif |
23 | 37 |
|
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/*)) |
25 | 40 |
|
26 | 41 | all: build run |
27 | 42 |
|
28 | | -pull: |
29 | | - $(call ssh_all,'for c in $(COMPONENTS); do docker pull deis/$$c; done') |
30 | | - |
31 | 43 | 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') |
33 | 45 |
|
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') |
36 | 55 |
|
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') |
39 | 58 |
|
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) |
43 | 61 |
|
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') |
46 | 64 |
|
47 | 65 | restart: stop start |
48 | 66 |
|
49 | 67 | run: install start |
50 | 68 |
|
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") |
53 | 73 |
|
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) |
0 commit comments