Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPSEXP-2286: allow passing the ATS location #115

Merged
merged 13 commits into from
Sep 22, 2023
3 changes: 3 additions & 0 deletions .checkov-values.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ elasticsearch:
reindexing:
db:
url: something
ats:
transform_url: http://transform
sfs_url: http://sfs
6 changes: 3 additions & 3 deletions charts/alfresco-search-enterprise/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
dependencies:
- name: alfresco-common
repository: https://alfresco.github.io/alfresco-helm-charts/
version: 2.1.0
version: 3.0.0-alpha.1
- name: activemq
repository: https://alfresco.github.io/alfresco-helm-charts/
version: 3.3.0
- name: elasticsearch
repository: https://helm.elastic.co
version: 7.17.3
digest: sha256:d542f131a0a88f216fdfefa55a132ad373051776e52f6cb334ad8b30dbdf5137
generated: "2023-09-20T17:55:19.77609+02:00"
digest: sha256:3217395d08bca2dca3ada26c8045f92409e4173deb0e881dd0d020c975b6217c
generated: "2023-09-21T19:55:50.962494+02:00"
4 changes: 2 additions & 2 deletions charts/alfresco-search-enterprise/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ apiVersion: v2
name: alfresco-search-enterprise
description: A Helm chart for deploying Alfresco Elasticsearch connector
type: application
version: 2.0.0
version: 3.0.0-alpha.1
appVersion: 3.3.1
dependencies:
- name: alfresco-common
version: 2.1.0
version: 3.0.0-alpha.1
repository: https://alfresco.github.io/alfresco-helm-charts/
- name: activemq
version: 3.3.0
Expand Down
9 changes: 7 additions & 2 deletions charts/alfresco-search-enterprise/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# alfresco-search-enterprise

![Version: 2.0.0](https://img.shields.io/badge/Version-2.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.3.1](https://img.shields.io/badge/AppVersion-3.3.1-informational?style=flat-square)
![Version: 3.0.0-alpha.1](https://img.shields.io/badge/Version-3.0.0--alpha.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.3.1](https://img.shields.io/badge/AppVersion-3.3.1-informational?style=flat-square)

A Helm chart for deploying Alfresco Elasticsearch connector

Expand All @@ -11,7 +11,7 @@ Please refer to the [documentation](https://github.com/Alfresco/acs-deployment/b
| Repository | Name | Version |
|------------|------|---------|
| https://alfresco.github.io/alfresco-helm-charts/ | activemq | 3.3.0 |
| https://alfresco.github.io/alfresco-helm-charts/ | alfresco-common | 2.1.0 |
| https://alfresco.github.io/alfresco-helm-charts/ | alfresco-common | 3.0.0-alpha.1 |
| https://helm.elastic.co | elasticsearch | 7.17.3 |

## Values
Expand All @@ -20,6 +20,11 @@ Please refer to the [documentation](https://github.com/Alfresco/acs-deployment/b
|-----|------|---------|-------------|
| activemq.enabled | bool | `false` | Enable embedded broker - useful when testing this chart in standalone |
| affinity | object | `{}` | |
| ats.existingConfigMap.keys.sfs_url | string | `"SFS_URL"` | Key within the configmap holding the URL of the alfresco shared filestore |
| ats.existingConfigMap.keys.transform_url | string | `"ATS_URL"` | Key within the configmap holding the URL of the alfresco transform |
| ats.existingConfigMap.name | string | `nil` | Alternatively, provide ATS details via an existing configmap |
| ats.sfs_url | string | `nil` | URL of the alfresco shared filestore (trouter or tengine-aio) |
| ats.transform_url | string | `nil` | URL of the alfresco transform (trouter or tengine-aio) |
| contentMediaTypeCache.enabled | bool | `true` | |
| contentMediaTypeCache.refreshTime | string | `"0 0 * * * *"` | |
| elasticsearch.clusterHealthCheckParams | string | `"wait_for_status=yellow&timeout=1s"` | |
Expand Down
3 changes: 3 additions & 0 deletions charts/alfresco-search-enterprise/ci/default-values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
reindexing:
# requires postgres database at startup
enabled: false
ats:
transform_url: http://alfresco-transform-services-router
sfs_url: http://alfresco-transform-services-sfs
activemq:
enabled: true
resources:
Expand Down
39 changes: 39 additions & 0 deletions charts/alfresco-search-enterprise/templates/_helpers-ats.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{/*

Render Alfresco Trasnform Service related env vars

Usage: include "alfresco-search-enterprise.transform.fullurl" "URL"

*/}}
{{- define "alfresco-search-enterprise.ats.fullurl" -}}
ATS_URL: {{ printf "%s/transform/config" . }}
{{- end -}}

{{/*

Render Alfresco Shared Filesotre related env vars

Usage: include "alfresco-search-enterprise.sfs.fullurl" "URL"

*/}}
{{- define "alfresco-search-enterprise.sfs.fullurl" -}}
SFS_URL: {{ printf "%s/alfresco/api/-default-/private/sfs/versions/1/file/" . }}
{{- end -}}

{{/*

Render common env vars

Usage: include "alfresco-search-enterprise.env" $

*/}}
{{- define "alfresco-search-enterprise.env" -}}
- name: ELASTICSEARCH_INDEXNAME
value: {{ .Values.indexName }}
- name: ALFRESCO_ACCEPTEDCONTENTMEDIATYPESCACHE_REFRESHTIME
value: {{ .Values.contentMediaTypeCache.refreshTime }}
- name: ALFRESCO_ACCEPTEDCONTENTMEDIATYPESCACHE_ENABLED
value: {{ .Values.contentMediaTypeCache.enabled | quote }}
- name: ALFRESCO_PATHINDEXINGCOMPONENT_ENABLED
value: {{ .Values.pathIndexingComponent.enabled | quote }}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{{- define "alfresco-search-enterprise.searchIndexExistingSecretName" -}}
{{ coalesce .Values.searchIndex.existingSecretName .Values.global.elasticsearch.existingSecretName (printf "%s-elasticsearch-secret" (include "alfresco-search-enterprise.fullname" .)) }}
{{- coalesce .Values.searchIndex.existingSecretName .Values.global.elasticsearch.existingSecretName (printf "%s-elasticsearch-secret" (include "alfresco-search-enterprise.fullname" .)) }}
{{- end -}}

{{- define "alfresco-search-enterprise.config.spring" -}}
{{- if .Values.elasticsearch.enabled }}
{{- if .Values.elasticsearch.enabled -}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the closing - really necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's cosmetic tbh 💅 ut I would argue that a named template should never start with a carriage return.

SPRING_ELASTICSEARCH_REST_URIS: "{{ .Values.elasticsearch.protocol }}://{{ .Values.elasticsearch.clusterName }}-{{ .Values.elasticsearch.nodeGroup }}:{{ .Values.elasticsearch.httpPort }}"
{{- else }}
{{- if and (not .Values.global.elasticsearch.host) (not .Values.searchIndex.host) }}
{{ fail "Please provide external elasticsearch connection details as values under .global.elasticsearch or .searchIndex or enable the embedded elasticsearch via .elasticsearch.enabled" }}
{{- end }}
{{- fail "Please provide external elasticsearch connection details as values under .global.elasticsearch or .searchIndex or enable the embedded elasticsearch via .elasticsearch.enabled" }}
{{- end -}}
SPRING_ELASTICSEARCH_REST_URIS: "{{ .Values.searchIndex.protocol | default .Values.global.elasticsearch.protocol }}://{{ .Values.searchIndex.host | default .Values.global.elasticsearch.host }}:{{ .Values.searchIndex.port | default .Values.global.elasticsearch.port }}"
{{- end -}}
{{- end -}}
Expand Down
11 changes: 11 additions & 0 deletions charts/alfresco-search-enterprise/templates/config-ats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if not .Values.ats.existingConfigMap.name }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "alfresco-search-enterprise.fullname" . }}-ats
labels:
{{- include "alfresco-search-enterprise.labels" $ | nindent 4 }}
data:
{{ template "alfresco-search-enterprise.ats.fullurl" (required "You need to provide the ATS URL using either ats.transform_url value or a configmap" .Values.ats.transform_url) }}
{{ template "alfresco-search-enterprise.sfs.fullurl" (required "You need to provide the SFS URL using either ats.sfs_url value or a configmap" .Values.ats.sfs_url) }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "alfresco-search-enterprise.fullname" . }}-es
labels:
{{- include "alfresco-search-enterprise.labels" $ | nindent 4 }}
data:
{{ template "alfresco-search-enterprise.config.spring" . }}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,29 @@ spec:
imagePullPolicy: {{ index $.Values "liveIndexing" (printf "%s" $serviceName) "image" "pullPolicy" }}
{{- include "component-security-context" .Values | indent 8 }}
envFrom:
- configMapRef:
name: {{ template "alfresco-search-enterprise.fullname" $ }}-configmap
- secretRef:
name: {{ default (printf "%s-messagebroker-secret" (include "alfresco-search-enterprise.fullname" $)) $.Values.messageBroker.existingSecretName }}
- configMapRef:
name: {{ template "alfresco-search-enterprise.fullname" $ }}-es
env:
{{- $ats_cm := $.Values.ats.existingConfigMap.name | default (printf "%s-ats" (include "alfresco-search-enterprise.fullname" $)) }}
- name: ALFRESCO_ACCEPTEDCONTENTMEDIATYPESCACHE_BASEURL
valueFrom:
configMapKeyRef:
name: {{ $ats_cm }}
key: {{ $.Values.ats.existingConfigMap.keys.transform_url }}
- name: ALFRESCO_SHAREDFILESTORE_BASEURL
valueFrom:
configMapKeyRef:
name: {{ $ats_cm }}
key: {{ $.Values.ats.existingConfigMap.keys.sfs_url }}
{{- include "spring.activemq.env" . | nindent 12 }}
{{- include "alfresco-search-enterprise.config.spring.envCredentials" $ | nindent 12 }}
{{- include "alfresco-search-enterprise.env" $ | nindent 12 }}
{{- range $key, $val := $.Values.liveIndexing.environment }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- end }}
ports:
- name: http
containerPort: 8080
Expand Down
17 changes: 0 additions & 17 deletions charts/alfresco-search-enterprise/templates/reindexing-config.yaml

This file was deleted.

20 changes: 19 additions & 1 deletion charts/alfresco-search-enterprise/templates/reindexing-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,30 @@ spec:
resources: {{- toYaml .Values.reindexing.resources | nindent 12 }}
envFrom:
- configMapRef:
name: {{ template "alfresco-search-enterprise.fullname" . }}-reindexing-configmap
name: {{ template "alfresco-search-enterprise.fullname" . }}-es
- secretRef:
name: {{ default (printf "%s-messagebroker-secret" (include "alfresco-search-enterprise.fullname" .)) .Values.messageBroker.existingSecretName }}
env:
{{- $dbCtx := dict "Values" (dict "nameOverride" "alfresco-database") "Chart" .Chart "Release" .Release }}
{{- $dbFullName := (include "alfresco-search-enterprise.fullname" $dbCtx) }}
{{- $ats_cm := .Values.ats.existingConfigMap.name | default (printf "%s-ats" (include "alfresco-search-enterprise.fullname" .)) }}
- name: ALFRESCO_ACCEPTEDCONTENTMEDIATYPESCACHE_BASEURL
valueFrom:
configMapKeyRef:
name: {{ $ats_cm }}
key: {{ .Values.ats.existingConfigMap.keys.transform_url }}
- name: ALFRESCO_SHAREDFILESTORE_BASEURL
valueFrom:
configMapKeyRef:
name: {{ $ats_cm }}
key: {{ .Values.ats.existingConfigMap.keys.sfs_url }}
{{- include "alfresco-search-enterprise.env" $ | nindent 12 }}
{{- range $key, $val := .Values.reindexing.environment }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- end }}
- name: ALFRESCO_REINDEX_PATHINDEXINGENABLED
value: {{ .Values.reindexing.pathIndexingEnabled | quote }}
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
suite: test liveindexing template rendering
templates:
- liveindexing-config.yaml
- config-ats.yaml
- config-elasticsearch.yaml
- liveindexing-deployment.yaml
- secret-elasticsearch.yaml
- secret-database.yaml
Expand All @@ -10,10 +11,11 @@ tests:
- it: |
Render elasticsearch Liveindexing configmap,
using global config to ensure it overrides default values.
values: &testvalues
- values/embedded-charts-values.yaml
set:
activemq:
enabled: true
global.elasticsearch:
global:
elasticsearch:
host: someglobally.used.host
user: admin
protocol: https
Expand All @@ -22,34 +24,46 @@ tests:
- equal:
path: data.SPRING_ELASTICSEARCH_REST_URIS
value: https://someglobally.used.host:1443
template: liveindexing-config.yaml
template: config-elasticsearch.yaml

- it: |
Render elasticsearch Liveindexing configmap,
using embedded elasticsearch chart.
values: &testvalues
- values/embedded-charts-values.yaml
asserts:
- equal:
path: data.SPRING_ELASTICSEARCH_REST_URIS
value: http://elasticsearch-master:9200
template: liveindexing-config.yaml

- it: should have env vars for elasticsearch credentials
Render default mainfest with embedded elasticsearch and pre-existing secret
values: *testvalues
template: liveindexing-deployment.yaml
set:
elasticsearch:
enabled: true
searchIndex:
existingSecretName: nooneknows
asserts:
- equal:
path: spec.template.spec.containers[0].env[3].name
value: SPRING_ELASTICSEARCH_REST_USERNAME
template: liveindexing-deployment.yaml
path: data.ATS_URL
value: http://transform/transform/config
template: config-ats.yaml
- equal:
path: spec.template.spec.containers[0].env[4].name
value: SPRING_ELASTICSEARCH_REST_PASSWORD
template: liveindexing-deployment.yaml

- it: should render cpu and memory limits
values: *testvalues
asserts:
path: data.SFS_URL
value: http://sfs/alfresco/api/-default-/private/sfs/versions/1/file/
template: config-ats.yaml
- equal:
path: data.SPRING_ELASTICSEARCH_REST_URIS
value: http://elasticsearch-master:9200
template: config-elasticsearch.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: SPRING_ELASTICSEARCH_REST_USERNAME
valueFrom:
secretKeyRef:
name: nooneknows
key: ELASTICSEARCH_USERNAME
- contains:
path: spec.template.spec.containers[0].env
content:
name: SPRING_ELASTICSEARCH_REST_PASSWORD
valueFrom:
secretKeyRef:
name: nooneknows
key: ELASTICSEARCH_PASSWORD
- equal:
path: spec.template.spec.containers[0].resources
value:
Expand All @@ -59,4 +73,3 @@ tests:
limits:
cpu: "2"
memory: "2048Mi"
template: liveindexing-deployment.yaml
Loading