Skip to content

Commit 2fa11dd

Browse files
committed
Merge pull request #1026 from deis/deis_hosts
fix(Makefile): enable targets to work for non-Vagrant
2 parents adedc89 + c0eae21 commit 2fa11dd

11 files changed

Lines changed: 200 additions & 176 deletions

File tree

Makefile

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,7 @@
22
# Deis Makefile
33
#
44

5-
ifndef FLEETCTL
6-
FLEETCTL = fleetctl --strict-host-key-checking=false
7-
endif
8-
9-
ifndef FLEETCTL_TUNNEL
10-
$(error You need to set FLEETCTL_TUNNEL to the IP address of a server in the cluster.)
11-
endif
12-
13-
ifndef DEIS_NUM_INSTANCES
14-
DEIS_NUM_INSTANCES = 1
15-
endif
16-
17-
ifndef DEIS_NUM_ROUTERS
18-
DEIS_NUM_ROUTERS = 1
19-
endif
20-
21-
ifndef DEIS_FIRST_ROUTER
22-
DEIS_FIRST_ROUTER = 1
23-
endif
24-
25-
DEIS_LAST_ROUTER = $(shell echo $(DEIS_FIRST_ROUTER)\+$(DEIS_NUM_ROUTERS)\-1 | bc)
26-
27-
# TODO refactor to support non-vagrant installations, since this Makefile
28-
# is now used by the various contrib/ scripts.
29-
define ssh_all
30-
i=1 ; while [ $$i -le $(DEIS_NUM_INSTANCES) ] ; do \
31-
vagrant ssh deis-$$i -c $(1) ; \
32-
i=`expr $$i + 1` ; \
33-
done
34-
endef
5+
include includes.mk
356

367
define check_for_errors
378
@if $(FLEETCTL) list-units -no-legend | awk '(($$2 == "launched") && ($$5 == "failed"))' | egrep -q "deis-.+service"; then \
@@ -48,37 +19,19 @@ define deis_units
4819
sed -n 's/\(deis-.*\.service\).*/\1/p' | tr '\n' ' ')
4920
endef
5021

51-
define echo_cyan
52-
@echo "\033[0;36m$(subst ",,$(1))\033[0m"
53-
endef
54-
55-
define echo_yellow
56-
@echo "\033[0;33m$(subst ",,$(1))\033[0m"
57-
endef
58-
59-
# TODO: re-evaluate the start order now that we're on fleet 0.3.2.
60-
# due to scheduling problems with fleet 0.2.0, start order of components
61-
# is fragile. hopefully this can be changed soon...
22+
# TODO: re-evaluate the fragile start order now that we're on fleet 0.3.2.
6223
COMPONENTS=builder cache controller database logger registry
6324
ALL_COMPONENTS=$(COMPONENTS) router
6425
START_COMPONENTS=registry logger cache database
6526

6627
ALL_UNITS = $(foreach C,$(COMPONENTS),$(wildcard $(C)/systemd/*))
6728
START_UNITS = $(foreach C,$(START_COMPONENTS),$(wildcard $(C)/systemd/*))
68-
ROUTER_UNITS = $(shell seq -f "deis-router.%g.service" -s " " $(DEIS_FIRST_ROUTER) 1 $(DEIS_LAST_ROUTER))
6929

7030
all: build run
7131

7232
build:
7333
$(call ssh_all,'cd share && for c in $(ALL_COMPONENTS); do cd $$c && docker build -t deis/$$c . && cd ..; done')
7434

75-
check-fleet:
76-
@LOCAL_VERSION=`$(FLEETCTL) -version`; \
77-
REMOTE_VERSION=`ssh -o StrictHostKeyChecking=no core@$(subst :, -p ,$(FLEETCTL_TUNNEL)) fleetctl -version`; \
78-
if [ "$$LOCAL_VERSION" != "$$REMOTE_VERSION" ]; then \
79-
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; \
80-
fi
81-
8235
clean: uninstall
8336
$(call ssh_all,'for c in $(ALL_COMPONENTS); do docker rm -f deis-$$c; done')
8437

builder/Makefile

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
build:
2-
vagrant ssh -c 'cd share/builder && docker build -t deis/builder .'
1+
include ../includes.mk
32

4-
install:
5-
vagrant ssh -c 'sudo systemctl enable /home/core/share/builder/systemd/*'
3+
build:
4+
$(call ssh_all,'cd share/builder && docker build -t deis/builder .')
65

7-
uninstall: stop
8-
vagrant ssh -c 'sudo systemctl disable /home/core/share/builder/systemd/*'
6+
install: check-fleet
7+
$(FLEETCTL) load systemd/*
98

10-
start:
11-
vagrant ssh -c 'sudo systemctl start deis-builder.service'
9+
uninstall: check-fleet stop
10+
$(FLEETCTL) unload systemd/*
11+
$(FLEETCTL) destroy systemd/*
1212

13-
stop:
14-
vagrant ssh -c 'sudo systemctl stop deis-builder.service'
13+
start: check-fleet
14+
$(FLEETCTL) start -no-block systemd/*
1515

16-
restart:
17-
vagrant ssh -c 'sudo systemctl restart deis-builder.service'
16+
stop: check-fleet
17+
$(FLEETCTL) stop -block-attempts=600 systemd/*
1818

19-
logs:
20-
vagrant ssh -c 'sudo journalctl -f -u deis-builder.service'
19+
restart: stop start
2120

22-
run: install restart logs
21+
run: install start
2322

2423
clean: uninstall
25-
vagrant ssh -c 'sudo docker rm -f deis-builder'
24+
$(call ssh_all,'sudo docker rm -f deis-builder')
2625

2726
full-clean: clean
28-
vagrant ssh -c 'sudo docker rmi deis/builder'
27+
$(call ssh_all,'sudo docker rmi deis/builder')

cache/Makefile

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
build:
2-
vagrant ssh -c 'cd share/cache && sudo docker build -t deis/cache .'
1+
include ../includes.mk
32

4-
install:
5-
vagrant ssh -c 'sudo systemctl enable /home/core/share/cache/systemd/*'
3+
build:
4+
$(call ssh_all,'cd share/cache && sudo docker build -t deis/cache .')
65

7-
uninstall: stop
8-
vagrant ssh -c 'sudo systemctl disable /home/core/share/cache/systemd/*'
6+
install: check-fleet
7+
$(FLEETCTL) load systemd/*
98

10-
start:
11-
vagrant ssh -c 'sudo systemctl start deis-cache.service'
9+
uninstall: check-fleet stop
10+
$(FLEETCTL) unload systemd/*
11+
$(FLEETCTL) destroy systemd/*
1212

13-
stop:
14-
vagrant ssh -c 'sudo systemctl stop deis-cache.service'
13+
start: check-fleet
14+
$(FLEETCTL) start -no-block systemd/*
1515

16-
restart:
17-
vagrant ssh -c 'sudo systemctl restart deis-cache.service'
16+
stop: check-fleet
17+
$(FLEETCTL) stop -block-attempts=600 systemd/*
1818

19-
logs:
20-
vagrant ssh -c 'sudo journalctl -f -u deis-cache.service'
19+
restart: stop start
2120

22-
run: install restart logs
21+
run: install start
2322

2423
clean: uninstall
25-
vagrant ssh -c 'sudo docker rm -f deis-cache'
24+
$(call ssh_all,'sudo docker rm -f deis-cache')
2625

2726
full-clean: clean
28-
vagrant ssh -c 'sudo docker rmi deis/cache'
27+
$(call ssh_all,'sudo docker rmi deis/cache')

contrib/ec2/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,22 @@ you configure your own DNS records using a domain you own. See [Configuring DNS]
8282

8383
## Use Deis!
8484
After that, register with Deis!
85-
```
85+
```console
8686
$ deis register deis.example.org:8000
8787
username: deis
8888
password:
8989
password (confirm):
9090
email: info@opdemand.com
9191
```
9292

93+
## Hack on Deis
94+
If you'd like to use this deployment to build Deis, you'll need to set `DEIS_HOSTS` to an array of your cluster hosts:
95+
```console
96+
$ export DEIS_HOSTS=1.2.3.4 1.2.3.5 1.2.3.6
97+
```
98+
99+
This variable is used in the `make build` command.
100+
93101
[aws-cli]: https://github.com/aws/aws-cli
94102
[template]: https://s3.amazonaws.com/coreos.com/dist/aws/coreos-alpha.template
95103
[pro-script]: provision-ec2-cluster.sh

contrib/rackspace/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,18 @@ You'll need to configure DNS records so you can access applications hosted on De
7777

7878
### Use Deis!
7979
After that, register with Deis!
80-
```
80+
```console
8181
$ deis register deis.example.org:8000
8282
username: deis
8383
password:
8484
password (confirm):
8585
email: info@opdemand.com
8686
```
87+
88+
## Hack on Deis
89+
If you'd like to use this deployment to build Deis, you'll need to set `DEIS_HOSTS` to an array of your cluster hosts:
90+
```console
91+
$ export DEIS_HOSTS=10.21.12.1 10.21.12.2 10.21.12.3
92+
```
93+
94+
This variable is used in the `make build` command.

controller/Makefile

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
1+
include ../includes.mk
2+
13
.PHONY: all test logs
24

35
all: build run
46

57
build:
6-
vagrant ssh -c 'cd share/controller && sudo docker build -t deis/controller .'
7-
8-
install:
9-
vagrant ssh -c 'sudo systemctl enable /home/core/share/controller/systemd/*'
8+
$(call ssh_all,'cd share/controller && sudo docker build -t deis/controller .')
109

11-
uninstall: stop
12-
vagrant ssh -c 'sudo systemctl disable /home/core/share/controller/systemd/*'
10+
install: check-fleet
11+
$(FLEETCTL) load systemd/*
1312

14-
start:
15-
vagrant ssh -c 'sudo systemctl start deis-controller.service'
13+
uninstall: check-fleet stop
14+
$(FLEETCTL) unload systemd/*
15+
$(FLEETCTL) destroy systemd/*
1616

17-
stop:
18-
vagrant ssh -c 'sudo systemctl stop deis-controller.service'
17+
start: check-fleet
18+
$(FLEETCTL) start -no-block systemd/*
1919

20-
restart:
21-
vagrant ssh -c 'sudo systemctl restart deis-controller.service'
20+
stop: check-fleet
21+
$(FLEETCTL) stop -block-attempts=600 systemd/*
2222

23-
logs:
24-
vagrant ssh -c 'sudo journalctl -f -u deis-controller.service'
23+
restart: stop start
2524

26-
run: install restart logs
25+
run: install start
2726

2827
clean: uninstall
29-
vagrant ssh -c 'sudo docker rm -f deis-controller'
28+
$(call ssh_all,'sudo docker rm -f deis-controller')
3029

3130
full-clean: clean
32-
vagrant ssh -c 'sudo docker rmi deis/controller'
31+
$(call ssh_all,'sudo docker rmi deis/controller')
3332

3433
test:
3534
python manage.py test --noinput api web

database/Makefile

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
build:
2-
vagrant ssh -c 'cd share/database && sudo docker build -t deis/database .'
1+
include ../includes.mk
32

4-
install:
5-
vagrant ssh -c 'sudo systemctl enable /home/core/share/database/systemd/*'
3+
build:
4+
$(call ssh_all,'cd share/database && sudo docker build -t deis/database .')
65

7-
uninstall: stop
8-
vagrant ssh -c 'sudo systemctl disable /home/core/share/database/systemd/*'
6+
install: check-fleet
7+
$(FLEETCTL) load systemd/*
98

10-
start:
11-
vagrant ssh -c 'sudo systemctl start deis-database.service'
9+
uninstall: check-fleet stop
10+
$(FLEETCTL) unload systemd/*
11+
$(FLEETCTL) destroy systemd/*
1212

13-
stop:
14-
vagrant ssh -c 'sudo systemctl stop deis-database.service'
13+
start: check-fleet
14+
$(FLEETCTL) start -no-block systemd/*
1515

16-
restart:
17-
vagrant ssh -c 'sudo systemctl restart deis-database.service'
16+
stop: check-fleet
17+
$(FLEETCTL) stop -block-attempts=600 systemd/*
1818

19-
logs:
20-
vagrant ssh -c 'sudo journalctl -f -u deis-database.service'
19+
restart: stop start
2120

22-
run: install restart logs
21+
run: install start
2322

2423
clean: uninstall
25-
vagrant ssh -c 'sudo docker rm -f deis-database'
24+
$(call ssh_all,'sudo docker rm -f deis-database')
2625

2726
full-clean: clean
28-
vagrant ssh -c 'sudo docker rmi deis/database'
27+
$(call ssh_all,'sudo docker rmi deis/database')

includes.mk

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
ifndef FLEETCTL
2+
FLEETCTL = fleetctl --strict-host-key-checking=false
3+
endif
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+
9+
ifndef DEIS_NUM_INSTANCES
10+
DEIS_NUM_INSTANCES = 1
11+
endif
12+
13+
ifndef DEIS_HOSTS
14+
DEIS_HOSTS = $(shell seq -f "172.17.8.%g" -s " " 100 1 `expr $(DEIS_NUM_INSTANCES) + 99` )
15+
endif
16+
17+
ifndef DEIS_NUM_ROUTERS
18+
DEIS_NUM_ROUTERS = 1
19+
endif
20+
21+
ifndef DEIS_FIRST_ROUTER
22+
DEIS_FIRST_ROUTER = 1
23+
endif
24+
25+
DEIS_LAST_ROUTER = $(shell echo $(DEIS_FIRST_ROUTER)\+$(DEIS_NUM_ROUTERS)\-1 | bc)
26+
27+
define ssh_all
28+
for host in $(DEIS_HOSTS); do ssh -o LogLevel=FATAL -o Compression=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PasswordAuthentication=no core@$$host -t $(1); done
29+
endef
30+
31+
define echo_cyan
32+
@echo "\033[0;36m$(subst ",,$(1))\033[0m"
33+
endef
34+
35+
define echo_yellow
36+
@echo "\033[0;33m$(subst ",,$(1))\033[0m"
37+
endef
38+
39+
ROUTER_UNITS = $(shell seq -f "deis-router.%g.service" -s " " $(DEIS_FIRST_ROUTER) 1 $(DEIS_LAST_ROUTER))
40+
41+
check-fleet:
42+
@LOCAL_VERSION=`$(FLEETCTL) -version`; \
43+
REMOTE_VERSION=`ssh -o StrictHostKeyChecking=no core@$(subst :, -p ,$(FLEETCTL_TUNNEL)) fleetctl -version`; \
44+
if [ "$$LOCAL_VERSION" != "$$REMOTE_VERSION" ]; then \
45+
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; \
46+
fi

logger/Makefile

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
build:
2-
vagrant ssh -c 'cd share/logger && sudo docker build -t deis/logger .'
1+
include ../includes.mk
32

4-
install:
5-
vagrant ssh -c 'sudo systemctl enable /home/core/share/logger/systemd/*'
3+
build:
4+
$(call ssh_all,'cd share/logger && sudo docker build -t deis/logger .')
65

7-
uninstall: stop
8-
vagrant ssh -c 'sudo systemctl disable /home/core/share/logger/systemd/*'
6+
install: check-fleet
7+
$(FLEETCTL) load systemd/*
98

10-
start:
11-
vagrant ssh -c 'sudo systemctl start deis-logger.service'
9+
uninstall: check-fleet stop
10+
$(FLEETCTL) unload systemd/*
11+
$(FLEETCTL) destroy systemd/*
1212

13-
stop:
14-
vagrant ssh -c 'sudo systemctl stop deis-logger.service'
13+
start: check-fleet
14+
$(FLEETCTL) start -no-block systemd/*
1515

16-
restart:
17-
vagrant ssh -c 'sudo systemctl restart deis-logger.service'
16+
stop: check-fleet
17+
$(FLEETCTL) stop -block-attempts=600 systemd/*
1818

19-
logs:
20-
vagrant ssh -c 'sudo journalctl -f -u deis-logger.service'
19+
restart: stop start
2120

22-
run: install restart logs
21+
run: install start
2322

2423
clean: uninstall
25-
vagrant ssh -c 'sudo docker rm -f deis-logger'
24+
$(call ssh_all,'sudo docker rm -f deis-logger')
2625

2726
full-clean: clean
28-
vagrant ssh -c 'sudo docker rmi deis/logger'
27+
$(call ssh_all,'sudo docker rmi deis/logger')

0 commit comments

Comments
 (0)