Skip to content

Commit

Permalink
Merge pull request #32 from gimlet-io/v1-ingress-support
Browse files Browse the repository at this point in the history
Using networking.k8s.io/v1 Ingress; requires cluster versions >= 1.19
  • Loading branch information
laszlocph authored Sep 29, 2021
2 parents 47ae89c + 13d860f commit 213303b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 30 deletions.
15 changes: 11 additions & 4 deletions charts/onechart/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{- $resourceName = printf "%s-%s" $robustName (include "robustName" .ingress.host) -}}
{{- end }}
---
apiVersion: networking.k8s.io/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $resourceName }}
Expand All @@ -26,6 +26,9 @@ metadata:
{{- end }}
{{- end }}
spec:
{{- if .ingress.ingressClassName }}
ingressClassName: {{ .ingress.ingressClassName }}
{{- end }}
{{- if default false .ingress.tlsEnabled }}
tls:
- hosts:
Expand All @@ -36,9 +39,13 @@ spec:
- host: {{ .ingress.host | quote }}
http:
paths:
- backend:
serviceName: {{ $robustName }}
servicePort: {{ if .root.Values.svcPort }}{{ .root.Values.svcPort }}{{ else }}{{ .root.Values.containerPort }}{{ end }}
- path: "/"
pathType: "Prefix"
backend:
service:
name: {{ $robustName }}
port:
number: {{ if .root.Values.svcPort }}{{ .root.Values.svcPort }}{{ else }}{{ .root.Values.containerPort }}{{ end }}
{{- end }}

{{- with .Values.ingress }}
Expand Down
33 changes: 25 additions & 8 deletions charts/onechart/tests/ingress_domain_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ tests:
- host: chart-example.local
http:
paths:
- backend:
serviceName: release-name
servicePort: 80
- path: "/"
pathType: "Prefix"
backend:
service:
name: release-name
port:
number: 80
- it: Should pass ingress host name as is, user must sanitize it
set:
ingress:
Expand All @@ -41,20 +45,33 @@ tests:
- host: feature/my_branch.local
http:
paths:
- backend:
serviceName: release-name
servicePort: 80
- path: "/"
pathType: "Prefix"
backend:
service:
name: release-name
port:
number: 80
- it: Should set Ingress annotation
set:
ingress:
host: chart-example.local
annotations:
kubernetes.io/ingress.class: nginx
just/a-random: annotation
asserts:
- equal:
path: metadata.annotations
value:
kubernetes.io/ingress.class: nginx
just/a-random: annotation
- it: Should set ingress class
set:
ingress:
host: chart-example.local
ingressClassName: nginx
asserts:
- equal:
path: spec.ingressClassName
value: nginx
- it: Should generate multiple ingresses
set:
ingresses:
Expand Down
4 changes: 2 additions & 2 deletions charts/onechart/tests/ingress_port_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tests:
containerPort: 1234
asserts:
- equal:
path: spec.rules[0].http.paths[0].backend.servicePort
path: spec.rules[0].http.paths[0].backend.service.port.number
value: 1234
- it: Should use service port
set:
Expand All @@ -19,5 +19,5 @@ tests:
containerPort: 5678
asserts:
- equal:
path: spec.rules[0].http.paths[0].backend.servicePort
path: spec.rules[0].http.paths[0].backend.service.port.number
value: 1234
17 changes: 1 addition & 16 deletions values.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
ingress:
host: chart-example.local
annotations:
kubernetes.io/ingress.class: nginx
ingresses:
- host: chart-example.local
tlsEnabled: true
annotations:
kubernetes.io/ingress.class: nginx
- host: another.local
tlsEnabled: true
annotations:
kubernetes.io/ingress.class: nginx
ingressClassName: nginx

gitRepository: github.com/laszlocph/demo-app
gitSha: xyz

vars:
MY_VAR: "value"

volumes:
- name: data
path: /data
existingClaim: myclaim

0 comments on commit 213303b

Please sign in to comment.