Skip to content

Commit

Permalink
move annotations to values to be less buried, add required use regex …
Browse files Browse the repository at this point in the history
…annotation and create tests
  • Loading branch information
pmacius committed Jan 8, 2025
1 parent 7d560c3 commit 49d0515
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 49 deletions.
6 changes: 5 additions & 1 deletion charts/alfresco-sync-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ Checkout [alfresco-content-services chart's doc](https://github.com/Alfresco/acs
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"quay.io/alfresco/service-sync"` | |
| image.tag | string | `"5.1.0"` | |
| ingress.extraAnnotations | object | `{}` | useful when running Sync service without SSL termination done by a load balancer, e.g. when ran on Minikube for testing purposes nginx.ingress.kubernetes.io/ssl-redirect: "false" |
| ingress.annotations."nginx.ingress.kubernetes.io/affinity" | string | `"cookie"` | |
| ingress.annotations."nginx.ingress.kubernetes.io/rewrite-target" | string | `"/alfresco/$2"` | |
| ingress.annotations."nginx.ingress.kubernetes.io/session-cookie-hash" | string | `"sha1"` | |
| ingress.annotations."nginx.ingress.kubernetes.io/session-cookie-name" | string | `"sync_affinity_route"` | |
| ingress.annotations."nginx.ingress.kubernetes.io/use-regex" | string | `"true"` | |
| ingress.hosts[0].paths[0].path | string | `"/syncservice(/|$)(.*)"` | |
| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
| ingress.tls | list | `[]` | |
Expand Down
11 changes: 3 additions & 8 deletions charts/alfresco-sync-service/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@ apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ template "alfresco-sync-service.fullname" . }}
{{- with .Values.ingress.annotations }}
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /alfresco/$2
nginx.ingress.kubernetes.io/affinity: "cookie"
nginx.ingress.kubernetes.io/session-cookie-name: "sync_affinity_route"
nginx.ingress.kubernetes.io/session-cookie-hash: "sha1"
{{- if .Values.ingress.extraAnnotations }}
{{ toYaml .Values.ingress.extraAnnotations | indent 4 }}
{{- end }}

{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: nginx
{{- if .Values.ingress.tls }}
Expand Down
100 changes: 64 additions & 36 deletions charts/alfresco-sync-service/tests/ingress_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,68 @@ suite: test sync ingress
templates:
- ingress.yaml
tests:
- it: should render default rules
asserts:
- equal:
path: spec.rules
value:
- host:
http:
paths:
- backend:
service:
name: RELEASE-NAME-alfresco-sync-service
port:
number: 80
path: /syncservice(/|$)(.*)
pathType: ImplementationSpecific
- it: should render rules with host
set:
ingress:
hosts:
- host: testhost
paths:
- path: /syncservice(/|$)(.*)
pathType: ImplementationSpecific
asserts:
- equal:
path: spec.rules
value:
- it: should render default rules
asserts:
- equal:
path: spec.rules
value:
- host:
http:
paths:
- backend:
service:
name: RELEASE-NAME-alfresco-sync-service
port:
number: 80
path: /syncservice(/|$)(.*)
pathType: ImplementationSpecific

- it: should render rules with host
set:
ingress:
hosts:
- host: testhost
http:
paths:
- backend:
service:
name: RELEASE-NAME-alfresco-sync-service
port:
number: 80
path: /syncservice(/|$)(.*)
pathType: ImplementationSpecific
paths:
- path: /syncservice(/|$)(.*)
pathType: ImplementationSpecific
asserts:
- equal:
path: spec.rules
value:
- host: testhost
http:
paths:
- backend:
service:
name: RELEASE-NAME-alfresco-sync-service
port:
number: 80
path: /syncservice(/|$)(.*)
pathType: ImplementationSpecific

- it: should render ingress with default annotations
asserts:
- equal:
path: metadata.annotations
value:
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /alfresco/$2
nginx.ingress.kubernetes.io/affinity: "cookie"
nginx.ingress.kubernetes.io/session-cookie-name: "sync_affinity_route"
nginx.ingress.kubernetes.io/session-cookie-hash: "sha1"

- it: should render ingress with custom annotations
set:
ingress:
annotations:
custom-annotation: "custom-value"
asserts:
- equal:
path: metadata.annotations
value:
custom-annotation: "custom-value"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /alfresco/$2
nginx.ingress.kubernetes.io/affinity: "cookie"
nginx.ingress.kubernetes.io/session-cookie-name: "sync_affinity_route"
nginx.ingress.kubernetes.io/session-cookie-hash: "sha1"
10 changes: 6 additions & 4 deletions charts/alfresco-sync-service/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,12 @@ database:
# -- Key within the secret holding the database password
password: DATABASE_PASSWORD
ingress:
# -- useful when running Sync service without SSL termination done by a load
# balancer, e.g. when ran on Minikube for testing purposes
# nginx.ingress.kubernetes.io/ssl-redirect: "false"
extraAnnotations: {}
annotations:
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /alfresco/$2
nginx.ingress.kubernetes.io/affinity: "cookie"
nginx.ingress.kubernetes.io/session-cookie-name: "sync_affinity_route"
nginx.ingress.kubernetes.io/session-cookie-hash: "sha1"
tls: []
hosts:
- paths:
Expand Down

0 comments on commit 49d0515

Please sign in to comment.