From 91ae67978b29b53b00c7529b47b7e9ff2917a151 Mon Sep 17 00:00:00 2001 From: Giovanni Toraldo Date: Fri, 14 Apr 2023 09:12:03 +0200 Subject: [PATCH] OPSEXP-2071 use standard helmv3 labels for resources in sync chart (#34) --- charts/alfresco-sync-service/Chart.yaml | 2 +- charts/alfresco-sync-service/README.md | 2 +- .../alfresco-sync-service/templates/NOTES.txt | 4 +- .../templates/_helpers-db.tpl | 8 +-- .../templates/_helpers-mq.tpl | 10 ++-- .../templates/_helpers.tpl | 59 ++++++++++++++----- .../templates/config-syncservice.yaml | 10 ++-- .../templates/deployment-syncservice.yaml | 14 ++--- .../templates/ingress.yaml | 4 +- .../templates/secret-database.yaml | 8 +-- .../templates/secret-message-broker.yaml | 10 ++-- .../templates/svc-syncservice.yaml | 6 +- 12 files changed, 84 insertions(+), 53 deletions(-) diff --git a/charts/alfresco-sync-service/Chart.yaml b/charts/alfresco-sync-service/Chart.yaml index 747bdeb3..5b13b1e4 100644 --- a/charts/alfresco-sync-service/Chart.yaml +++ b/charts/alfresco-sync-service/Chart.yaml @@ -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: diff --git a/charts/alfresco-sync-service/README.md b/charts/alfresco-sync-service/README.md index 1b35ef89..4cb2f107 100644 --- a/charts/alfresco-sync-service/README.md +++ b/charts/alfresco-sync-service/README.md @@ -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 diff --git a/charts/alfresco-sync-service/templates/NOTES.txt b/charts/alfresco-sync-service/templates/NOTES.txt index 8fed6068..3d482969 100644 --- a/charts/alfresco-sync-service/templates/NOTES.txt +++ b/charts/alfresco-sync-service/templates/NOTES.txt @@ -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" . }} diff --git a/charts/alfresco-sync-service/templates/_helpers-db.tpl b/charts/alfresco-sync-service/templates/_helpers-db.tpl index 440b6929..3f93d0c6 100644 --- a/charts/alfresco-sync-service/templates/_helpers-db.tpl +++ b/charts/alfresco-sync-service/templates/_helpers-db.tpl @@ -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 }} @@ -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 }} @@ -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 }} @@ -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 := "" }} diff --git a/charts/alfresco-sync-service/templates/_helpers-mq.tpl b/charts/alfresco-sync-service/templates/_helpers-mq.tpl index 3ade644f..75f803b3 100644 --- a/charts/alfresco-sync-service/templates/_helpers-mq.tpl +++ b/charts/alfresco-sync-service/templates/_helpers-mq.tpl @@ -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 }} @@ -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 }} @@ -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 }} @@ -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 }} diff --git a/charts/alfresco-sync-service/templates/_helpers.tpl b/charts/alfresco-sync-service/templates/_helpers.tpl index 16a4e778..2375db12 100644 --- a/charts/alfresco-sync-service/templates/_helpers.tpl +++ b/charts/alfresco-sync-service/templates/_helpers.tpl @@ -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 }} diff --git a/charts/alfresco-sync-service/templates/config-syncservice.yaml b/charts/alfresco-sync-service/templates/config-syncservice.yaml index 64c807f0..cbd6eed9 100644 --- a/charts/alfresco-sync-service/templates/config-syncservice.yaml +++ b/charts/alfresco-sync-service/templates/config-syncservice.yaml @@ -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 diff --git a/charts/alfresco-sync-service/templates/deployment-syncservice.yaml b/charts/alfresco-sync-service/templates/deployment-syncservice.yaml index 13280af3..bdbd07bc 100644 --- a/charts/alfresco-sync-service/templates/deployment-syncservice.yaml +++ b/charts/alfresco-sync-service/templates/deployment-syncservice.yaml @@ -2,14 +2,14 @@ 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: @@ -17,7 +17,7 @@ spec: 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 }} @@ -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 diff --git a/charts/alfresco-sync-service/templates/ingress.yaml b/charts/alfresco-sync-service/templates/ingress.yaml index f6841dce..ff78387f 100644 --- a/charts/alfresco-sync-service/templates/ingress.yaml +++ b/charts/alfresco-sync-service/templates/ingress.yaml @@ -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 diff --git a/charts/alfresco-sync-service/templates/secret-database.yaml b/charts/alfresco-sync-service/templates/secret-database.yaml index 39ddb69d..1e3017e3 100644 --- a/charts/alfresco-sync-service/templates/secret-database.yaml +++ b/charts/alfresco-sync-service/templates/secret-database.yaml @@ -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 }} diff --git a/charts/alfresco-sync-service/templates/secret-message-broker.yaml b/charts/alfresco-sync-service/templates/secret-message-broker.yaml index 1b28302e..41f2b236 100644 --- a/charts/alfresco-sync-service/templates/secret-message-broker.yaml +++ b/charts/alfresco-sync-service/templates/secret-message-broker.yaml @@ -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 }} diff --git a/charts/alfresco-sync-service/templates/svc-syncservice.yaml b/charts/alfresco-sync-service/templates/svc-syncservice.yaml index 5e3411ea..98d4c270 100644 --- a/charts/alfresco-sync-service/templates/svc-syncservice.yaml +++ b/charts/alfresco-sync-service/templates/svc-syncservice.yaml @@ -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 }}