From 235e6ebaedfee923b10bf2daed622d5ff28961da Mon Sep 17 00:00:00 2001 From: Jesper Svendsen <99078145+jesper7@users.noreply.github.com> Date: Tue, 4 Apr 2023 17:28:28 +0200 Subject: [PATCH] Make the ingress host field optional (#94) * Make the ingress host field optional * Bump chart version to 0.1.26 * Remove leftover labels * Fix blobvault ingress annotation * Make TLS depend on hostnameEnabled * Fix comparator --- charts/studio/Chart.yaml | 2 +- .../studio/templates/ingress-blobvault.yaml | 53 +++++++++++++++++++ charts/studio/templates/ingress-studio.yaml | 12 +++-- charts/studio/values.yaml | 7 +-- 4 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 charts/studio/templates/ingress-blobvault.yaml diff --git a/charts/studio/Chart.yaml b/charts/studio/Chart.yaml index e3ae2f58..e3543d7e 100644 --- a/charts/studio/Chart.yaml +++ b/charts/studio/Chart.yaml @@ -15,7 +15,7 @@ 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.1.25 +version: 0.1.26 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/studio/templates/ingress-blobvault.yaml b/charts/studio/templates/ingress-blobvault.yaml new file mode 100644 index 00000000..1f574273 --- /dev/null +++ b/charts/studio/templates/ingress-blobvault.yaml @@ -0,0 +1,53 @@ +{{- if .Values.global.ingress.enabled -}} +{{- if and .Values.global.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.global.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.global.ingress.annotations "kubernetes.io/ingress.class" .Values.global.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: blobvault + annotations: + nginx.ingress.kubernetes.io/rewrite-target: /$2 + {{- with .Values.global.ingress.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.global.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.global.ingress.className }} + {{- end }} + {{- if and .Values.global.ingress.tlsEnabled .Values.global.ingress.hostnameEnabled }} + tls: + - hosts: + - {{ .Values.global.host }} + secretName: {{ .Values.global.ingress.tlsSecretName }} + {{- end }} + rules: + - http: + paths: + - path: /blobvault(/|$)(.*) + {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} + pathType: ImplementationSpecific + {{- end }} + backend: + {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ .Release.Name }}-nginx + port: + name: http + {{- else }} + serviceName: {{ .Release.Name }}-nginx + servicePort: 80 + {{- end }} + {{- if .Values.global.ingress.hostnameEnabled }} + host: {{ .Values.global.host }} + {{- end }} +{{- end }} + diff --git a/charts/studio/templates/ingress-studio.yaml b/charts/studio/templates/ingress-studio.yaml index fec38965..e056ff0a 100644 --- a/charts/studio/templates/ingress-studio.yaml +++ b/charts/studio/templates/ingress-studio.yaml @@ -13,7 +13,7 @@ apiVersion: extensions/v1beta1 {{- end }} kind: Ingress metadata: - name: studio + name: app labels: {{- include "studio-ui.labels" . | nindent 4 }} {{- with .Values.global.ingress.annotations }} @@ -24,15 +24,14 @@ spec: {{- if and .Values.global.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} ingressClassName: {{ .Values.global.ingress.className }} {{- end }} - {{- if .Values.global.ingress.tlsEnabled }} + {{- if and .Values.global.ingress.tlsEnabled .Values.global.ingress.hostnameEnabled }} tls: - hosts: - {{ .Values.global.host }} secretName: {{ .Values.global.ingress.tlsSecretName }} {{- end }} rules: - - host: {{ .Values.global.host }} - http: + - http: paths: - path: / {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} @@ -74,6 +73,9 @@ spec: number: {{ .Values.studioBackend.service.port }} {{- else }} serviceName: studio-backend - servicePort: {{ .Values.stu.service.port }} + servicePort: {{ .Values.studioBackend.service.port }} {{- end }} + {{- if .Values.global.ingress.hostnameEnabled }} + host: {{ .Values.global.host }} + {{- end }} {{- end }} diff --git a/charts/studio/values.yaml b/charts/studio/values.yaml index f2f192ac..d40276ec 100644 --- a/charts/studio/values.yaml +++ b/charts/studio/values.yaml @@ -55,6 +55,7 @@ global: ingress: enabled: true + hostnameEnabled: true className: "" annotations: {} # kubernetes.io/ingress.class: nginx @@ -139,11 +140,7 @@ nginx: type: ClusterIP ingress: - enabled: true - hostname: "localhost" - path: /blobvault(/|$)(.*) - annotations: - nginx.ingress.kubernetes.io/rewrite-target: /$2 + enabled: false extraVolumes: - name: blobvault