Skip to content

Commit

Permalink
fix(charts/buildbarn): fix ingress for frontend component (#618)
Browse files Browse the repository at this point in the history
Signed-off-by: wuhuizuo <[email protected]>
  • Loading branch information
wuhuizuo authored Jun 25, 2023
1 parent 09c4559 commit a39569a
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 12 deletions.
2 changes: 1 addition & 1 deletion apps/prod/buildbarn/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ spec:
chart:
spec:
chart: buildbarn
version: 0.0.5
version: 0.0.6
sourceRef:
kind: HelmRepository
name: ee-ops
Expand Down
2 changes: 1 addition & 1 deletion charts/buildbarn/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ maintainers:
name: wuhuizuo
name: buildbarn
type: application
version: 0.0.5
version: 0.0.6
26 changes: 23 additions & 3 deletions charts/buildbarn/templates/browser/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
{{- if and .Values.browser.enabled .Values.browser.ingress.enabled -}}
{{- $fullName := include "buildbarn.fullname" (list . "browser") -}}
{{- $svcPort := .Values.browser.service.port -}}
{{- if and .Values.browser.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.browser.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.browser.ingress.annotations "kubernetes.io/ingress.class" .Values.browser.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "buildbarn.labels" (list . "browser") | nindent 4 }}
{{- with .Values.browser.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.browser.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.browser.ingress.className }}
{{- end }}
{{- if .Values.browser.ingress.tls }}
tls:
{{- range .Values.browser.ingress.tls }}
Expand All @@ -29,13 +42,20 @@ spec:
http:
paths:
{{- range .paths }}
- path: {{ . }}
pathType: Prefix
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
28 changes: 24 additions & 4 deletions charts/buildbarn/templates/frontend/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
{{- if and .Values.frontend.enabled .Values.frontend.ingress.enabled -}}
{{- $fullName := include "buildbarn.fullname" (list . "frontend") -}}
{{- $svcPort := .Values.frontend.service.port -}}
{{- if and .Values.frontend.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.frontend.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.frontend.ingress.annotations "kubernetes.io/ingress.class" .Values.frontend.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ include "buildbarn.fullname" (list . "frontend") }}
namespace: {{ .Release.Namespace }}
name: {{ $fullName }}
labels:
{{- include "buildbarn.labels" (list . "frontend") | nindent 4 }}
{{- with .Values.frontend.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.frontend.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.frontend.ingress.className }}
{{- end }}
{{- if .Values.frontend.ingress.tls }}
tls:
{{- range .Values.frontend.ingress.tls }}
Expand All @@ -29,13 +42,20 @@ spec:
http:
paths:
{{- range .paths }}
- path: {{ . }}
pathType: Prefix
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
13 changes: 10 additions & 3 deletions charts/buildbarn/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ browser:
ingress:
# browser.ingress.enabled -- enables Ingress
enabled: false
# browser.ingress.className -- ingress class name
className: ""
# browser.ingress.annotations -- ingress annotations
annotations: {}
# kubernetes.io/ingress.class: nginx
Expand All @@ -111,7 +113,9 @@ browser:
# browser.ingress.hosts -- ingress accepted hostnames
hosts: []
# - host: chart-example.local
# paths: []
# paths:
# - path: /
# pathType: ImplementationSpecific
# browser.ingress.tls -- ingress TLS configuration
tls: []
# - secretName: chart-example-tls
Expand Down Expand Up @@ -172,15 +176,18 @@ frontend:
ingress:
# frontend.ingress.enabled -- enables Ingress
enabled: false
# frontend.ingress.className -- ingress class name
className: ""
# frontend.ingress.annotations -- ingress annotations
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"

# frontend.ingress.hosts -- ingress accepted hostnames
hosts: []
# - host: chart-example.local
# paths: []
# paths:
# - path: /
# pathType: ImplementationSpecific
# frontend.ingress.tls -- ingress TLS configuration
tls: []
# - secretName: chart-example-tls
Expand Down

0 comments on commit a39569a

Please sign in to comment.