1515# limitations under the License.
1616
1717SHELL := /bin/bash
18- -include ./dev/config/env.sh
19- export $(shell sed 's/=.*//' ./dev/config/env.sh 2>/dev/null)
18+ export BASH_ENV =./dev/config/env.sh
19+
20+ # declare all targets as phony to avoid collisions with local files or folders
21+ .PHONY : $(MAKECMDGOALS )
2022
2123# ######
2224# Dev #
@@ -25,208 +27,219 @@ export $(shell sed 's/=.*//' ./dev/config/env.sh 2>/dev/null)
2527# Cortex
2628
2729# build cli, start local operator, and watch for changes
28- .PHONY : devstart
29- devstart :
30- @$(MAKE ) operator-stop || true
31- @./dev/operator_local.sh || true
30+ devstart-aws :
31+ @$(MAKE ) operator-stop-aws || true
32+ @./dev/operator_local.sh --aws || true
33+ devstart-gcp :
34+ @$(MAKE ) operator-stop-gcp || true
35+ @./dev/operator_local.sh --gcp || true
3236
33- .PHONY : cli
3437cli :
3538 @mkdir -p ./bin
3639 @go build -o ./bin/cortex ./cli
3740
3841# build cli and watch for changes
39- .PHONY : cli-watch
4042cli-watch :
4143 @rerun -watch ./pkg ./cli -run sh -c " clear && echo 'building cli...' && go build -o ./bin/cortex ./cli && clear && echo '\033[1;32mCLI built\033[0m'" || true
4244
4345# start local operator and watch for changes
44- .PHONY : operator-local
45- operator-local :
46- @$(MAKE ) operator-stop || true
47- @./dev/operator_local.sh --operator-only || true
48-
49- # configure kubectl to point to the cluster specified in dev/config/cluster.yaml
50- .PHONY : kubectl
51- kubectl :
52- @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster.yaml ) && eksctl utils write-kubeconfig --cluster=" $$ CORTEX_CLUSTER_NAME" --region=" $$ CORTEX_REGION" | grep -v " saved kubeconfig as" | grep -v " using region" | grep -v " eksctl version" || true
53-
54- .PHONY : cluster-up
55- cluster-up :
56- @$(MAKE ) registry-all
46+ operator-local-aws :
47+ @$(MAKE ) operator-stop-aws || true
48+ @./dev/operator_local.sh --operator-only --aws || true
49+ operator-local-gcp :
50+ @$(MAKE ) operator-stop-gcp || true
51+ @./dev/operator_local.sh --operator-only --gcp || true
52+
53+ # configure kubectl to point to the cluster specified in dev/config/cluster-[aws|gcp].yaml
54+ kubectl-aws :
55+ @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml ) && eksctl utils write-kubeconfig --cluster=" $$ CORTEX_CLUSTER_NAME" --region=" $$ CORTEX_REGION" | grep -v " saved kubeconfig as" | grep -v " using region" | grep -v " eksctl version" || true
56+ kubectl-gcp :
57+ @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-gcp.yaml ) && gcloud container clusters get-credentials " $$ CORTEX_CLUSTER_NAME" --zone " $$ CORTEX_ZONE" --project " $$ CORTEX_PROJECT" 2>&1 | grep -v " Fetching cluster" | grep -v " kubeconfig entry generated" || true
58+
59+ cluster-up-aws :
60+ @$(MAKE ) images-all-aws
61+ @$(MAKE ) cli
62+ @kill $(shell pgrep -f rerun) > /dev/null 2>&1 || true
63+ @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml ) && ./bin/cortex cluster up --config=./dev/config/cluster-aws.yaml --configure-env=" $$ CORTEX_CLUSTER_NAME-aws" --aws-key=$$ AWS_ACCESS_KEY_ID --aws-secret=$$ AWS_SECRET_ACCESS_KEY --cluster-aws-key=$$ CLUSTER_AWS_ACCESS_KEY_ID --cluster-aws-secret=$$ CLUSTER_AWS_SECRET_ACCESS_KEY && ./bin/cortex env default " $$ CORTEX_CLUSTER_NAME-aws"
64+ @$(MAKE ) kubectl-aws
65+ cluster-up-gcp :
66+ @$(MAKE ) images-all-gcp
5767 @$(MAKE ) cli
5868 @kill $(shell pgrep -f rerun) > /dev/null 2>&1 || true
59- @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster.yaml ) && ./bin/cortex cluster up --config=./dev/config/cluster.yaml --configure-env=" $$ CORTEX_CLUSTER_NAME" --aws-key= $$ AWS_ACCESS_KEY_ID --aws-secret= $$ AWS_SECRET_ACCESS_KEY --cluster-aws-key= $$ CLUSTER_AWS_ACCESS_KEY_ID --cluster-aws-secret= $$ CLUSTER_AWS_SECRET_ACCESS_KEY && ./bin/cortex env default " $$ CORTEX_CLUSTER_NAME"
60- @$(MAKE ) kubectl
69+ @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-gcp .yaml ) && ./bin/cortex cluster-gcp up --config=./dev/config/cluster-gcp .yaml --configure-env=" $$ CORTEX_CLUSTER_NAME-gcp " && ./bin/cortex env default " $$ CORTEX_CLUSTER_NAME-gcp "
70+ @$(MAKE ) kubectl-gcp
6171
62- .PHONY : cluster-up-y
63- cluster-up-y :
64- @$(MAKE ) registry-all
72+ cluster-up-aws-y :
73+ @$(MAKE ) images-all-aws
6574 @$(MAKE ) cli
6675 @kill $(shell pgrep -f rerun) > /dev/null 2>&1 || true
67- @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster.yaml ) && ./bin/cortex cluster up --config=./dev/config/cluster.yaml --configure-env=" $$ CORTEX_CLUSTER_NAME" --aws-key=$$ AWS_ACCESS_KEY_ID --aws-secret=$$ AWS_SECRET_ACCESS_KEY --cluster-aws-key=$$ CLUSTER_AWS_ACCESS_KEY_ID --cluster-aws-secret=$$ CLUSTER_AWS_SECRET_ACCESS_KEY --yes && ./bin/cortex env default " $$ CORTEX_CLUSTER_NAME"
68- @$(MAKE ) kubectl
76+ @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml ) && ./bin/cortex cluster up --config=./dev/config/cluster-aws.yaml --configure-env=" $$ CORTEX_CLUSTER_NAME-aws" --aws-key=$$ AWS_ACCESS_KEY_ID --aws-secret=$$ AWS_SECRET_ACCESS_KEY --cluster-aws-key=$$ CLUSTER_AWS_ACCESS_KEY_ID --cluster-aws-secret=$$ CLUSTER_AWS_SECRET_ACCESS_KEY --yes && ./bin/cortex env default " $$ CORTEX_CLUSTER_NAME-aws"
77+ @$(MAKE ) kubectl-aws
78+ cluster-up-gcp-y :
79+ @$(MAKE ) images-all-gcp
80+ @$(MAKE ) cli
81+ @kill $(shell pgrep -f rerun) > /dev/null 2>&1 || true
82+ @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-gcp.yaml ) && ./bin/cortex cluster-gcp up --config=./dev/config/cluster-gcp.yaml --configure-env=" $$ CORTEX_CLUSTER_NAME-gcp" --yes && ./bin/cortex env default " $$ CORTEX_CLUSTER_NAME-gcp"
83+ @$(MAKE ) kubectl-gcp
6984
70- .PHONY : cluster-down
71- cluster-down :
72- @$(MAKE ) manager-local
85+ cluster-down-aws :
86+ @$(MAKE ) images-manager-local
87+ @$(MAKE ) cli
88+ @kill $(shell pgrep -f rerun) > /dev/null 2>&1 || true
89+ @./bin/cortex cluster down --config=./dev/config/cluster-aws.yaml --aws-key=$$ AWS_ACCESS_KEY_ID --aws-secret=$$ AWS_SECRET_ACCESS_KEY
90+ cluster-down-gcp :
91+ @$(MAKE ) images-manager-local
7392 @$(MAKE ) cli
7493 @kill $(shell pgrep -f rerun) > /dev/null 2>&1 || true
75- @./bin/cortex cluster down --config=./dev/config/cluster.yaml --aws-key= $$ AWS_ACCESS_KEY_ID --aws-secret= $$ AWS_SECRET_ACCESS_KEY
94+ @./bin/cortex cluster-gcp down --config=./dev/config/cluster-gcp .yaml
7695
77- .PHONY : cluster-down-y
78- cluster-down-y :
79- @$(MAKE ) manager-local
96+ cluster-down-aws-y :
97+ @$(MAKE ) images-manager-local
8098 @$(MAKE ) cli
8199 @kill $(shell pgrep -f rerun) > /dev/null 2>&1 || true
82- @./bin/cortex cluster down --config=./dev/config/cluster.yaml --aws-key=$$ AWS_ACCESS_KEY_ID --aws-secret=$$ AWS_SECRET_ACCESS_KEY --yes
100+ @./bin/cortex cluster down --config=./dev/config/cluster-aws.yaml --aws-key=$$ AWS_ACCESS_KEY_ID --aws-secret=$$ AWS_SECRET_ACCESS_KEY --yes
101+ cluster-down-gcp-y :
102+ @$(MAKE ) images-manager-local
103+ @$(MAKE ) cli
104+ @kill $(shell pgrep -f rerun) > /dev/null 2>&1 || true
105+ @./bin/cortex cluster-gcp down --config=./dev/config/cluster-gcp.yaml --yes
83106
84- .PHONY : cluster-info
85- cluster-info :
86- @$(MAKE ) manager-local
107+ cluster-info-aws :
108+ @$(MAKE ) images-manager-local
87109 @$(MAKE ) cli
88- @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster.yaml ) && ./bin/cortex cluster info --config=./dev/config/cluster.yaml --configure-env=" $$ CORTEX_CLUSTER_NAME" --aws-key=$$ AWS_ACCESS_KEY_ID --aws-secret=$$ AWS_SECRET_ACCESS_KEY && ./bin/cortex env default " $$ CORTEX_CLUSTER_NAME"
110+ @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml ) && ./bin/cortex cluster info --config=./dev/config/cluster-aws.yaml --configure-env=" $$ CORTEX_CLUSTER_NAME-aws" --aws-key=$$ AWS_ACCESS_KEY_ID --aws-secret=$$ AWS_SECRET_ACCESS_KEY && ./bin/cortex env default " $$ CORTEX_CLUSTER_NAME-aws"
111+ cluster-info-gcp :
112+ @$(MAKE ) images-manager-local
113+ @$(MAKE ) cli
114+ @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-gcp.yaml ) && ./bin/cortex cluster-gcp info --config=./dev/config/cluster-gcp.yaml --configure-env=" $$ CORTEX_CLUSTER_NAME-gcp" && ./bin/cortex env default " $$ CORTEX_CLUSTER_NAME-gcp"
89115
90- .PHONY : cluster-configure
91- cluster-configure :
92- @$(MAKE ) registry-all
116+ cluster-configure-aws :
117+ @$(MAKE ) images-all-aws
93118 @$(MAKE ) cli
94119 @kill $(shell pgrep -f rerun) > /dev/null 2>&1 || true
95- @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster.yaml ) && ./bin/cortex cluster configure --config=./dev/config/cluster.yaml --configure-env=" $$ CORTEX_CLUSTER_NAME" --aws-key=$$ AWS_ACCESS_KEY_ID --aws-secret=$$ AWS_SECRET_ACCESS_KEY --cluster-aws-key=$$ CLUSTER_AWS_ACCESS_KEY_ID --cluster-aws-secret=$$ CLUSTER_AWS_SECRET_ACCESS_KEY && ./bin/cortex env default " $$ CORTEX_CLUSTER_NAME"
96-
97- .PHONY : cluster-configure-y
98- cluster-configure-y :
99- @$(MAKE ) registry-all
120+ @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml ) && ./bin/cortex cluster configure --config=./dev/config/cluster-aws.yaml --configure-env=" $$ CORTEX_CLUSTER_NAME-aws" --aws-key=$$ AWS_ACCESS_KEY_ID --aws-secret=$$ AWS_SECRET_ACCESS_KEY --cluster-aws-key=$$ CLUSTER_AWS_ACCESS_KEY_ID --cluster-aws-secret=$$ CLUSTER_AWS_SECRET_ACCESS_KEY && ./bin/cortex env default " $$ CORTEX_CLUSTER_NAME-aws"
121+ # cluster-configure-gcp:
122+ # @$(MAKE) images-all-gcp
123+ # @$(MAKE) cli
124+ # @kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
125+ # @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-gcp.yaml) && ./bin/cortex cluster-gcp configure --config=./dev/config/cluster-gcp.yaml --configure-env="$$CORTEX_CLUSTER_NAME-gcp" && ./bin/cortex env default "$$CORTEX_CLUSTER_NAME-gcp"
126+
127+ cluster-configure-aws-y :
128+ @$(MAKE ) images-all-aws
100129 @$(MAKE ) cli
101130 @kill $(shell pgrep -f rerun) > /dev/null 2>&1 || true
102- @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster.yaml ) && ./bin/cortex cluster configure --config=./dev/config/cluster.yaml --configure-env=" $$ CORTEX_CLUSTER_NAME" --aws-key=$$ AWS_ACCESS_KEY_ID --aws-secret=$$ AWS_SECRET_ACCESS_KEY --cluster-aws-key=$$ CLUSTER_AWS_ACCESS_KEY_ID --cluster-aws-secret=$$ CLUSTER_AWS_SECRET_ACCESS_KEY --yes && ./bin/cortex env default " $$ CORTEX_CLUSTER_NAME"
131+ @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml ) && ./bin/cortex cluster configure --config=./dev/config/cluster-aws.yaml --configure-env=" $$ CORTEX_CLUSTER_NAME-aws" --aws-key=$$ AWS_ACCESS_KEY_ID --aws-secret=$$ AWS_SECRET_ACCESS_KEY --cluster-aws-key=$$ CLUSTER_AWS_ACCESS_KEY_ID --cluster-aws-secret=$$ CLUSTER_AWS_SECRET_ACCESS_KEY --yes && ./bin/cortex env default " $$ CORTEX_CLUSTER_NAME-aws"
132+ # cluster-configure-gcp-y:
133+ # @$(MAKE) images-all-gcp
134+ # @$(MAKE) cli
135+ # @kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
136+ # @eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-gcp.yaml) && ./bin/cortex cluster-gcp configure --config=./dev/config/cluster-gcp.yaml --configure-env="$$CORTEX_CLUSTER_NAME-gcp" --yes && ./bin/cortex env default "$$CORTEX_CLUSTER_NAME-gcp"
103137
104138# stop the in-cluster operator
105- .PHONY : operator-stop
106- operator-stop :
107- @$(MAKE ) kubectl
139+ operator-stop-aws :
140+ @$(MAKE ) kubectl-aws
141+ @kubectl delete --namespace=default --ignore-not-found=true deployment operator
142+ operator-stop-gcp :
143+ @$(MAKE ) kubectl-gcp
108144 @kubectl delete --namespace=default --ignore-not-found=true deployment operator
109145
110146# Docker images
111147
112- .PHONY : registry-all
113- registry-all :
114- @./dev/registry.sh update all
115- .PHONY : registry-all-local
116- registry-all-local :
117- @./dev/registry.sh update all --skip-push
118- .PHONY : registry-all-slim
119- registry-all-slim :
120- @./dev/registry.sh update all --include-slim
121- .PHONY : registry-all-slim-local
122- registry-all-slim-local :
123- @./dev/registry.sh update all --include-slim --skip-push
124- .PHONY : registry-all-local-slim
125- registry-all-local-slim :
126- @./dev/registry.sh update all --include-slim --skip-push
127-
128- .PHONY : registry-dev
129- registry-dev :
130- @./dev/registry.sh update dev
131- .PHONY : registry-dev-local
132- registry-dev-local :
133- @./dev/registry.sh update dev --skip-push
134- .PHONY : registry-dev-slim
135- registry-dev-slim :
136- @./dev/registry.sh update dev --include-slim
137- .PHONY : registry-dev-slim-local
138- registry-dev-slim-local :
139- @./dev/registry.sh update dev --include-slim --skip-push
140- .PHONY : registry-dev-local-slim
141- registry-dev-local-slim :
142- @./dev/registry.sh update dev --include-slim --skip-push
143-
144- .PHONY : registry-api
145- registry-api :
146- @./dev/registry.sh update api
147- .PHONY : registry-api-local
148- registry-api-local :
149- @./dev/registry.sh update api --skip-push
150- .PHONY : registry-api-slim
151- registry-api-slim :
152- @./dev/registry.sh update api --include-slim
153- .PHONY : registry-api-slim-local
154- registry-api-slim-local :
155- @./dev/registry.sh update api --include-slim --skip-push
156- .PHONY : registry-api-local-slim
157- registry-api-local-slim :
158- @./dev/registry.sh update api --include-slim --skip-push
159-
160- .PHONY : registry-create
161- registry-create :
162- @./dev/registry.sh create
163-
164- .PHONY : registry-clean
165- registry-clean :
166- @./dev/registry.sh clean
167-
168- .PHONY : manager-local
169- manager-local :
170- @./dev/registry.sh update-manager-local
148+ images-all-aws :
149+ @./dev/registry.sh update all -p aws
150+ images-all-gcp :
151+ @./dev/registry.sh update all -p gcp
152+ images-all-local :
153+ @./dev/registry.sh update all -p local
154+ images-all-slim-aws :
155+ @./dev/registry.sh update all -p aws --include-slim
156+ images-all-slim-gcp :
157+ @./dev/registry.sh update all -p gcp --include-slim
158+ images-all-slim-local :
159+ @./dev/registry.sh update all -p local --include-slim
160+
161+ images-dev-aws :
162+ @./dev/registry.sh update dev -p aws
163+ images-dev-gcp :
164+ @./dev/registry.sh update dev -p gcp
165+ images-dev-local :
166+ @./dev/registry.sh update dev -p local
167+ images-dev-slim-aws :
168+ @./dev/registry.sh update dev -p aws --include-slim
169+ images-dev-slim-gcp :
170+ @./dev/registry.sh update dev -p gcp --include-slim
171+ images-dev-slim-local :
172+ @./dev/registry.sh update dev -p local --include-slim
173+
174+ images-api-aws :
175+ @./dev/registry.sh update api -p aws
176+ images-api-gcp :
177+ @./dev/registry.sh update api -p gcp
178+ images-api-local :
179+ @./dev/registry.sh update api -p local
180+ images-api-slim-aws :
181+ @./dev/registry.sh update api -p aws --include-slim
182+ images-api-slim-gcp :
183+ @./dev/registry.sh update api -p gcp --include-slim
184+ images-api-slim-local :
185+ @./dev/registry.sh update api -p local --include-slim
186+
187+ images-manager-local :
188+ @./dev/registry.sh update-single manager -p local
189+ images-iris-local :
190+ @./dev/registry.sh update-single python-predictor-cpu -p local
191+ images-iris-aws :
192+ @./dev/registry.sh update-single python-predictor-cpu -p aws
193+ images-iris-gcp :
194+ @./dev/registry.sh update-single python-predictor-cpu -p gcp
195+
196+ registry-create-aws :
197+ @./dev/registry.sh create -p aws
198+
199+ registry-clean-aws :
200+ @./dev/registry.sh clean -p aws
201+ registry-clean-local :
202+ @./dev/registry.sh clean -p local
171203
172204# Misc
173205
174- .PHONY : aws-clear-bucket
175- aws-clear-bucket :
176- @./dev/aws.sh clear-bucket
177-
178- .PHONY : tools
179206tools :
180207 @go get -u -v golang.org/x/lint/golint
181208 @go get -u -v github.com/VojtechVitek/rerun/cmd/rerun
182209 @python3 -m pip install black ' pydoc-markdown>=3.0.0,<4.0.0'
183210 @if [[ " $$ OSTYPE" == " darwin" * ]]; then brew install parallel; elif [[ " $$ OSTYPE" == " linux" * ]]; then sudo apt-get install -y parallel; else echo " your operating system is not supported" ; fi
184211
185- .PHONY : format
186212format :
187213 @./dev/format.sh
188214
189215# ########
190216# Tests #
191217# ########
192218
193- .PHONY : test
194219test :
195220 @./build/test.sh
196221
197- .PHONY : test-go
198222test-go :
199223 @./build/test.sh go
200224
201- .PHONY : test-python
202225test-python :
203226 @./build/test.sh python
204227
205- .PHONY : lint
206228lint :
207229 @./build/lint.sh
208230
209- .PHONY : test-examples
210- test-examples :
211- @$(MAKE ) registry-all
212- @./build/test-examples.sh
213-
214231# ##############
215232# CI Commands #
216233# ##############
217234
218- .PHONY : ci-build-images
219235ci-build-images :
220236 @./build/build-images.sh
221237
222- .PHONY : ci-push-images
223238ci-push-images :
224239 @./build/push-images.sh
225240
226- .PHONY : ci-build-cli
227241ci-build-cli :
228242 @./build/cli.sh
229243
230- .PHONY : ci-build-and-upload-cli
231244ci-build-and-upload-cli :
232245 @./build/cli.sh upload
0 commit comments