-
-
Notifications
You must be signed in to change notification settings - Fork 204
/
Makefile
137 lines (106 loc) · 3.94 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
AIRFLOW_VERSION ?= 1.8.0.0
KUBECTL_VERSION ?= 1.6.1
KUBE_AIRFLOW_VERSION ?= 0.10
REPOSITORY ?= mumoshu/kube-airflow
TAG ?= $(AIRFLOW_VERSION)-$(KUBECTL_VERSION)-$(KUBE_AIRFLOW_VERSION)
IMAGE ?= $(REPOSITORY):$(TAG)
ALIAS ?= $(REPOSITORY):$(AIRFLOW_VERSION)-$(KUBECTL_VERSION)
BUILD_ROOT ?= build/$(TAG)
DOCKERFILE ?= $(BUILD_ROOT)/Dockerfile
ROOTFS ?= $(BUILD_ROOT)/rootfs
AIRFLOW_CONF ?= $(BUILD_ROOT)/config/airflow.cfg
ENTRYPOINT_SH ?= $(BUILD_ROOT)/script/entrypoint.sh
GIT_SYNC ?= $(BUILD_ROOT)/script/git-sync
DAGS ?= $(BUILD_ROOT)/dags
AIRFLOW_REQUIREMENTS ?= $(BUILD_ROOT)/requirements/airflow.txt
DAGS_REQUIREMENTS ?= $(BUILD_ROOT)/requirements/dags.txt
DOCKER_CACHE ?= docker-cache
SAVED_IMAGE ?= $(DOCKER_CACHE)/image-$(AIRFLOW_VERSION)-$(KUBECTL_VERSION).tar
NAMESPACE ?= airflow-dev
HELM_APPLICATION_NAME ?= airflow
HELM_VALUES ?= airflow/values.yaml
CHART_LOCATION ?= ./airflow
EMBEDDED_DAGS_LOCATION ?= "./dags"
REQUIREMENTS_TXT_LOCATION ?= "requirements/dags.txt"
.PHONY: build clean
clean:
rm -Rf build
helm-install:
helm upgrade -f $(HELM_VALUES) \
--install \
--debug \
$(HELM_APPLICATION_NAME) \
$(CHART_LOCATION)
helm-check:
helm install --dry_run \
$(CHART_LOCATION) \
--version=v0.1.0 \
--name=$(HELM_APPLICATION_NAME) \
--namespace=$(NAMESPACE) \
--debug \
-f $(HELM_VALUES)
helm-ls:
helm ls --all $(HELM_APPLICATION_NAME)
helm-uninstall:
helm del --purge $(HELM_APPLICATION_NAME)
build: clean $(DOCKERFILE) $(ROOTFS) $(DAGS) $(AIRFLOW_CONF) $(ENTRYPOINT_SH) $(GIT_SYNC) $(AIRFLOW_REQUIREMENTS) $(DAGS_REQUIREMENTS)
cd $(BUILD_ROOT) && docker build -t $(IMAGE) . && docker tag $(IMAGE) $(ALIAS)
publish:
docker push $(IMAGE) && docker push $(ALIAS)
$(DOCKERFILE): $(BUILD_ROOT)
sed -e 's/%%KUBECTL_VERSION%%/'"$(KUBECTL_VERSION)"'/g;' \
-e 's/%%AIRFLOW_VERSION%%/'"$(AIRFLOW_VERSION)"'/g;' \
-e 's#%%EMBEDDED_DAGS_LOCATION%%#'"$(EMBEDDED_DAGS_LOCATION)"'#g;' \
-e 's#%%REQUIREMENTS_TXT_LOCATION%%#'"$(REQUIREMENTS_TXT_LOCATION)"'#g;' \
Dockerfile.template > $(DOCKERFILE)
$(ROOTFS): $(BUILD_ROOT)
mkdir -p rootfs
cp -R rootfs $(ROOTFS)
$(AIRFLOW_CONF): $(BUILD_ROOT)
mkdir -p $(shell dirname $(AIRFLOW_CONF))
cp config/airflow.cfg $(AIRFLOW_CONF)
$(ENTRYPOINT_SH): $(BUILD_ROOT)
mkdir -p $(shell dirname $(ENTRYPOINT_SH))
cp script/entrypoint.sh $(ENTRYPOINT_SH)
$(GIT_SYNC): $(BUILD_ROOT)
mkdir -p $(shell dirname $(GIT_SYNC))
cp script/git-sync $(GIT_SYNC)
$(AIRFLOW_REQUIREMENTS): $(BUILD_ROOT)
mkdir -p $(shell dirname $(AIRFLOW_REQUIREMENTS))
cp requirements/airflow.txt $(AIRFLOW_REQUIREMENTS)
$(DAGS_REQUIREMENTS): $(BUILD_ROOT)
mkdir -p $(shell dirname $(DAGS_REQUIREMENTS))
cp $(REQUIREMENTS_TXT_LOCATION) $(DAGS_REQUIREMENTS)
$(DAGS): $(BUILD_ROOT)
mkdir -p $(shell dirname $(DAGS))
cp -R $(EMBEDDED_DAGS_LOCATION) $(DAGS)
$(BUILD_ROOT):
mkdir -p $(BUILD_ROOT)
travis-env:
travis env set DOCKER_EMAIL $(DOCKER_EMAIL)
travis env set DOCKER_USERNAME $(DOCKER_USERNAME)
travis env set DOCKER_PASSWORD $(DOCKER_PASSWORD)
test:
@echo There are no tests available for now. Skipping
save-docker-cache: $(DOCKER_CACHE)
docker save $(IMAGE) $(shell docker history -q $(IMAGE) | tail -n +2 | grep -v \<missing\> | tr '\n' ' ') > $(SAVED_IMAGE)
ls -lah $(DOCKER_CACHE)
load-docker-cache: $(DOCKER_CACHE)
if [ -e $(SAVED_IMAGE) ]; then docker load < $(SAVED_IMAGE); fi
$(DOCKER_CACHE):
mkdir -p $(DOCKER_CACHE)
create:
if ! kubectl get namespace $(NAMESPACE) >/dev/null 2>&1; then \
kubectl create namespace $(NAMESPACE); \
fi
kubectl create -f airflow.all.yaml --namespace $(NAMESPACE)
apply:
kubectl apply -f airflow.all.yaml --namespace $(NAMESPACE)
delete:
kubectl delete -f airflow.all.yaml --namespace $(NAMESPACE)
list-pods:
kubectl get po -a --namespace $(NAMESPACE)
browse-web:
minikube service web -n $(NAMESPACE)
browse-flower:
minikube service flower -n $(NAMESPACE)