Skip to content

Commit

Permalink
Merge pull request #129 from melchanatan/feature/ingress-mutiple-path
Browse files Browse the repository at this point in the history
Feature/ingress-mutipath
  • Loading branch information
laszlocph authored May 21, 2024
2 parents 96a5c6b + 970df18 commit 6cafb41
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
Binary file modified charts/cron-job/charts/common-0.5.1.tgz
Binary file not shown.
Binary file modified charts/onechart/charts/common-0.5.1.tgz
Binary file not shown.
18 changes: 17 additions & 1 deletion charts/onechart/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
{{- if .longName }}
{{- $resourceName = printf "%s-%s" $robustName (include "robustName" .ingress.host) -}}
{{- end }}
{{- $svcPort := .root.Values.svcPort -}}
{{- $containerPort := .root.Values.containerPort -}}

---
apiVersion: networking.k8s.io/v1
kind: Ingress
Expand Down Expand Up @@ -43,14 +46,27 @@ spec:
rules:
- host: {{ .ingress.host | quote }}
http:
{{- if not .ingress.paths }}
paths:
- path: {{ .ingress.path | default "/" | quote }}
pathType: {{ .ingress.pathType | default "Prefix" | quote }}
backend:
service:
name: {{ $robustName }}
port:
number: {{ if .root.Values.svcPort }}{{ .root.Values.svcPort }}{{ else }}{{ .root.Values.containerPort }}{{ end }}
number: {{ if $svcPort }}{{ $svcPort }}{{ else }}{{ $containerPort }}{{ end }}
{{- else }}
paths:
{{- range .ingress.paths }}
- path: {{ .path | quote }}
pathType: {{ .pathType | default "Prefix" | quote }}
backend:
service:
name: {{ $robustName }}
port:
number: {{ if $svcPort }}{{ $svcPort }}{{ else }}{{ $containerPort }}{{ end }}
{{- end }}
{{- end }}
{{- end }}

{{- with .Values.ingress }}
Expand Down
26 changes: 26 additions & 0 deletions charts/onechart/tests/ingress_multipath_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
suite: test ingress
templates:
- ingress.yaml
tests:
- it: Should default
set:
ingress:
host: chart-example.local
asserts:
- equal:
path: spec.rules[0].http.paths[0].path
value: "/"
- it: Should use paths
set:
ingress:
host: chart-example.local
paths:
- path: /mypath
- path: /mypath2
asserts:
- equal:
path: spec.rules[0].http.paths[0].path
value: "/mypath"
- equal:
path: spec.rules[0].http.paths[1].path
value: "/mypath2"

0 comments on commit 6cafb41

Please sign in to comment.