Skip to content

Commit 859557e

Browse files
authored
Merge branch 'master' into merge-container-logs-per-pod
2 parents acbc32c + ee4b3fc commit 859557e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+978
-622
lines changed

Makefile

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,41 +21,58 @@ SHELL := /bin/bash
2121
# Cortex
2222

2323
devstart:
24+
@$(MAKE) operator-stop
2425
@./dev/operator_local.sh || true
2526

2627
kubectl:
27-
@eksctl utils write-kubeconfig --name="cortex"
28-
@kubectl config set-context --current --namespace="cortex"
28+
@eksctl utils write-kubeconfig --name="cortex" >/dev/null
29+
@kubectl config set-context --current --namespace="cortex" >/dev/null
2930

3031
cortex-up:
3132
@$(MAKE) registry-all
33+
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
3234
@./cortex.sh -c=./dev/config/cortex.sh install
33-
$(MAKE) kubectl
35+
@$(MAKE) kubectl
3436

3537
cortex-up-dev:
36-
$(MAKE) cortex-up
37-
$(MAKE) operator-stop
38+
@$(MAKE) cortex-up
39+
@$(MAKE) operator-stop
3840

3941
cortex-down:
42+
@$(MAKE) manager-local
43+
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
4044
@./cortex.sh -c=./dev/config/cortex.sh uninstall
4145

46+
cortex-install:
47+
@$(MAKE) registry-all
48+
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
49+
@./cortex.sh -c=./dev/config/cortex.sh install cortex
50+
@$(MAKE) kubectl
51+
52+
cortex-uninstall:
53+
@./dev/uninstall_cortex.sh
54+
4255
cortex-info:
56+
@$(MAKE) manager-local
4357
@./cortex.sh -c=./dev/config/cortex.sh info
4458

4559
cortex-update:
4660
@$(MAKE) registry-all
61+
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
4762
@./cortex.sh -c=./dev/config/cortex.sh update
4863

4964
operator-start:
5065
@$(MAKE) registry-all
66+
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
5167
@./cortex.sh -c=./dev/config/cortex.sh update
5268

5369
operator-update:
5470
@$(MAKE) registry-all
71+
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
5572
@./cortex.sh -c=./dev/config/cortex.sh update
5673

5774
operator-stop:
58-
$(MAKE) kubectl
75+
@$(MAKE) kubectl
5976
@kubectl delete --namespace="cortex" --ignore-not-found=true deployment operator
6077

6178
# Docker images
@@ -69,6 +86,9 @@ registry-dev:
6986
registry-create:
7087
@./dev/registry.sh create
7188

89+
manager-local:
90+
@./dev/registry.sh update-manager-local
91+
7292
# Misc
7393

7494
.PHONY: cli
@@ -110,7 +130,7 @@ find-missing-version:
110130
@./build/find-missing-version.sh
111131

112132
test-examples:
113-
$(MAKE) registry-all
133+
@$(MAKE) registry-all
114134
@./build/test-examples.sh
115135

116136
###############
@@ -133,12 +153,17 @@ ci-build-images:
133153
@./build/build-image.sh images/onnx-serve-gpu onnx-serve-gpu
134154
@./build/build-image.sh images/operator operator
135155
@./build/build-image.sh images/fluentd fluentd
136-
@./build/build-image.sh images/nginx-controller nginx-controller
137-
@./build/build-image.sh images/nginx-backend nginx-backend
138156
@./build/build-image.sh images/python-packager python-packager
139157
@./build/build-image.sh images/cluster-autoscaler cluster-autoscaler
140158
@./build/build-image.sh images/nvidia nvidia
141159
@./build/build-image.sh images/metrics-server metrics-server
160+
@./build/build-image.sh images/istio-citadel istio-citadel
161+
@./build/build-image.sh images/istio-galley istio-galley
162+
@./build/build-image.sh images/istio-pilot istio-pilot
163+
@./build/build-image.sh images/istio-sidecar istio-sidecar
164+
@./build/build-image.sh images/istio-proxy istio-proxy
165+
@./build/build-image.sh images/istio-proxy-init istio-proxy-init
166+
@./build/build-image.sh images/istio-mixer istio-mixer
142167

143168
ci-push-images:
144169
@./build/push-image.sh manager
@@ -153,12 +178,17 @@ ci-push-images:
153178
@./build/push-image.sh onnx-serve-gpu
154179
@./build/push-image.sh operator
155180
@./build/push-image.sh fluentd
156-
@./build/push-image.sh nginx-controller
157-
@./build/push-image.sh nginx-backend
158181
@./build/push-image.sh python-packager
159182
@./build/push-image.sh cluster-autoscaler
160183
@./build/push-image.sh nvidia
161184
@./build/push-image.sh metrics-server
185+
@./build/push-image.sh istio-citadel
186+
@./build/push-image.sh istio-galley
187+
@./build/push-image.sh istio-pilot
188+
@./build/push-image.sh istio-sidecar
189+
@./build/push-image.sh istio-proxy
190+
@./build/push-image.sh istio-proxy-init
191+
@./build/push-image.sh istio-mixer
162192

163193

164194
ci-build-cli:

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
<br>
44

5-
**Get started:** [Install](https://docs.cortex.dev/install)[Tutorial](https://docs.cortex.dev/tutorial)<!-- CORTEX_VERSION_MINOR_STABLE e.g. https://docs.cortex.dev/v/0.2/ -->[Docs](https://docs.cortex.dev/v/0.7)<!-- CORTEX_VERSION_MINOR_STABLE -->[Examples](https://github.com/cortexlabs/cortex/tree/0.7/examples)
5+
**Get started:** [Install](https://docs.cortex.dev/install)[Tutorial](https://docs.cortex.dev/tutorial)<!-- CORTEX_VERSION_MINOR_STABLE e.g. https://docs.cortex.dev/v/0.2/ -->[Docs](https://docs.cortex.dev)<!-- CORTEX_VERSION_MINOR_STABLE -->[Examples](https://github.com/cortexlabs/cortex/tree/0.7/examples)
66

7-
**Learn more:** [Website](https://cortex.dev)[Blog](https://blog.cortex.dev)[Subscribe](https://cortexlabs.us20.list-manage.com/subscribe?u=a1987373ab814f20961fd90b4&id=ae83491e1c)[Contact](mailto:hello@cortex.dev)
7+
**Learn more:** [Website](https://cortex.dev)[Blog](https://medium.com/cortex-labs)[Subscribe](https://cortexlabs.us20.list-manage.com/subscribe?u=a1987373ab814f20961fd90b4&id=ae83491e1c)[Contact](mailto:hello@cortex.dev)
88

99
<br>
1010

11-
Cortex is a machine learning model deployment platform that runs in your AWS account. You define deployments with simple declarative configuration and Cortex deploys your models as JSON APIs. It also handles autoscaling, rolling updates, log streaming, inference on CPUs or GPUs, and more.
11+
Cortex is a machine learning deployment platform that runs in your AWS account. It takes exported models from S3 and deploys them as web APIs. It also handles autoscaling, rolling updates, log streaming, inference on CPUs or GPUs, and more.
1212

13-
Cortex is actively maintained by a venture-backed team of infrastructure engineers and [we're hiring](https://angel.co/cortex-labs-inc/jobs).
13+
Cortex is maintained by a venture-backed team of infrastructure engineers and [we're hiring](https://angel.co/cortex-labs-inc/jobs).
1414

1515
<br>
1616

@@ -40,7 +40,7 @@ def post_inference(prediction, metadata):
4040
# Python code
4141
```
4242

43-
**Deploy** to your cloud infrastructure:
43+
**Deploy** to AWS:
4444

4545
```bash
4646
$ cortex deploy
@@ -59,7 +59,7 @@ $ curl -d '{"a": 1, "b": 2, "c": 3}' https://amazonaws.com/my-api
5959
6060
<br>
6161
62-
## Spinning up a Cortex cluster on your AWS account
62+
## Hosting Cortex on AWS
6363
6464
```bash
6565
# Download the install script

cli/cmd/get.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,8 @@ func describeAPI(name string, resourcesRes *schema.GetResourcesResponse, flagVer
489489

490490
apiEndpoint := urls.Join(resourcesRes.APIsBaseURL, anyAPIStatus.Path)
491491

492-
out := "\nURL: " + apiEndpoint + "\n"
493-
out += fmt.Sprintf("cURL: curl -k -X POST -H \"Content-Type: application/json\" %s -d @samples.json\n", apiEndpoint)
492+
out := "\nURL: " + apiEndpoint + "\n"
493+
out += fmt.Sprintf("cURL: curl -k -X POST -H \"Content-Type: application/json\" %s -d @samples.json\n", apiEndpoint)
494494
out += "\n"
495495
out += fmt.Sprintf("Status: %s\n", groupStatus.Message())
496496
out += fmt.Sprintf("Available replicas: %s\n", s.Int32(groupStatus.Available()))

cli/cmd/predict.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,25 @@ var predictCmd = &cobra.Command{
7070
}
7171

7272
apiGroupStatus := resourcesRes.APIGroupStatuses[apiName]
73+
74+
// Check for prefix match
7375
if apiGroupStatus == nil {
74-
errors.Exit(ErrorAPINotFound(apiName))
76+
var matchedName string
77+
for name := range resourcesRes.APIGroupStatuses {
78+
if strings.HasPrefix(name, apiName) {
79+
if matchedName != "" {
80+
errors.Exit(ErrorAPINotFound(apiName)) // duplicates
81+
}
82+
matchedName = name
83+
}
84+
}
85+
if matchedName == "" {
86+
errors.Exit(ErrorAPINotFound(apiName))
87+
}
88+
apiName = matchedName
89+
apiGroupStatus = resourcesRes.APIGroupStatuses[apiName]
7590
}
91+
7692
if apiGroupStatus.ActiveStatus == nil {
7793
errors.Exit(ErrorAPINotReady(apiName, apiGroupStatus.Message()))
7894
}

cortex.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ export CORTEX_NAMESPACE="${CORTEX_NAMESPACE:-cortex}"
118118

119119
export CORTEX_IMAGE_MANAGER="${CORTEX_IMAGE_MANAGER:-cortexlabs/manager:$CORTEX_VERSION_STABLE}"
120120
export CORTEX_IMAGE_FLUENTD="${CORTEX_IMAGE_FLUENTD:-cortexlabs/fluentd:$CORTEX_VERSION_STABLE}"
121-
export CORTEX_IMAGE_NGINX_BACKEND="${CORTEX_IMAGE_NGINX_BACKEND:-cortexlabs/nginx-backend:$CORTEX_VERSION_STABLE}"
122-
export CORTEX_IMAGE_NGINX_CONTROLLER="${CORTEX_IMAGE_NGINX_CONTROLLER:-cortexlabs/nginx-controller:$CORTEX_VERSION_STABLE}"
123121
export CORTEX_IMAGE_OPERATOR="${CORTEX_IMAGE_OPERATOR:-cortexlabs/operator:$CORTEX_VERSION_STABLE}"
124122
export CORTEX_IMAGE_SPARK="${CORTEX_IMAGE_SPARK:-cortexlabs/spark:$CORTEX_VERSION_STABLE}"
125123
export CORTEX_IMAGE_SPARK_OPERATOR="${CORTEX_IMAGE_SPARK_OPERATOR:-cortexlabs/spark-operator:$CORTEX_VERSION_STABLE}"
@@ -134,6 +132,13 @@ export CORTEX_IMAGE_ONNX_SERVE_GPU="${CORTEX_IMAGE_ONNX_SERVE_GPU:-cortexlabs/on
134132
export CORTEX_IMAGE_CLUSTER_AUTOSCALER="${CORTEX_IMAGE_CLUSTER_AUTOSCALER:-cortexlabs/cluster-autoscaler:$CORTEX_VERSION_STABLE}"
135133
export CORTEX_IMAGE_NVIDIA="${CORTEX_IMAGE_NVIDIA:-cortexlabs/nvidia:$CORTEX_VERSION_STABLE}"
136134
export CORTEX_IMAGE_METRICS_SERVER="${CORTEX_IMAGE_METRICS_SERVER:-cortexlabs/metrics-server:$CORTEX_VERSION_STABLE}"
135+
export CORTEX_IMAGE_ISTIO_CITADEL="${CORTEX_IMAGE_ISTIO_CITADEL:-cortexlabs/istio-citadel:$CORTEX_VERSION_STABLE}"
136+
export CORTEX_IMAGE_ISTIO_GALLEY="${CORTEX_IMAGE_ISTIO_GALLEY:-cortexlabs/istio-galley:$CORTEX_VERSION_STABLE}"
137+
export CORTEX_IMAGE_ISTIO_PILOT="${CORTEX_IMAGE_ISTIO_PILOT:-cortexlabs/istio-pilot:$CORTEX_VERSION_STABLE}"
138+
export CORTEX_IMAGE_ISTIO_SIDECAR="${CORTEX_IMAGE_ISTIO_SIDECAR:-cortexlabs/istio-sidecar:$CORTEX_VERSION_STABLE}"
139+
export CORTEX_IMAGE_ISTIO_PROXY="${CORTEX_IMAGE_ISTIO_PROXY:-cortexlabs/istio-proxy:$CORTEX_VERSION_STABLE}"
140+
export CORTEX_IMAGE_ISTIO_PROXY_INIT="${CORTEX_IMAGE_ISTIO_PROXY_INIT:-cortexlabs/istio-proxy-init:$CORTEX_VERSION_STABLE}"
141+
export CORTEX_IMAGE_ISTIO_MIXER="${CORTEX_IMAGE_ISTIO_MIXER:-cortexlabs/istio-mixer:$CORTEX_VERSION_STABLE}"
137142

138143
export CORTEX_ENABLE_TELEMETRY="${CORTEX_ENABLE_TELEMETRY:-""}"
139144

@@ -176,8 +181,6 @@ function install_cortex() {
176181
-e CORTEX_LOG_GROUP=$CORTEX_LOG_GROUP \
177182
-e CORTEX_BUCKET=$CORTEX_BUCKET \
178183
-e CORTEX_IMAGE_FLUENTD=$CORTEX_IMAGE_FLUENTD \
179-
-e CORTEX_IMAGE_NGINX_BACKEND=$CORTEX_IMAGE_NGINX_BACKEND \
180-
-e CORTEX_IMAGE_NGINX_CONTROLLER=$CORTEX_IMAGE_NGINX_CONTROLLER \
181184
-e CORTEX_IMAGE_OPERATOR=$CORTEX_IMAGE_OPERATOR \
182185
-e CORTEX_IMAGE_SPARK=$CORTEX_IMAGE_SPARK \
183186
-e CORTEX_IMAGE_SPARK_OPERATOR=$CORTEX_IMAGE_SPARK_OPERATOR \
@@ -192,6 +195,13 @@ function install_cortex() {
192195
-e CORTEX_IMAGE_CLUSTER_AUTOSCALER=$CORTEX_IMAGE_CLUSTER_AUTOSCALER \
193196
-e CORTEX_IMAGE_NVIDIA=$CORTEX_IMAGE_NVIDIA \
194197
-e CORTEX_IMAGE_METRICS_SERVER=$CORTEX_IMAGE_METRICS_SERVER \
198+
-e CORTEX_IMAGE_ISTIO_CITADEL=$CORTEX_IMAGE_ISTIO_CITADEL \
199+
-e CORTEX_IMAGE_ISTIO_GALLEY=$CORTEX_IMAGE_ISTIO_GALLEY \
200+
-e CORTEX_IMAGE_ISTIO_SIDECAR=$CORTEX_IMAGE_ISTIO_SIDECAR \
201+
-e CORTEX_IMAGE_ISTIO_PILOT=$CORTEX_IMAGE_ISTIO_PILOT \
202+
-e CORTEX_IMAGE_ISTIO_PROXY=$CORTEX_IMAGE_ISTIO_PROXY \
203+
-e CORTEX_IMAGE_ISTIO_PROXY_INIT=$CORTEX_IMAGE_ISTIO_PROXY_INIT \
204+
-e CORTEX_IMAGE_ISTIO_MIXER=$CORTEX_IMAGE_ISTIO_MIXER \
195205
-e CORTEX_ENABLE_TELEMETRY=$CORTEX_ENABLE_TELEMETRY \
196206
$CORTEX_IMAGE_MANAGER
197207
}
@@ -423,6 +433,8 @@ if [ "$arg1" = "install" ]; then
423433
prompt_for_telemetry && install_eks && install_cortex && info
424434
elif [ "$arg2" = "cli" ]; then
425435
install_cli
436+
elif [ "$arg2" = "cortex" ]; then # Undocumented (just for dev)
437+
install_cortex && info
426438
elif [ "$arg2" = "" ]; then
427439
echo -e "\nerror: missing subcommand for install"
428440
show_help

dev/registry.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@ function ecr_login() {
3737
function create_registry() {
3838
aws ecr create-repository --repository-name=cortexlabs/manager --region=$REGISTRY_REGION || true
3939
aws ecr create-repository --repository-name=cortexlabs/fluentd --region=$REGISTRY_REGION || true
40-
aws ecr create-repository --repository-name=cortexlabs/nginx-backend --region=$REGISTRY_REGION || true
41-
aws ecr create-repository --repository-name=cortexlabs/nginx-controller --region=$REGISTRY_REGION || true
40+
aws ecr create-repository --repository-name=cortexlabs/istio-citadel --region=$REGISTRY_REGION || true
41+
aws ecr create-repository --repository-name=cortexlabs/istio-pilot --region=$REGISTRY_REGION || true
42+
aws ecr create-repository --repository-name=cortexlabs/istio-galley --region=$REGISTRY_REGION || true
43+
aws ecr create-repository --repository-name=cortexlabs/istio-sidecar --region=$REGISTRY_REGION || true
44+
aws ecr create-repository --repository-name=cortexlabs/istio-proxy --region=$REGISTRY_REGION || true
45+
aws ecr create-repository --repository-name=cortexlabs/istio-proxy-init --region=$REGISTRY_REGION || true
46+
aws ecr create-repository --repository-name=cortexlabs/istio-mixer --region=$REGISTRY_REGION || true
4247
aws ecr create-repository --repository-name=cortexlabs/operator --region=$REGISTRY_REGION || true
4348
aws ecr create-repository --repository-name=cortexlabs/spark --region=$REGISTRY_REGION || true
4449
aws ecr create-repository --repository-name=cortexlabs/spark-operator --region=$REGISTRY_REGION || true
@@ -116,6 +121,9 @@ env=${2:-""}
116121
if [ "$cmd" = "create" ]; then
117122
create_registry
118123

124+
elif [ "$cmd" = "update-manager-local" ]; then
125+
build $ROOT/images/manager manager latest
126+
119127
elif [ "$cmd" = "update" ]; then
120128
if [ "$env" != "dev" ]; then
121129
build_and_push $ROOT/images/manager manager latest
@@ -133,8 +141,6 @@ elif [ "$cmd" = "update" ]; then
133141
build_and_push $ROOT/images/spark spark latest
134142
build_and_push $ROOT/images/tf-train tf-train latest
135143
build_and_push $ROOT/images/tf-train-gpu tf-train-gpu latest
136-
build_and_push $ROOT/images/nginx-controller nginx-controller latest
137-
build_and_push $ROOT/images/nginx-backend nginx-backend latest
138144
build_and_push $ROOT/images/fluentd fluentd latest
139145
build_and_push $ROOT/images/tf-serve tf-serve latest
140146
build_and_push $ROOT/images/tf-serve-gpu tf-serve-gpu latest
@@ -143,6 +149,13 @@ elif [ "$cmd" = "update" ]; then
143149
build_and_push $ROOT/images/cluster-autoscaler cluster-autoscaler latest
144150
build_and_push $ROOT/images/nvidia nvidia latest
145151
build_and_push $ROOT/images/metrics-server metrics-server latest
152+
build_and_push $ROOT/images/istio-citadel istio-citadel latest
153+
build_and_push $ROOT/images/istio-pilot istio-pilot latest
154+
build_and_push $ROOT/images/istio-galley istio-galley latest
155+
build_and_push $ROOT/images/istio-sidecar istio-sidecar latest
156+
build_and_push $ROOT/images/istio-proxy istio-proxy latest
157+
build_and_push $ROOT/images/istio-proxy-init istio-proxy-init latest
158+
build_and_push $ROOT/images/istio-mixer istio-mixer latest
146159
fi
147160

148161
build_and_push $ROOT/images/tf-api tf-api latest

dev/uninstall_cortex.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
# Copyright 2019 Cortex Labs, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. >/dev/null && pwd)"
19+
20+
source $ROOT/dev/config/cortex.sh
21+
22+
eksctl utils write-kubeconfig --name=$CORTEX_CLUSTER --region=$CORTEX_REGION
23+
24+
echo "Uninstalling Cortex ..."
25+
26+
# Remove finalizers on sparkapplications (they sometimes create deadlocks)
27+
if kubectl get namespace $CORTEX_NAMESPACE >/dev/null 2>&1 && kubectl get customresourcedefinition sparkapplications.sparkoperator.k8s.io >/dev/null 2>&1; then
28+
kubectl -n=$CORTEX_NAMESPACE get sparkapplications.sparkoperator.k8s.io -o name | xargs -L1 \
29+
kubectl -n=$CORTEX_NAMESPACE patch -p '{"metadata":{"finalizers": []}}' --type=merge >/dev/null 2>&1
30+
fi
31+
32+
kubectl delete --ignore-not-found=true customresourcedefinition scheduledsparkapplications.sparkoperator.k8s.io
33+
kubectl delete --ignore-not-found=true customresourcedefinition sparkapplications.sparkoperator.k8s.io
34+
kubectl delete --ignore-not-found=true namespace istio-system
35+
kubectl delete --ignore-not-found=true namespace $CORTEX_NAMESPACE
36+
37+
echo "✓ Uninstalled Cortex"

0 commit comments

Comments
 (0)