Skip to content

Update Cortex to be installable on any k8s cluster on AWS and GCP #1837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2e35984
hack operator to work on any cluster
vishalbollu Jan 22, 2021
c99ee52
Add helm charts and update operator to run on non cortex managed clus…
vishalbollu Jan 29, 2021
f784a5f
High level self review
vishalbollu Jan 29, 2021
064750a
Rename helm folder to manifests, set required values and fix bugs in …
vishalbollu Jan 31, 2021
4428043
Remove auth requiring credentials and provider prompt in cx configre
vishalbollu Jan 31, 2021
1ebcf93
Clean up PR and remove debug statements
vishalbollu Jan 31, 2021
43194f0
Fix linting
vishalbollu Jan 31, 2021
e48a915
Self review nits
vishalbollu Feb 1, 2021
ecd5d0d
Respond to PR comments
vishalbollu Feb 1, 2021
dda4a28
Merge branch 'master' into byocluster
vishalbollu Feb 2, 2021
e970119
Update docs
ospillinger Feb 2, 2021
7e7faf8
Updated helm charts to install prometheus and rename variables
vishalbollu Feb 2, 2021
02a992e
Merge branch 'byocluster' of github.com:cortexlabs/cortex into byoclu…
vishalbollu Feb 2, 2021
3ac09e1
Update RBAC api version on fluentbit.yaml
Feb 2, 2021
dc07a46
Add namespace explicitly in prometheus-monitoring.yaml
Feb 2, 2021
0b6d3e0
Clean-up values.yaml
Feb 2, 2021
bd0644c
Rename helm charts folder from manifests to charts
vishalbollu Feb 2, 2021
f265c02
Rename manifests to charts
vishalbollu Feb 2, 2021
c66b9a5
Consolidate kubernetes documentation
vishalbollu Feb 2, 2021
8130353
Propagate cortex namespace to prometheus url
vishalbollu Feb 2, 2021
9c546d9
Merge branch 'master' into byocluster
vishalbollu Feb 2, 2021
42409d2
Update cluster_config_aws.go
vishalbollu Feb 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,5 @@ $ curl http://example.com/text-generator -X POST -H "Content-Type: application/j

## Get started

* [Read the docs](https://docs.cortex.dev)
* [Report an issue](https://github.com/cortexlabs/cortex/issues)
* [Join our community](https://gitter.im/cortexlabs/cortex)
* [Install Cortex](https://docs.cortex.dev)
* [Join our community](https://join.slack.com/t/cortex-dot-dev/shared_invite/zt-lf58axgy-0QkLZzFSSku5_Jybd9yiZQ)
14 changes: 14 additions & 0 deletions build/cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,22 @@ function build_python {
popd
}

function upload_charts {
set -euo pipefail

echo -e "\nCompressing charts"
tar -czf charts.tar.gz charts/

echo "Uploading compressed charts to s3://$CLI_BUCKET_NAME/$CORTEX_VERSION/charts/cortex-$CORTEX_VERSION.tar.gz"
aws s3 cp charts.tar.gz s3://$CLI_BUCKET_NAME/$CORTEX_VERSION/charts/cortex-$CORTEX_VERSION.tar.gz --only-show-errors

rm -rf charts.tar.gz
}

build_and_upload darwin

build_and_upload linux

build_python

upload_charts
4 changes: 4 additions & 0 deletions build/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ output=$(cd "$ROOT" && find . -type f \
! -path "**/.history/*" \
! -path "**/__pycache__/*" \
! -path "./test/*" \
! -path "./charts/*" \
! -path "./dev/config/*" \
! -path "./bin/*" \
! -path "./.circleci/*" \
Expand Down Expand Up @@ -146,6 +147,7 @@ output=$(cd "$ROOT" && find . -type f \
! -path "./dev/config/*" \
! -path "./bin/*" \
! -path "./.git/*" \
! -path "./charts/charts/networking/charts/*" \
! -name ".*" \
! -name "*.bin" \
! -name "*.wav" \
Expand All @@ -166,6 +168,7 @@ output=$(cd "$ROOT" && find . -type f \
! -path "./dev/config/*" \
! -path "./bin/*" \
! -path "./.git/*" \
! -path "./charts/charts/networking/charts/*" \
! -name ".*" \
! -name "*.bin" \
! -name "*.wav" \
Expand All @@ -186,6 +189,7 @@ output=$(cd "$ROOT" && find . -type f \
! -path "./dev/config/*" \
! -path "./bin/*" \
! -path "./.git/*" \
! -path "./charts/charts/networking/charts/*" \
! -name ".*" \
! -name "*.bin" \
! -name "*.wav" \
Expand Down
23 changes: 23 additions & 0 deletions charts/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: cortex
description: A Helm chart for installing Cortex
type: application
version: 0.1.0 # CORTEX_VERSION
appVersion: "master" # CORTEX_VERSION
23 changes: 23 additions & 0 deletions charts/charts/networking/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions charts/charts/networking/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: networking
description: A Helm chart for setting up Cortex's networking dependencies
type: application
version: 0.1.0 # CORTEX_VERSION
appVersion: "master" # CORTEX_VERSION
13 changes: 13 additions & 0 deletions charts/charts/networking/charts/api-ingress/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
name: api-ingress
version: 1.1.0
tillerVersion: ">=2.7.2"
description: Helm chart for deploying Istio gateways
keywords:
- istio
- ingressgateway
- gateways
sources:
- http://github.com/istio/istio
engine: gotpl
icon: https://istio.io/latest/favicons/android-192x192.png
43 changes: 43 additions & 0 deletions charts/charts/networking/charts/api-ingress/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Changes:
- separate namespace allows:
-- easier reconfig of just the gateway
-- TLS secrets and domain name management is isolated, for better security
-- simplified configuration
-- multiple versions of the ingress can be used, to minimize upgrade risks

- the new chart uses the default namespace service account, and doesn't require
additional RBAC permissions.

- simplified label and chart structure.
- ability to run a pilot dedicated for the gateway, isolated from the main pilot. This is more robust, safer on upgrades
and allows a bit more flexibility.
- the dedicated pilot-per-ingress is required if the gateway needs to support k8s-style ingress.

# Port and basic host configuration

In order to configure the Service object, the install/upgrade needs to provide a list of all ports.
In the past, this was done when installing/upgrading full istio, and involved some duplication - ports configured
both in upgrade, Gateway and VirtualService.

The new Ingress chart uses a 'values.yaml' (see user-example-ingress), which auto-generates Service ports,
Gateways and basic VirtualService. It is still possible to only configure the ports in Service, and do manual
config for the rest.

All internal services ( telemetry, pilot debug ports, mesh expansion ) can now be configured via the new mechanism.

# Migration from istio-system

Istio 1.0 includes the gateways in istio-system. Since the external IP is associated
with the Service and bound to the namespace, it is recommended to:

1. Install the new gateway in a new namespace.
2. Copy any TLS certificate to the new namespace, and configure the domains.
3. Checking the new gateway work - for example by overriding the IP in /etc/hosts
4. Modify the DNS server to add the A record of the new namespace
5. Check traffic
6. Delete the A record corresponding to the gateway in istio-system
7. Upgrade istio-system, disabling the ingressgateway
8. Delete the domain TLS certs from istio-system.

If using certmanager, all Certificate and associated configs must be moved as well.
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{{/* affinity - https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ */}}

{{- define "nodeaffinity" }}
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
{{- include "nodeAffinityRequiredDuringScheduling" . }}
preferredDuringSchedulingIgnoredDuringExecution:
{{- include "nodeAffinityPreferredDuringScheduling" . }}
{{- end }}

{{- define "nodeAffinityRequiredDuringScheduling" }}
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/arch
operator: In
values:
{{- range $key, $val := .global.arch }}
{{- if gt ($val | int) 0 }}
- {{ $key | quote }}
{{- end }}
{{- end }}
{{- $nodeSelector := default .global.defaultNodeSelector .nodeSelector -}}
{{- range $key, $val := $nodeSelector }}
- key: {{ $key }}
operator: In
values:
- {{ $val | quote }}
{{- end }}
{{- end }}

{{- define "nodeAffinityPreferredDuringScheduling" }}
{{- range $key, $val := .global.arch }}
{{- if gt ($val | int) 0 }}
- weight: {{ $val | int }}
preference:
matchExpressions:
- key: kubernetes.io/arch
operator: In
values:
- {{ $key | quote }}
{{- end }}
{{- end }}
{{- end }}

{{- define "podAntiAffinity" }}
{{- if or .podAntiAffinityLabelSelector .podAntiAffinityTermLabelSelector}}
podAntiAffinity:
{{- if .podAntiAffinityLabelSelector }}
requiredDuringSchedulingIgnoredDuringExecution:
{{- include "podAntiAffinityRequiredDuringScheduling" . }}
{{- end }}
{{- if .podAntiAffinityTermLabelSelector }}
preferredDuringSchedulingIgnoredDuringExecution:
{{- include "podAntiAffinityPreferredDuringScheduling" . }}
{{- end }}
{{- end }}
{{- end }}

{{- define "podAntiAffinityRequiredDuringScheduling" }}
{{- range $index, $item := .podAntiAffinityLabelSelector }}
- labelSelector:
matchExpressions:
- key: {{ $item.key }}
operator: {{ $item.operator }}
{{- if $item.values }}
values:
{{- $vals := split "," $item.values }}
{{- range $i, $v := $vals }}
- {{ $v | quote }}
{{- end }}
{{- end }}
topologyKey: {{ $item.topologyKey }}
{{- end }}
{{- end }}

{{- define "podAntiAffinityPreferredDuringScheduling" }}
{{- range $index, $item := .podAntiAffinityTermLabelSelector }}
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: {{ $item.key }}
operator: {{ $item.operator }}
{{- if $item.values }}
values:
{{- $vals := split "," $item.values }}
{{- range $i, $v := $vals }}
- {{ $v | quote }}
{{- end }}
{{- end }}
topologyKey: {{ $item.topologyKey }}
weight: 100
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{ $gateway := index .Values "gateways" "istio-ingressgateway" }}
{{- if and $gateway.autoscaleEnabled $gateway.autoscaleMin $gateway.autoscaleMax }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ $gateway.name | default "istio-ingressgateway" }}
namespace: {{ .Release.Namespace }}
labels:
{{ $gateway.labels | toYaml | indent 4 }}
release: {{ .Release.Name }}
spec:
maxReplicas: {{ $gateway.autoscaleMax }}
minReplicas: {{ $gateway.autoscaleMin }}
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ $gateway.name | default "istio-ingressgateway" }}
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ $gateway.cpu.targetAverageUtilization }}
---
{{- end }}
Loading