Skip to content

Commit 2215086

Browse files
authored
merge(#976): refactored Ingress chart template
2 parents 609a98f + ba8979c commit 2215086

File tree

3 files changed

+52
-17
lines changed

3 files changed

+52
-17
lines changed

charts/cloudinfo/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
description: Cloud instance type and price information as a service
33
name: cloudinfo
4-
version: 0.9.0
4+
version: 0.10.0
55

66
appVersion: "0.18.0"
77

+36-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
{{- if .Values.frontend.ingress.enabled -}}
22
{{- $fullName := include "cloudinfo.frontend.fullname" . -}}
3+
{{- $svcPort := .Values.frontend.service.port -}}
4+
{{- if and .Values.frontend.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
5+
{{- if not (hasKey .Values.frontend.ingress.annotations "kubernetes.io/ingress.class") }}
6+
{{- $_ := set .Values.frontend.ingress.annotations "kubernetes.io/ingress.class" .Values.frontend.ingress.className}}
7+
{{- end }}
8+
{{- end }}
9+
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
310
apiVersion: networking.k8s.io/v1
11+
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
12+
apiVersion: networking.k8s.io/v1beta1
13+
{{- else -}}
14+
apiVersion: extensions/v1beta1
15+
{{- end }}
416
kind: Ingress
517
metadata:
618
name: {{ $fullName }}
@@ -15,29 +27,40 @@ metadata:
1527
{{- toYaml . | nindent 4 }}
1628
{{- end }}
1729
spec:
18-
ingressClassName: {{ .Values.frontend.ingress.ingressClassName }}
19-
{{- if .Values.frontend.ingress.tls }}
30+
{{- if and .Values.frontend.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
31+
ingressClassName: {{ .Values.frontend.ingress.className }}
32+
{{- end }}
33+
{{- if .Values.frontend.ingress.tls }}
2034
tls:
21-
{{- range .Values.frontend.ingress.tls }}
35+
{{- range .Values.frontend.ingress.tls }}
2236
- hosts:
23-
{{- range .hosts }}
37+
{{- range .hosts }}
2438
- {{ . | quote }}
25-
{{- end }}
39+
{{- end }}
2640
secretName: {{ .secretName }}
41+
{{- end }}
2742
{{- end }}
28-
{{- end }}
2943
rules:
30-
{{- range .Values.frontend.ingress.hosts }}
31-
{{- $url := splitList "/" . }}
32-
- host: {{ first $url }}
44+
{{- range .Values.frontend.ingress.hosts }}
45+
- host: {{ .host | quote }}
3346
http:
3447
paths:
35-
- path: /{{ rest $url | join "/" }}
36-
pathType: {{ .Values.frontend.ingress.pathType }}
48+
{{- range .paths }}
49+
- path: {{ .path }}
50+
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
51+
pathType: {{ .pathType }}
52+
{{- end }}
3753
backend:
54+
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
3855
service:
3956
name: {{ $fullName }}
4057
port:
41-
number: {{ .Values.frontend.service.port }}
42-
{{- end }}
58+
number: {{ $svcPort }}
59+
{{- else }}
60+
serviceName: {{ $fullName }}
61+
servicePort: {{ $svcPort }}
62+
{{- end }}
63+
{{- end }}
64+
{{- end }}
4365
{{- end }}
66+

charts/cloudinfo/values.yaml

+15-3
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,31 @@ frontend:
2525
port: 80
2626

2727
ingress:
28+
# -- Enable [ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/).
2829
enabled: false
29-
ingressClassName: traefik
30+
31+
# -- Ingress [class name](https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-class).
32+
className: ""
33+
34+
# -- Annotations to be added to the ingress.
3035
annotations: {}
3136
# kubernetes.io/ingress.class: nginx
3237
# kubernetes.io/tls-acme: "true"
38+
39+
# -- Ingress host configuration.
40+
# @default -- See [values.yaml](values.yaml).
3341
hosts:
34-
- "/"
42+
- host: chart-example.local
43+
paths:
44+
- path: /
45+
pathType: ImplementationSpecific
3546

47+
# -- Ingress TLS configuration.
48+
# @default -- See [values.yaml](values.yaml).
3649
tls: []
3750
# - secretName: chart-example-tls
3851
# hosts:
3952
# - chart-example.local
40-
pathType: Prefix
4153

4254
resources: {}
4355
# We usually recommend not to specify default resources and to leave this as a conscious

0 commit comments

Comments
 (0)