Skip to content

Commit

Permalink
OPSEXP-2488 Configurable ingress class in repository chart (#211)
Browse files Browse the repository at this point in the history
Co-authored-by: pmacius <[email protected]>
  • Loading branch information
pmacius and pmacius authored Feb 5, 2024
1 parent ee00ff6 commit 1d6b14e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 51 deletions.
2 changes: 1 addition & 1 deletion charts/alfresco-repository/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: alfresco-repository
description: Alfresco content repository Helm chart
type: application
version: 0.1.3
version: 0.2.0
appVersion: 23.1.1
dependencies:
- name: alfresco-common
Expand Down
3 changes: 2 additions & 1 deletion charts/alfresco-repository/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# alfresco-repository

![Version: 0.1.3](https://img.shields.io/badge/Version-0.1.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 23.1.1](https://img.shields.io/badge/AppVersion-23.1.1-informational?style=flat-square)
![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 23.1.1](https://img.shields.io/badge/AppVersion-23.1.1-informational?style=flat-square)

Alfresco content repository Helm chart

Expand Down Expand Up @@ -82,6 +82,7 @@ Checkout [alfresco-content-services chart's doc](https://github.com/Alfresco/acs
| image.tag | string | `"23.1.1"` | |
| imagePullSecrets | list | `[]` | |
| ingress.annotations | object | `{"nginx.ingress.kubernetes.io/affinity":"cookie","nginx.ingress.kubernetes.io/proxy-body-size":"5g","nginx.ingress.kubernetes.io/session-cookie-hash":"sha1","nginx.ingress.kubernetes.io/session-cookie-name":"alfrescoRepo"}` | provide annotations for nginx ingress (no toher ingress is supported at that point) |
| ingress.className | string | `"nginx"` | supported ingress class |
| ingress.enabled | bool | `true` | Toggle ingress |
| ingress.hosts[0].paths[0].path | string | `"/"` | |
| ingress.hosts[0].paths[0].pathType | string | `"Prefix"` | |
Expand Down
29 changes: 2 additions & 27 deletions charts/alfresco-repository/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,9 @@
{{- $fullName := include "alfresco-repository.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{/*
We only support nginx ingress for now: https://alfresco.atlassian.net/browse/OPSEXP-131
so forcibly set the ingress.class annotation to nginx for pre 1.18 k8s
We only support latest apiVersion which is stable now.
*/}}
{{- if not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
{{- $_ := unset .Values.ingress.annotations "kubernetes.io/ingress.class" }}
{{- $_ = set .Values.ingress.annotations "kubernetes.io/ingress.class" "nginx" }}
{{- 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 }}
Expand All @@ -26,16 +15,7 @@ metadata:
{{- include "alfresco-common.nginx.annotations" .Values }}
{{- include "alfresco-common.nginx.secure.annotations" .Values }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{/*
We only support nginx ingress for now: https://alfresco.atlassian.net/browse/OPSEXP-131
so forcibly set the ingressClassName to nginx for post 1.18 k8s
*/}}
{{- if (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: nginx
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
Expand All @@ -53,19 +33,14 @@ so forcibly set the ingressClassName to nginx for post 1.18 k8s
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
{{- if .pathType }}
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 }}
56 changes: 34 additions & 22 deletions charts/alfresco-repository/tests/ingress_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,57 @@ tests:
location ~ ^/.*/proxy/.*/api/solr/.*$ {return 403;}
location ~ ^/.*/-default-/proxy/.*/api/.*$ {return 403;}
location ~ ^/.*/s/prometheus$ {return 403;}
template: ingress.yaml
- equal:
path: spec.ingressClassName
value: nginx
template: ingress.yaml

- it: should sanitize ingress
capabilities:
majorVersion: 1
minorVersion: 17
set:
ingress:
annotations:
kubernetes.io/ingress.class: myfancyClass
nginx.ingress.kubernetes.io/server-snippet: listen 6666;
asserts:
- notMatchRegex:
path: metadata.annotations['nginx.ingress.kubernetes.io/server-snippet']
pattern: listen 6666;
template: ingress.yaml
- equal:
path: metadata.annotations['kubernetes.io/ingress.class']
path: spec.ingressClassName
value: nginx
template: ingress.yaml

- it: should sanitize ingress
capabilities:
majorVersion: 1
minorVersion: 19
- it: should render default rules section
asserts:
- equal:
path: spec.rules
value:
- host:
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: RELEASE-NAME-alfresco-repository
port:
number: 80
- path: /api-explorer
pathType: Prefix
backend:
service:
name: RELEASE-NAME-alfresco-repository
port:
number: 80

- it: should render tls section with specified values
set:
ingress:
annotations:
nginx.ingress.kubernetes.io/server-snippet: listen 6666;
tls:
- secretName: chart-example-tls
hosts:
- chart-example.local
asserts:
- notMatchRegex:
path: metadata.annotations['nginx.ingress.kubernetes.io/server-snippet']
pattern: listen 6666;
template: ingress.yaml
- equal:
path: spec.ingressClassName
value: nginx
template: ingress.yaml
path: spec.tls
value:
- hosts:
- "chart-example.local"
secretName: chart-example-tls
2 changes: 2 additions & 0 deletions charts/alfresco-repository/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ ingress:
nginx.ingress.kubernetes.io/affinity: "cookie"
nginx.ingress.kubernetes.io/session-cookie-name: "alfrescoRepo"
nginx.ingress.kubernetes.io/session-cookie-hash: "sha1"
# -- supported ingress class
className: nginx
hosts:
- paths:
- path: /
Expand Down

0 comments on commit 1d6b14e

Please sign in to comment.