From 7dcbb76e711a9b8b7e2fecb27ea4aeb0cd0cd70a Mon Sep 17 00:00:00 2001 From: Haveiss Date: Wed, 6 Dec 2023 09:56:44 +0700 Subject: [PATCH] feat(app): support additional ingress (#68) * feat(app): support additional ingress * refactor(app): enforce kube git version --- stable/app/Chart.yaml | 2 +- stable/app/templates/ingress.yaml | 68 +++++++++++++++++++++---------- stable/app/values.yaml | 15 +++++++ stable/compass/Chart.yaml | 6 +-- 4 files changed, 66 insertions(+), 25 deletions(-) diff --git a/stable/app/Chart.yaml b/stable/app/Chart.yaml index 3e429bfe..aa93615d 100644 --- a/stable/app/Chart.yaml +++ b/stable/app/Chart.yaml @@ -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 diff --git a/stable/app/templates/ingress.yaml b/stable/app/templates/ingress.yaml index b083ec00..67ed1af3 100644 --- a/stable/app/templates/ingress.yaml +++ b/stable/app/templates/ingress.yaml @@ -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 }} @@ -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 }} diff --git a/stable/app/values.yaml b/stable/app/values.yaml index 2bbf9128..81055736 100644 --- a/stable/app/values.yaml +++ b/stable/app/values.yaml @@ -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: {} diff --git a/stable/compass/Chart.yaml b/stable/compass/Chart.yaml index 5bbfc50f..73e18715 100644 --- a/stable/compass/Chart.yaml +++ b/stable/compass/Chart.yaml @@ -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/"