From 0e191bfc7a2ae339b54abfd2aa9fa21843f69cb4 Mon Sep 17 00:00:00 2001 From: mattkaar Date: Fri, 25 Jun 2021 02:28:45 +0800 Subject: [PATCH] Support custom Ingress path (#151) Adds support for a custom Ingress path. This allows us to run Gitea as a path in an existing domain. Co-authored-by: Matt Kaar Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/151 Reviewed-by: luhahn Reviewed-by: justusbunsi Co-authored-by: mattkaar Co-committed-by: mattkaar --- README.md | 4 +++- templates/NOTES.txt | 4 +++- templates/gitea/ingress.yaml | 14 ++++++++------ values.yaml | 5 ++++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7283168..5c567cb 100644 --- a/README.md +++ b/README.md @@ -455,7 +455,9 @@ Annotations can be added to the Gitea pod. |---------------------|-----------------------------------|------------------------------| |ingress.enabled| enable ingress | false| |ingress.annotations| add ingress annotations | | -|ingress.hosts| add hosts for ingress as string list | git.example.com | +|ingress.hosts[0].host | add hosts for ingress | git.example.com | +|ingress.hosts[0].paths[0].path | add path for each ingress host | / | +|ingress.hosts[0].paths[0].pathType | add ingress path type | Prefix | |ingress.tls|add ingress tls settings|[]| ### Service diff --git a/templates/NOTES.txt b/templates/NOTES.txt index 8ed67dd..25b35e7 100644 --- a/templates/NOTES.txt +++ b/templates/NOTES.txt @@ -1,7 +1,9 @@ 1. Get the application URL by running these commands: {{- if .Values.ingress.enabled }} {{- range $host := .Values.ingress.hosts }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}/ + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} {{- end }} {{- else if contains "NodePort" .Values.service.http.type }} export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "gitea.fullname" . }}) diff --git a/templates/gitea/ingress.yaml b/templates/gitea/ingress.yaml index f1a03c1..e7cb645 100644 --- a/templates/gitea/ingress.yaml +++ b/templates/gitea/ingress.yaml @@ -29,13 +29,14 @@ spec: {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ . | quote }} + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} http: paths: - - path: / - {{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }} - pathType: Prefix + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType ($.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress") }} + pathType: {{ .pathType }} {{- end }} backend: {{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }} @@ -47,5 +48,6 @@ spec: serviceName: {{ $fullName }}-http servicePort: {{ $httpPort }} {{- end }} - {{- end }} + {{- end }} + {{- end }} {{- end }} diff --git a/values.yaml b/values.yaml index ddb72e2..ef0d804 100644 --- a/values.yaml +++ b/values.yaml @@ -54,7 +54,10 @@ ingress: # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" hosts: - - git.example.com + - host: git.example.com + paths: + - path: / + pathType: Prefix tls: [] # - secretName: chart-example-tls # hosts: