From c814ddf7185313689e574395fad0bb4603fb28c9 Mon Sep 17 00:00:00 2001 From: Jose Santorum Date: Tue, 14 May 2024 20:59:30 +0200 Subject: [PATCH] chore: allow to split ingress (cherry picked from commit a0ee2747be9d61243d6f92c97d6bb5035a66c345) --- charts/motive-service/Chart.yaml | 2 +- charts/motive-service/README.md | 3 +- .../templates/ingress-public-split.yaml | 66 +++++++++++++++++++ .../templates/ingress-public.yaml | 2 +- charts/motive-service/values.yaml | 1 + 5 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 charts/motive-service/templates/ingress-public-split.yaml diff --git a/charts/motive-service/Chart.yaml b/charts/motive-service/Chart.yaml index 238215a..297d81a 100644 --- a/charts/motive-service/Chart.yaml +++ b/charts/motive-service/Chart.yaml @@ -4,6 +4,6 @@ description: A Helm chart for Kubernetes type: application -version: 2.0.6 +version: 2.0.7 appVersion: "1.0.0" diff --git a/charts/motive-service/README.md b/charts/motive-service/README.md index 60c3085..e93dec8 100644 --- a/charts/motive-service/README.md +++ b/charts/motive-service/README.md @@ -1,6 +1,6 @@ # motive-service -![Version: 2.0.6](https://img.shields.io/badge/Version-2.0.6-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square) +![Version: 2.0.7](https://img.shields.io/badge/Version-2.0.7-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square) A Helm chart for Kubernetes @@ -29,6 +29,7 @@ A Helm chart for Kubernetes | ingress.public.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | | | ingress.public.hosts[0].paths[0].port | int | `8080` | | | ingress.public.hosts[0].paths[0].portName | string | `"http"` | | +| ingress.public.split | bool | `false` | | | ingress.public.tls | list | `[]` | | | metrics.enabled | bool | See values.yaml | Enable and configure a Prometheus serviceMonitor for the chart under this key. | | metrics.podMonitor.annotations | object | `{}` | | diff --git a/charts/motive-service/templates/ingress-public-split.yaml b/charts/motive-service/templates/ingress-public-split.yaml new file mode 100644 index 0000000..8d4fd05 --- /dev/null +++ b/charts/motive-service/templates/ingress-public-split.yaml @@ -0,0 +1,66 @@ +{{- with .Values.ingress.public -}} +{{- if and .enabled .split -}} +{{- if and .className (not (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .annotations "kubernetes.io/ingress.class" .className}} + {{- end }} +{{- end }} +{{- $ingressConfig := . -}} +{{- $counter := 0 | int -}} +{{- range $host := .hosts }} +{{- 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: {{ include "motive-service.fullname" $ }}-public-{{ $counter }} + labels: + {{- include "motive-service.serviceLabels" $ | nindent 4 }} + {{- $annotations := merge ($host.annotations | default (dict)) $ingressConfig.annotations -}} + {{- with $annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and $ingressConfig.className (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ $ingressConfig.className }} + {{- end }} + {{- if $ingressConfig.tls }} + tls: + {{- range $ingressConfig.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + - host: {{ $host.host | quote }} + http: + paths: + {{- range $host.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: {{ include "motive-service.fullname" $ }} + port: + name: {{ .portName | default "http" }} + {{- else }} + serviceName: {{ include "motive-service.fullname" $ }} + servicePort: {{ .port | default 8080 }} + {{- end }} + {{- end }} +--- +{{- $counter = add1 $counter -}} +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/motive-service/templates/ingress-public.yaml b/charts/motive-service/templates/ingress-public.yaml index de028a9..0ae2ce0 100644 --- a/charts/motive-service/templates/ingress-public.yaml +++ b/charts/motive-service/templates/ingress-public.yaml @@ -1,5 +1,5 @@ {{- with .Values.ingress.public -}} -{{- if .enabled -}} +{{- if and .enabled (not .split) -}} {{- if and .className (not (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion)) }} {{- if not (hasKey .annotations "kubernetes.io/ingress.class") }} {{- $_ := set .annotations "kubernetes.io/ingress.class" .className}} diff --git a/charts/motive-service/values.yaml b/charts/motive-service/values.yaml index ef5a7b8..f71d254 100644 --- a/charts/motive-service/values.yaml +++ b/charts/motive-service/values.yaml @@ -427,6 +427,7 @@ ingress: public: enabled: false + split: false className: nginx-public annotations: {} # nginx.ingress.kubernetes.io/enable-opentelemetry: "true"