Skip to content

Commit

Permalink
Updated Ingress chart template (#230)
Browse files Browse the repository at this point in the history
* feat: enhanced Ingress template K8s compatibility

* feat: bumped chart version 0.2.1->0.3.0
  • Loading branch information
akijakya committed Jan 23, 2023
1 parent 05376ac commit 7d662fc
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 38 deletions.
4 changes: 2 additions & 2 deletions charts/telescopes/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: telescopes
home: https://banzaicloud.com
sources:
- https://github.com/banzaicloud/banzai-charts
version: 0.2.1
version: 0.3.0
appVersion: 0.5.3
description: A Telescopes Helm chart for Kubernetes
keywords:
Expand All @@ -25,4 +25,4 @@ icon: https://banzaicloud.com/img/banzai-cloud-logo.svg
# 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
# type: application
10 changes: 7 additions & 3 deletions charts/telescopes/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{{- $url := splitList "/" (index .Values.ingress.hosts 0) }}
{{- $basePath := (rest $url | join "/") }}
{{- $basePath := "" -}}
{{- with (first .Values.ingress.hosts )}}
{{- with (first .paths) }}
{{- $basePath = .path }}
{{- end }}
{{- end }}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -39,7 +43,7 @@ spec:
env:
{{- if .Values.ingress.hosts }}
- name: TELESCOPES_BASEPATH
value: /{{ $basePath }}
value: {{ $basePath }}
{{- end }}
command:
- "/bin/sh"
Expand Down
62 changes: 42 additions & 20 deletions charts/telescopes/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,65 @@
{{- if .Values.ingress.enabled -}}
{{- $serviceName := include "telescopes.fullname" . -}}
{{- $servicePort := .Values.service.internalPort -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
{{- $fullName := include "telescopes.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- 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: {{ template "telescopes.fullname" . }}
name: {{ $fullName }}
labels:
app: {{ template "telescopes.name" . }}
chart: {{ .Chart.Name }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
{{- 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 }}
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . }}
{{- end }}
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
{{- $url := splitList "/" . }}
- host: {{ first $url }}
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
- path: /{{ rest $url | join "/" }}
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end}}
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

38 changes: 25 additions & 13 deletions charts/telescopes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,31 @@ service:
# annotations:

ingress:
enabled: false
annotations: {}
#kubernetes.io/ingress.class: traefik
#ingress.kubernetes.io/ssl-redirect: "false"
#traefik.frontend.rule.type: PathPrefix
hosts:
- "/"
# - "domain.com/xyz"
# - "domain.com"
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
# -- Enable [ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/).
enabled: false

# -- Ingress [class name](https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-class).
className: ""

# -- Annotations to be added to the ingress.
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"

# -- Ingress host configuration.
# @default -- See [values.yaml](values.yaml).
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific

# -- Ingress TLS configuration.
# @default -- See [values.yaml](values.yaml).
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

podAnnotations: {}
# prometheus.io/scrape: "true"
Expand Down

0 comments on commit 7d662fc

Please sign in to comment.