Skip to content

Commit

Permalink
Make it possible to use an ingress without kong being enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhpalm committed Jul 30, 2024
1 parent 4eda664 commit 4f7700b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
60 changes: 60 additions & 0 deletions charts/kubernetes-dashboard/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,63 @@ private.key: {{ randBytes 256 | b64enc | quote }}
{{- fail "value of .Values.app.ingress.issuer.scope must be one of [default, cluster, disabled]"}}
{{- end -}}
{{- end -}}

{{- define "kubernetes-dashboard.ingress.paths" -}}
paths:
{{- if eq .Values.app.mode "dashboard" }}
- pathType: Exact
path: {{ .Values.app.ingress.path }}api/v1/login
backend:
service:
name: {{ template "kubernetes-dashboard.name" . }}-{{ .Values.auth.role }}
port:
{{- with (index .Values.auth.containers.ports 0) }}
number: {{ .containerPort }}
{{- end }}
- pathType: Exact
path: {{ .Values.app.ingress.path }}api/v1/csrftoken/login
backend:
service:
name: {{ template "kubernetes-dashboard.name" . }}-{{ .Values.auth.role }}
port:
{{- with (index .Values.auth.containers.ports 0) }}
number: {{ .containerPort }}
{{- end }}
- pathType: Exact
path: {{ .Values.app.ingress.path }}api/v1/me
backend:
service:
name: {{ template "kubernetes-dashboard.name" . }}-{{ .Values.auth.role }}
port:
{{- with (index .Values.auth.containers.ports 0) }}
number: {{ .containerPort }}
{{- end }}
- pathType: Prefix
path: {{ .Values.app.ingress.path }}
backend:
service:
name: {{ template "kubernetes-dashboard.name" . }}-{{ .Values.web.role }}
port:
{{- with (index .Values.web.containers.ports 0) }}
number: {{ .containerPort }}
{{- end }}
{{- end }}
- pathType: Prefix
path: {{ .Values.app.ingress.path }}api
backend:
service:
name: {{ template "kubernetes-dashboard.name" . }}-{{ .Values.api.role }}
port:
{{- with (index .Values.api.containers.ports 0) }}
number: {{ .containerPort }}
{{- end }}
- pathType: Prefix
path: {{ .Values.app.ingress.path }}metrics
backend:
service:
name: {{ template "kubernetes-dashboard.name" . }}-{{ .Values.api.role }}
port:
{{- with (index .Values.api.containers.ports 0) }}
number: {{ .containerPort }}
{{- end }}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/kubernetes-dashboard/templates/config/gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

{{- if eq .Values.app.mode "dashboard" }}
{{- if and .Values.kong.enabled (eq .Values.app.mode "dashboard") }}

apiVersion: v1
kind: ConfigMap
Expand Down
8 changes: 8 additions & 0 deletions charts/kubernetes-dashboard/templates/networking/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ spec:
{{- range $host := .Values.app.ingress.hosts }}
- host: {{ $host }}
http:
{{- if $.Values.kong.enabled }}
paths:
{{- if not (eq $.Values.app.ingress.path "/") }}
- path: {{ $.Values.app.ingress.path }}(/|$)(.*)
Expand All @@ -73,9 +74,13 @@ spec:
name: {{ template "kong.fullname" (index $.Subcharts "kong") }}-proxy
port:
number: {{ $.Values.kong.proxy.tls.servicePort }}
{{- else }}
{{- include "kubernetes-dashboard.ingress.paths" $ | nindent 9 }}
{{- end }}
{{- end }}
{{- else }}
- http:
{{- if .Values.kong.enabled }}
paths:
- path: {{ .Values.app.ingress.path }}
pathType: {{ .Values.app.ingress.pathType }}
Expand All @@ -84,5 +89,8 @@ spec:
name: {{ template "kong.fullname" (index $.Subcharts "kong") }}-proxy
port:
number: {{ $.Values.kong.proxy.tls.servicePort }}
{{- else }}
{{- include "kubernetes-dashboard.ingress.paths" $ | nindent 9 }}
{{- end }}
{{- end }}
{{- end }}

0 comments on commit 4f7700b

Please sign in to comment.