Skip to content

Commit

Permalink
Merge pull request #42 from mage-ai/dy--fix_ingress_getting_overwritten
Browse files Browse the repository at this point in the history
[dy] Add ingress chart
  • Loading branch information
dy46 authored Jan 31, 2024
2 parents d98e0dd + c487c2a commit 50a9572
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/ingress/.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/
55 changes: 55 additions & 0 deletions charts/ingress/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
annotations:
artifacthub.io/alternativeName: Mage-Ingress
artifacthub.io/category: networking
artifacthub.io/license: Apache-2.0
artifacthub.io/links: |
- name: Homepage
url: https://www.mage.ai/
- name: Source
url: https://github.com/mage-ai/helm-charts
- name: Documentation
url: https://mage-ai.github.io/helm-charts/
artifacthub.io/maintainers: |
- name: Mage
email: [email protected]
artifacthub.io/screenshots: |
- title: Build Pipeline
url: https://www.mage.ai/images/pages/home/screenshots/v5/[email protected]
- title: Preview Pipeline
url: https://www.mage.ai/images/pages/home/screenshots/v5/[email protected]
- title: Launch Pipeline
url: https://www.mage.ai/images/pages/home/screenshots/v5/[email protected]
apiVersion: v2

description: A Helm chart for deploying ingress for Mage AI

home: https://www.mage.ai

icon: https://avatars.githubusercontent.com/u/69371472

maintainers:
- name: mage-ai
url: https://www.mage.ai
email: [email protected]

name: mageai-ingress


sources:
- https://github.com/mage-ai/helm-charts/tree/master/charts/ingress

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.1
8 changes: 8 additions & 0 deletions charts/ingress/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- if .Values.ingress.enabled }}
The following hosts were added to the ingress:
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- end }}
33 changes: 33 additions & 0 deletions charts/ingress/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "mageai.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "mageai.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "mageai.labels" -}}
helm.sh/chart: {{ include "mageai.chart" . }}
{{ include "mageai.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "mageai.selectorLabels" -}}
app.kubernetes.io/name: {{ include "mageai.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
59 changes: 59 additions & 0 deletions charts/ingress/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{{- if .Values.ingress.enabled -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ .Values.ingress.name }}
labels:
{{- include "mageai.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ .backend.service.name }}
port:
number: {{ .backend.service.port }}
{{- else }}
serviceName: {{ .backend.service.name }}
servicePort: {{ .backend.service.port }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
20 changes: 20 additions & 0 deletions charts/ingress/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ingress:
name: mageai
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: mageai
port: 6789
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
3 changes: 3 additions & 0 deletions charts/mageai/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ customLivenessProbe: {}
# Custom readiness probe
customReadinessProbe: {}

# We recommend creating the ingress separately instead of creating it using this chart.
# There is a corresponding Mage-Ingress chart to create an ingress for Mage if needed.
# This section is kept here for backwards compatibility.
ingress:
enabled: false
className: ""
Expand Down

0 comments on commit 50a9572

Please sign in to comment.