Skip to content

Commit 17581ad

Browse files
authored
Update Cortex to be installable on any k8s clusters on AWS and GCP (#1837)
1 parent 4e9ce4b commit 17581ad

File tree

128 files changed

+38286
-1570
lines changed

Some content is hidden

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

128 files changed

+38286
-1570
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,5 @@ $ curl http://example.com/text-generator -X POST -H "Content-Type: application/j
8282

8383
## Get started
8484

85-
* [Read the docs](https://docs.cortex.dev)
86-
* [Report an issue](https://github.com/cortexlabs/cortex/issues)
87-
* [Join our community](https://gitter.im/cortexlabs/cortex)
85+
* [Install Cortex](https://docs.cortex.dev)
86+
* [Join our community](https://join.slack.com/t/cortex-dot-dev/shared_invite/zt-lf58axgy-0QkLZzFSSku5_Jybd9yiZQ)

build/cli.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,22 @@ function build_python {
6161
popd
6262
}
6363

64+
function upload_charts {
65+
set -euo pipefail
66+
67+
echo -e "\nCompressing charts"
68+
tar -czf charts.tar.gz charts/
69+
70+
echo "Uploading compressed charts to s3://$CLI_BUCKET_NAME/$CORTEX_VERSION/charts/cortex-$CORTEX_VERSION.tar.gz"
71+
aws s3 cp charts.tar.gz s3://$CLI_BUCKET_NAME/$CORTEX_VERSION/charts/cortex-$CORTEX_VERSION.tar.gz --only-show-errors
72+
73+
rm -rf charts.tar.gz
74+
}
75+
6476
build_and_upload darwin
6577

6678
build_and_upload linux
6779

6880
build_python
81+
82+
upload_charts

build/lint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ output=$(cd "$ROOT" && find . -type f \
7575
! -path "**/.history/*" \
7676
! -path "**/__pycache__/*" \
7777
! -path "./test/*" \
78+
! -path "./charts/*" \
7879
! -path "./dev/config/*" \
7980
! -path "./bin/*" \
8081
! -path "./.circleci/*" \
@@ -146,6 +147,7 @@ output=$(cd "$ROOT" && find . -type f \
146147
! -path "./dev/config/*" \
147148
! -path "./bin/*" \
148149
! -path "./.git/*" \
150+
! -path "./charts/charts/networking/charts/*" \
149151
! -name ".*" \
150152
! -name "*.bin" \
151153
! -name "*.wav" \
@@ -166,6 +168,7 @@ output=$(cd "$ROOT" && find . -type f \
166168
! -path "./dev/config/*" \
167169
! -path "./bin/*" \
168170
! -path "./.git/*" \
171+
! -path "./charts/charts/networking/charts/*" \
169172
! -name ".*" \
170173
! -name "*.bin" \
171174
! -name "*.wav" \
@@ -186,6 +189,7 @@ output=$(cd "$ROOT" && find . -type f \
186189
! -path "./dev/config/*" \
187190
! -path "./bin/*" \
188191
! -path "./.git/*" \
192+
! -path "./charts/charts/networking/charts/*" \
189193
! -name ".*" \
190194
! -name "*.bin" \
191195
! -name "*.wav" \

charts/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: cortex
3+
description: A Helm chart for installing Cortex
4+
type: application
5+
version: 0.1.0 # CORTEX_VERSION
6+
appVersion: "master" # CORTEX_VERSION
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: networking
3+
description: A Helm chart for setting up Cortex's networking dependencies
4+
type: application
5+
version: 0.1.0 # CORTEX_VERSION
6+
appVersion: "master" # CORTEX_VERSION
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
name: api-ingress
3+
version: 1.1.0
4+
tillerVersion: ">=2.7.2"
5+
description: Helm chart for deploying Istio gateways
6+
keywords:
7+
- istio
8+
- ingressgateway
9+
- gateways
10+
sources:
11+
- http://github.com/istio/istio
12+
engine: gotpl
13+
icon: https://istio.io/latest/favicons/android-192x192.png
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
Changes:
3+
- separate namespace allows:
4+
-- easier reconfig of just the gateway
5+
-- TLS secrets and domain name management is isolated, for better security
6+
-- simplified configuration
7+
-- multiple versions of the ingress can be used, to minimize upgrade risks
8+
9+
- the new chart uses the default namespace service account, and doesn't require
10+
additional RBAC permissions.
11+
12+
- simplified label and chart structure.
13+
- ability to run a pilot dedicated for the gateway, isolated from the main pilot. This is more robust, safer on upgrades
14+
and allows a bit more flexibility.
15+
- the dedicated pilot-per-ingress is required if the gateway needs to support k8s-style ingress.
16+
17+
# Port and basic host configuration
18+
19+
In order to configure the Service object, the install/upgrade needs to provide a list of all ports.
20+
In the past, this was done when installing/upgrading full istio, and involved some duplication - ports configured
21+
both in upgrade, Gateway and VirtualService.
22+
23+
The new Ingress chart uses a 'values.yaml' (see user-example-ingress), which auto-generates Service ports,
24+
Gateways and basic VirtualService. It is still possible to only configure the ports in Service, and do manual
25+
config for the rest.
26+
27+
All internal services ( telemetry, pilot debug ports, mesh expansion ) can now be configured via the new mechanism.
28+
29+
# Migration from istio-system
30+
31+
Istio 1.0 includes the gateways in istio-system. Since the external IP is associated
32+
with the Service and bound to the namespace, it is recommended to:
33+
34+
1. Install the new gateway in a new namespace.
35+
2. Copy any TLS certificate to the new namespace, and configure the domains.
36+
3. Checking the new gateway work - for example by overriding the IP in /etc/hosts
37+
4. Modify the DNS server to add the A record of the new namespace
38+
5. Check traffic
39+
6. Delete the A record corresponding to the gateway in istio-system
40+
7. Upgrade istio-system, disabling the ingressgateway
41+
8. Delete the domain TLS certs from istio-system.
42+
43+
If using certmanager, all Certificate and associated configs must be moved as well.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{{/* affinity - https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ */}}
2+
3+
{{- define "nodeaffinity" }}
4+
nodeAffinity:
5+
requiredDuringSchedulingIgnoredDuringExecution:
6+
{{- include "nodeAffinityRequiredDuringScheduling" . }}
7+
preferredDuringSchedulingIgnoredDuringExecution:
8+
{{- include "nodeAffinityPreferredDuringScheduling" . }}
9+
{{- end }}
10+
11+
{{- define "nodeAffinityRequiredDuringScheduling" }}
12+
nodeSelectorTerms:
13+
- matchExpressions:
14+
- key: kubernetes.io/arch
15+
operator: In
16+
values:
17+
{{- range $key, $val := .global.arch }}
18+
{{- if gt ($val | int) 0 }}
19+
- {{ $key | quote }}
20+
{{- end }}
21+
{{- end }}
22+
{{- $nodeSelector := default .global.defaultNodeSelector .nodeSelector -}}
23+
{{- range $key, $val := $nodeSelector }}
24+
- key: {{ $key }}
25+
operator: In
26+
values:
27+
- {{ $val | quote }}
28+
{{- end }}
29+
{{- end }}
30+
31+
{{- define "nodeAffinityPreferredDuringScheduling" }}
32+
{{- range $key, $val := .global.arch }}
33+
{{- if gt ($val | int) 0 }}
34+
- weight: {{ $val | int }}
35+
preference:
36+
matchExpressions:
37+
- key: kubernetes.io/arch
38+
operator: In
39+
values:
40+
- {{ $key | quote }}
41+
{{- end }}
42+
{{- end }}
43+
{{- end }}
44+
45+
{{- define "podAntiAffinity" }}
46+
{{- if or .podAntiAffinityLabelSelector .podAntiAffinityTermLabelSelector}}
47+
podAntiAffinity:
48+
{{- if .podAntiAffinityLabelSelector }}
49+
requiredDuringSchedulingIgnoredDuringExecution:
50+
{{- include "podAntiAffinityRequiredDuringScheduling" . }}
51+
{{- end }}
52+
{{- if .podAntiAffinityTermLabelSelector }}
53+
preferredDuringSchedulingIgnoredDuringExecution:
54+
{{- include "podAntiAffinityPreferredDuringScheduling" . }}
55+
{{- end }}
56+
{{- end }}
57+
{{- end }}
58+
59+
{{- define "podAntiAffinityRequiredDuringScheduling" }}
60+
{{- range $index, $item := .podAntiAffinityLabelSelector }}
61+
- labelSelector:
62+
matchExpressions:
63+
- key: {{ $item.key }}
64+
operator: {{ $item.operator }}
65+
{{- if $item.values }}
66+
values:
67+
{{- $vals := split "," $item.values }}
68+
{{- range $i, $v := $vals }}
69+
- {{ $v | quote }}
70+
{{- end }}
71+
{{- end }}
72+
topologyKey: {{ $item.topologyKey }}
73+
{{- end }}
74+
{{- end }}
75+
76+
{{- define "podAntiAffinityPreferredDuringScheduling" }}
77+
{{- range $index, $item := .podAntiAffinityTermLabelSelector }}
78+
- podAffinityTerm:
79+
labelSelector:
80+
matchExpressions:
81+
- key: {{ $item.key }}
82+
operator: {{ $item.operator }}
83+
{{- if $item.values }}
84+
values:
85+
{{- $vals := split "," $item.values }}
86+
{{- range $i, $v := $vals }}
87+
- {{ $v | quote }}
88+
{{- end }}
89+
{{- end }}
90+
topologyKey: {{ $item.topologyKey }}
91+
weight: 100
92+
{{- end }}
93+
{{- end }}

0 commit comments

Comments
 (0)