Skip to content

Commit

Permalink
OPSEXP-2071 use standard helmv3 labels for resources in sync chart (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
gionn authored Apr 14, 2023
1 parent c1af338 commit 91ae679
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 53 deletions.
2 changes: 1 addition & 1 deletion charts/alfresco-sync-service/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ keywords:
name: alfresco-sync-service
sources:
- https://github.com/Alfresco/acs-deployment
version: 4.0.4
version: 4.0.5
appVersion: 4.0.0-M7
icon: https://avatars0.githubusercontent.com/u/391127?s=200&v=4
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion charts/alfresco-sync-service/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# alfresco-sync-service

![Version: 4.0.4](https://img.shields.io/badge/Version-4.0.4-informational?style=flat-square) ![AppVersion: 4.0.0-M7](https://img.shields.io/badge/AppVersion-4.0.0--M7-informational?style=flat-square)
![Version: 4.0.5](https://img.shields.io/badge/Version-4.0.5-informational?style=flat-square) ![AppVersion: 4.0.0-M7](https://img.shields.io/badge/AppVersion-4.0.0--M7-informational?style=flat-square)

Alfresco Sync Service

Expand Down
4 changes: 2 additions & 2 deletions charts/alfresco-sync-service/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ Alfresco Sync Service
Sync endpoint available at {{ printf "%s/%s" (default "" .Values.ingress.hostName) .Values.ingress.path }}
Using required components:
- Content repostory: http://{{ .Values.repository.host }}:{{ .Values.repository.port }}
- ActiveMQ: {{ template "syncservice.brokerUrl" . }}
- SQL datbase: {{ template "syncservice.dbUrl" . }}
- ActiveMQ: {{ template "alfresco-sync-service.brokerUrl" . }}
- SQL datbase: {{ template "alfresco-sync-service.dbUrl" . }}
8 changes: 4 additions & 4 deletions charts/alfresco-sync-service/templates/_helpers-db.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/*
Get Database Username
*/}}
{{- define "syncservice.dbUser" -}}
{{- define "alfresco-sync-service.dbUser" -}}
{{- $defaultUser := "alfresco" }}
{{- if .Values.postgresql.enabled }}
{{- coalesce .Values.postgresql.auth.username $defaultUser }}
Expand All @@ -13,7 +13,7 @@ Get Database Username
{{/*
Get Database Password
*/}}
{{- define "syncservice.dbPass" -}}
{{- define "alfresco-sync-service.dbPass" -}}
{{- $defaultPass := "admin" }}
{{- if .Values.postgresql.enabled }}
{{- coalesce .Values.postgresql.auth.password $defaultPass }}
Expand All @@ -25,7 +25,7 @@ Get Database Password
{{/*
Get Database Driver
*/}}
{{- define "syncservice.dbDriver" -}}
{{- define "alfresco-sync-service.dbDriver" -}}
{{- $defaultDriver := "org.postgresql.Driver" }}
{{- if .Values.postgresql.enabled }}
{{- $defaultDriver }}
Expand All @@ -37,7 +37,7 @@ Get Database Driver
{{/*
Get Database URL
*/}}
{{- define "syncservice.dbUrl" -}}
{{- define "alfresco-sync-service.dbUrl" -}}
{{- if .Values.postgresql.enabled }}
{{- $pgsvcname := printf "%s-%s" .Release.Name .Values.postgresql.nameOverride }}
{{- $pgsvcport := "" }}
Expand Down
10 changes: 5 additions & 5 deletions charts/alfresco-sync-service/templates/_helpers-mq.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/*
Get ActiveMQ URL
*/}}
{{- define "syncservice.brokerUrl" -}}
{{- define "alfresco-sync-service.brokerUrl" -}}
{{- $brokerOptions := "?timeout=3000&jms.useCompression=true" }}
{{- $brokerPort := .Values.activemq.services.broker.ports.external.openwire | int }}
{{- if .Values.activemq.enabled }}
Expand All @@ -15,7 +15,7 @@ Get ActiveMQ URL
{{/*
Get ActiveMQ Username
*/}}
{{- define "syncservice.brokerUser" -}}
{{- define "alfresco-sync-service.brokerUser" -}}
{{- if .Values.activemq.enabled }}
{{- .Values.activemq.adminUser.user -}}
{{- else }}
Expand All @@ -26,7 +26,7 @@ Get ActiveMQ Username
{{/*
Get ActiveMQ Password
*/}}
{{- define "syncservice.brokerPass" -}}
{{- define "alfresco-sync-service.brokerPass" -}}
{{- if .Values.activemq.enabled }}
{{- .Values.activemq.adminUser.password -}}
{{- else }}
Expand All @@ -37,9 +37,9 @@ Get ActiveMQ Password
{{/*
Get ActiveMQ secret
*/}}
{{- define "syncservice.brokerSecret" -}}
{{- define "alfresco-sync-service.brokerSecret" -}}
{{- if .Values.activemq.enabled }}
{{- coalesce .Values.activemq.existingSecretName (printf "%s-messagebroker-secret" (include "syncservice.fullname" . )) -}}
{{- coalesce .Values.activemq.existingSecretName (printf "%s-messagebroker-secret" (include "alfresco-sync-service.fullname" . )) -}}
{{- else }}
{{- coalesce .Values.messageBroker.existingSecretName .Values.global.messageBroker.existingSecretName -}}
{{- end }}
Expand Down
59 changes: 45 additions & 14 deletions charts/alfresco-sync-service/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,25 +1,56 @@
{{/*
Create a default fully qualified name.
Expand the name of the chart.
*/}}
{{- define "alfresco-sync-service.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "syncservice.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- define "alfresco-sync-service.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{- define "syncservice.selectorLabels" -}}
app: {{ template "syncservice.fullname" . }}
release: {{ .Release.Name }}
component: syncservice
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "alfresco-sync-service.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "syncservice.labels" -}}
chart: {{ .Chart.Name }}
{{ include "syncservice.selectorLabels" . }}
heritage: {{ .Release.Service }}
{{/*
Common labels
*/}}
{{- define "alfresco-sync-service.labels" -}}
helm.sh/chart: {{ include "alfresco-sync-service.chart" . }}
{{ include "alfresco-sync-service.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "alfresco-sync-service.selectorLabels" -}}
app.kubernetes.io/name: {{ include "alfresco-sync-service.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "syncservice.repository" -}}
{{- define "alfresco-sync-service.repository" -}}
{{- if .Values.repository.nameOverride }}
{{- printf "%s-%s" .Release.Name .Values.repository.nameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand Down
10 changes: 5 additions & 5 deletions charts/alfresco-sync-service/templates/config-syncservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "syncservice.fullname" . }}-configmap
name: {{ template "alfresco-sync-service.fullname" . }}-configmap
labels:
{{- include "syncservice.labels" . | nindent 4 }}
{{- include "alfresco-sync-service.labels" . | nindent 4 }}
data:
JAVA_OPTS: >-
-Dsql.db.url={{ include "syncservice.dbUrl" . }}
-Dsql.db.driver={{ include "syncservice.dbDriver" . | quote }}
-Dsql.db.url={{ include "alfresco-sync-service.dbUrl" . }}
-Dsql.db.driver={{ include "alfresco-sync-service.dbDriver" . | quote }}
-Dsql.db.username=$DATABASE_USERNAME
-Dsql.db.password=$DATABASE_PASSWORD
-Drepo.hostname={{ template "syncservice.repository" . }}
-Drepo.hostname={{ template "alfresco-sync-service.repository" . }}
-Drepo.port={{ .Values.repository.port }}
-Ddw.server.applicationConnectors[0].type=http
-Dmessaging.broker.url=$BROKER_URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "syncservice.fullname" . }}
name: {{ template "alfresco-sync-service.fullname" . }}
labels:
{{- include "syncservice.labels" . | nindent 4 }}
{{- include "alfresco-sync-service.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "syncservice.selectorLabels" . | nindent 6 }}
{{- include "alfresco-sync-service.selectorLabels" . | nindent 6 }}
strategy:
type: RollingUpdate
rollingUpdate:
{{ toYaml .Values.global.strategy.rollingUpdate | indent 6 }}
template:
metadata:
labels:
{{- include "syncservice.selectorLabels" . | nindent 8 }}
{{- include "alfresco-sync-service.selectorLabels" . | nindent 8 }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/config-syncservice.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/secret-database.yaml") . | sha256sum }}
Expand All @@ -35,11 +35,11 @@ spec:
{{- include "component-security-context" .Values | indent 6 }}
envFrom:
- secretRef:
name: {{ template "syncservice.fullname" . }}-dbsecret
name: {{ template "alfresco-sync-service.fullname" . }}-dbsecret
- configMapRef:
name: {{ template "syncservice.fullname" . }}-configmap
name: {{ template "alfresco-sync-service.fullname" . }}-configmap
- secretRef:
name: {{ template "syncservice.brokerSecret" . }}
name: {{ template "alfresco-sync-service.brokerSecret" . }}
ports:
- name: serviceport
containerPort: 9090
Expand Down
4 changes: 2 additions & 2 deletions charts/alfresco-sync-service/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{- $serviceName := (include "syncservice.fullname" .) -}}
{{- $serviceName := (include "alfresco-sync-service.fullname" .) -}}
{{- $servicePort := .Values.service.externalPort -}}
apiVersion: {{ template "common.capabilities.ingress.apiVersion" . }}
kind: Ingress
metadata:
name: {{ template "syncservice.fullname" . }}-ingress
name: {{ template "alfresco-sync-service.fullname" . }}-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/rewrite-target: /alfresco/$2
Expand Down
8 changes: 4 additions & 4 deletions charts/alfresco-sync-service/templates/secret-database.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "syncservice.fullname" . }}-dbsecret
name: {{ template "alfresco-sync-service.fullname" . }}-dbsecret
labels:
{{- include "syncservice.labels" . | nindent 4 }}
{{- include "alfresco-sync-service.labels" . | nindent 4 }}
type: Opaque
data:
DATABASE_USERNAME: {{ include "syncservice.dbUser" . | b64enc | quote }}
DATABASE_PASSWORD: {{ include "syncservice.dbPass" . | b64enc | quote }}
DATABASE_USERNAME: {{ include "alfresco-sync-service.dbUser" . | b64enc | quote }}
DATABASE_PASSWORD: {{ include "alfresco-sync-service.dbPass" . | b64enc | quote }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "syncservice.fullname" . }}-messagebroker-secret
name: {{ template "alfresco-sync-service.fullname" . }}-messagebroker-secret
labels:
{{- include "syncservice.labels" . | nindent 4 }}
{{- include "alfresco-sync-service.labels" . | nindent 4 }}
type: Opaque
data:
BROKER_URL: {{ include "syncservice.brokerUrl" . | b64enc | quote }}
BROKER_USERNAME: {{ include "syncservice.brokerUser" . | b64enc | quote }}
BROKER_PASSWORD: {{ include "syncservice.brokerPass" . | b64enc | quote }}
BROKER_URL: {{ include "alfresco-sync-service.brokerUrl" . | b64enc | quote }}
BROKER_USERNAME: {{ include "alfresco-sync-service.brokerUser" . | b64enc | quote }}
BROKER_PASSWORD: {{ include "alfresco-sync-service.brokerPass" . | b64enc | quote }}
{{- end }}
6 changes: 3 additions & 3 deletions charts/alfresco-sync-service/templates/svc-syncservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "syncservice.fullname" . }}
name: {{ template "alfresco-sync-service.fullname" . }}
labels:
{{- include "syncservice.labels" . | nindent 4 }}
{{- include "alfresco-sync-service.labels" . | nindent 4 }}
spec:
selector:
{{- include "syncservice.selectorLabels" . | nindent 4 }}
{{- include "alfresco-sync-service.selectorLabels" . | nindent 4 }}
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.externalPort }}
Expand Down

0 comments on commit 91ae679

Please sign in to comment.