Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 6cafb41

Browse files
authored
Merge pull request #129 from melchanatan/feature/ingress-mutiple-path
Feature/ingress-mutipath
2 parents 96a5c6b + 970df18 commit 6cafb41

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

charts/onechart/templates/ingress.yaml

+17-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
{{- if .longName }}
66
{{- $resourceName = printf "%s-%s" $robustName (include "robustName" .ingress.host) -}}
77
{{- end }}
8+
{{- $svcPort := .root.Values.svcPort -}}
9+
{{- $containerPort := .root.Values.containerPort -}}
10+
811
---
912
apiVersion: networking.k8s.io/v1
1013
kind: Ingress
@@ -43,14 +46,27 @@ spec:
4346
rules:
4447
- host: {{ .ingress.host | quote }}
4548
http:
49+
{{- if not .ingress.paths }}
4650
paths:
4751
- path: {{ .ingress.path | default "/" | quote }}
4852
pathType: {{ .ingress.pathType | default "Prefix" | quote }}
4953
backend:
5054
service:
5155
name: {{ $robustName }}
5256
port:
53-
number: {{ if .root.Values.svcPort }}{{ .root.Values.svcPort }}{{ else }}{{ .root.Values.containerPort }}{{ end }}
57+
number: {{ if $svcPort }}{{ $svcPort }}{{ else }}{{ $containerPort }}{{ end }}
58+
{{- else }}
59+
paths:
60+
{{- range .ingress.paths }}
61+
- path: {{ .path | quote }}
62+
pathType: {{ .pathType | default "Prefix" | quote }}
63+
backend:
64+
service:
65+
name: {{ $robustName }}
66+
port:
67+
number: {{ if $svcPort }}{{ $svcPort }}{{ else }}{{ $containerPort }}{{ end }}
68+
{{- end }}
69+
{{- end }}
5470
{{- end }}
5571

5672
{{- with .Values.ingress }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
suite: test ingress
2+
templates:
3+
- ingress.yaml
4+
tests:
5+
- it: Should default
6+
set:
7+
ingress:
8+
host: chart-example.local
9+
asserts:
10+
- equal:
11+
path: spec.rules[0].http.paths[0].path
12+
value: "/"
13+
- it: Should use paths
14+
set:
15+
ingress:
16+
host: chart-example.local
17+
paths:
18+
- path: /mypath
19+
- path: /mypath2
20+
asserts:
21+
- equal:
22+
path: spec.rules[0].http.paths[0].path
23+
value: "/mypath"
24+
- equal:
25+
path: spec.rules[0].http.paths[1].path
26+
value: "/mypath2"

0 commit comments

Comments
 (0)