Skip to content

Commit e59bad4

Browse files
committed
feat(Makefile): add kube service targets
1 parent eb38af6 commit e59bad4

5 files changed

Lines changed: 91 additions & 22 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ client/makeself/
2626
docs/_build/
2727
docs/docs.zip
2828
docs/dummy.sqlite3
29+
manifests/*.tmp
2930

3031
# coverage reports
3132
.coverage

Makefile

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ ifndef BUILD_TAG
22
BUILD_TAG = git-$(shell git rev-parse --short HEAD)
33
endif
44

5-
COMPONENT = workflow
6-
IMAGE = $(IMAGE_PREFIX)$(COMPONENT):$(BUILD_TAG)
7-
SHELL_SCRIPTS = $(wildcard rootfs/bin/*) $(shell find "rootfs" -name '*.sh')
5+
COMPONENT=workflow
6+
IMAGE_PREFIX ?= $(DEV_REGISTRY)/deis/
7+
IMAGE=$(IMAGE_PREFIX)$(COMPONENT):$(BUILD_TAG)
8+
SHELL_SCRIPTS=$(wildcard rootfs/bin/*) $(shell find "rootfs" -name '*.sh')
89

910
check-docker:
1011
@if [ -z $$(which docker) ]; then \
@@ -17,9 +18,33 @@ build: docker-build
1718
docker-build: check-docker
1819
docker build --rm -t $(IMAGE) rootfs
1920

20-
docker-push:
21+
docker-push: update-manifests
2122
docker push ${IMAGE}
2223

24+
kube-delete:
25+
-kubectl delete service deis-workflow
26+
-kubectl delete rc deis-workflow
27+
28+
kube-delete-database:
29+
-kubectl delete service deis-database
30+
-kubectl delete rc deis-database
31+
32+
kube-delete-all: kube-delete kube-delete-database
33+
34+
kube-create:
35+
kubectl create -f manifests/deis-workflow-rc.yml.tmp
36+
kubectl create -f manifests/deis-workflow-service.yml
37+
38+
kube-create-database:
39+
kubectl create -f manifests/deis-database-rc.yml
40+
kubectl create -f manifests/deis-database-service.yml
41+
42+
kube-create-all: kube-create-database kube-create
43+
44+
update-manifests:
45+
sed 's#\(image:\) .*#\1 $(IMAGE)#' manifests/deis-workflow-rc.yml \
46+
> manifests/deis-workflow-rc.yml.tmp
47+
2348
clean: check-docker
2449
docker rmi $(IMAGE)
2550

@@ -41,15 +66,18 @@ setup-venv:
4166
@if [ ! -d venv ]; then virtualenv venv; fi
4267
venv/bin/pip install --disable-pip-version-check -q -r rootfs/requirements.txt -r rootfs/dev_requirements.txt
4368

44-
test: test-style test-unit
69+
test: test-style test-unit test-functional
70+
71+
test-style:
72+
cd rootfs && flake8 --show-pep8 --show-source
73+
shellcheck $(SHELL_SCRIPTS)
4574

4675
test-unit:
4776
cd rootfs \
4877
&& coverage run manage.py test --noinput web registry api \
4978
&& coverage report -m
5079

51-
test-style:
52-
cd rootfs && flake8 --show-pep8 --show-source
53-
shellcheck $(SHELL_SCRIPTS)
80+
test-functional:
81+
@echo "Implement functional tests in _tests directory"
5482

55-
.PHONY: build clean commit-hook full-clean postgres setup-venv test test-unit test-style
83+
.PHONY: build clean commit-hook full-clean postgres setup-venv test test-style test-unit test-functional

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,55 @@ Deis (pronounced DAY-iss) is an open source PaaS that makes it easy to deploy an
1010

1111
Deis Workflow v2 is changing quickly. Your feedback and participation are more than welcome, but be aware that this project is considered a work in progress.
1212

13+
## Hacking Workflow
14+
15+
First, install [deis/etcd](https://github.com/deis/etcd) as described in its documentation. Ensure that the deis-etcd-service is running and healthy by accessing its port 4001 and seeing that the environment variable `DEIS_ETCD_1_SERVICE_HOST` is set.
16+
17+
One way to test this by running commands from another pod in the same namespace:
18+
19+
```console
20+
$ kubectl exec alpine -- env | grep DEIS_ETCD_1_SERVICE | sort
21+
DEIS_ETCD_1_SERVICE_HOST=10.247.187.217
22+
DEIS_ETCD_1_SERVICE_PORT=2380
23+
DEIS_ETCD_1_SERVICE_PORT_CLIENT=4100
24+
DEIS_ETCD_1_SERVICE_PORT_PEER=2380
25+
$ kubectl exec alpine -- curl -sS 10.247.187.217:4100/version
26+
{"etcdserver":"2.2.1","etcdcluster":"2.2.0"}
27+
```
28+
29+
Next build the deis/workflow image and push it to a Docker registry. The `$DEV_REGISTRY` environment variable must point to a registry accessible to your Kubernetes cluster. You may need to configure the Docker engines on your Kubernetes nodes to allow `--insecure-registry 192.168.0.0/16` (or the appropriate address range).
30+
31+
```console
32+
$ make docker-build docker-push
33+
```
34+
35+
Finally create a PostgreSQL database and the Deis workflow service:
36+
```console
37+
$ make kube-create-all
38+
kubectl create -f manifests/deis-database-rc.yml
39+
replicationcontrollers/deis-database
40+
kubectl create -f manifests/deis-database-service.yml
41+
services/deis-database
42+
kubectl create -f manifests/deis-workflow-rc.yml.tmp
43+
replicationcontrollers/deis-workflow
44+
kubectl create -f manifests/deis-workflow-service.yml
45+
services/deis-workflow
46+
$ kubectl get pod
47+
NAME READY STATUS RESTARTS AGE
48+
deis-database-34ch4 1/1 Running 0 12m
49+
deis-etcd-1-140w7 1/1 Running 2 1h
50+
deis-etcd-1-3jib8 1/1 Running 2 1h
51+
deis-etcd-1-qf9ab 1/1 Running 2 1h
52+
deis-etcd-discovery-dp2kp 1/1 Running 0 1h
53+
deis-workflow-e8qks 1/1 Running 0 12m
54+
$ kubectl logs deis-workflow-e8qks
55+
+ export ETCD_PORT=4100
56+
+ ETCD_PORT=4100
57+
+ export ETCD_HOST=10.247.187.217
58+
+ ETCD_HOST=10.247.187.217
59+
...
60+
```
61+
1362
## License
1463

1564
Copyright 2013, 2014, 2015 Engine Yard, Inc.

manifests/deis-workflow-pod.yml

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

manifests/deis-workflow-rc.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ spec:
1515
spec:
1616
containers:
1717
- name: deis-workflow
18-
image: 192.168.99.100:5000/deis/workflow:git-3b9ce13
18+
image: deis/workflow:latest
19+
env:
20+
- name: DEBUG
21+
value: "true"
1922
ports:
2023
- containerPort: 8000

0 commit comments

Comments
 (0)