Skip to content

Commit

Permalink
feat(app): support additional ingress (#68)
Browse files Browse the repository at this point in the history
* feat(app): support additional ingress

* refactor(app): enforce kube git version
  • Loading branch information
haveiss authored Dec 6, 2023
1 parent 736d809 commit 7dcbb76
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 25 deletions.
2 changes: 1 addition & 1 deletion stable/app/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ 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.5.11
version: 0.5.12
68 changes: 47 additions & 21 deletions stable/app/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "app.fullname" . -}}
{{- 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 -}}
{{- $labels := include "app.labels" . -}}
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: {{ $fullName }}
labels:
{{- include "app.labels" . | nindent 4 }}
{{- $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) }}
{{- if .Values.ingress.className }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
Expand All @@ -43,20 +33,56 @@ spec:
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: {{ ternary $fullName .backend.service.name (empty .backend.service.name) }}
port:
number: {{ .backend.service.port.number }}
{{- else }}
serviceName: {{ ternary $fullName .backend.service.name (empty .backend.service.name) }}
servicePort: {{ .backend.service.port.number }}
{{- end }}
{{- end }}
{{- end }}

{{- if .Values.ingress.additionalIngress }}
{{- range .Values.ingress.additionalIngress }}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ printf "%s-%s" $fullName .name }}
labels:
{{- $labels | nindent 4 }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .className }}
ingressClassName: {{ .className }}
{{- end }}
{{- if .tls }}
tls:
{{- range .tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ ternary $fullName .backend.service.name (empty .backend.service.name) }}
port:
number: {{ .backend.service.port.number }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions stable/app/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ ingress:
# -- - secretName: chart-example-tls
# -- hosts:
# -- - chart-example.local
additionalIngress:
- name: grpc
className: ""
annotations: {}
hosts:
- host: grpc-chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
# name: backend_01
port:
number: 8081
tls: []

resources:
{}
Expand Down
6 changes: 3 additions & 3 deletions stable/compass/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ apiVersion: v2
name: compass
description: A Helm chart for running Compass in Kubernetes
type: application
version: 0.2.1
appVersion: "0.5.7"
version: 0.2.2
appVersion: "0.5.12"
dependencies:
- name: app
version: "0.5.6"
version: "0.5.12"
repository: "https://goto.github.io/charts/"

0 comments on commit 7dcbb76

Please sign in to comment.