From 9bc425d144fe9426e4665e2ed6ff9e9aa01b3e33 Mon Sep 17 00:00:00 2001 From: Giovanni Toraldo Date: Fri, 5 Jan 2024 09:23:25 +0100 Subject: [PATCH] fix secondary resources --- .../templates/_helpers-name.tpl | 7 ++++++- .../templates/deployment.yaml | 2 +- .../templates/ingress.yaml | 15 ++++++++------- .../templates/secret-ingress.yaml | 5 ++--- .../templates/secret-repository.yaml | 8 +++----- .../templates/service.yaml | 10 +++------- .../tests/ingress_test.yaml | 2 +- charts/alfresco-search-service/values.yaml | 4 ++-- 8 files changed, 26 insertions(+), 27 deletions(-) diff --git a/charts/alfresco-search-service/templates/_helpers-name.tpl b/charts/alfresco-search-service/templates/_helpers-name.tpl index 9d136b92a..d7de1a294 100644 --- a/charts/alfresco-search-service/templates/_helpers-name.tpl +++ b/charts/alfresco-search-service/templates/_helpers-name.tpl @@ -9,6 +9,11 @@ {{- end }} {{- define "alfresco-search-service.repository-config.name" -}} -{{- $scope := (dict "Values" (dict "nameOverride" "repository-config" ) "Chart" .Chart "Release" .Release) }} +{{- $scope := (dict "Values" (dict "nameOverride" "solr-repository-config" ) "Chart" .Chart "Release" .Release) }} +{{- include "alfresco-search-service.fullname" $scope }} +{{- end }} + +{{- define "alfresco-search-service.ingress-secret.name" -}} +{{- $scope := (dict "Values" (dict "nameOverride" "solr-ingress-credentials" ) "Chart" .Chart "Release" .Release) }} {{- include "alfresco-search-service.fullname" $scope }} {{- end }} diff --git a/charts/alfresco-search-service/templates/deployment.yaml b/charts/alfresco-search-service/templates/deployment.yaml index b0abb84cf..80f4916cc 100644 --- a/charts/alfresco-search-service/templates/deployment.yaml +++ b/charts/alfresco-search-service/templates/deployment.yaml @@ -121,7 +121,7 @@ spec: {{- end }} {{- with .Values.affinity }} affinity: - {{- toYaml . | nindent 8 }} + {{- tpl . $ | nindent 8 }} {{- end }} {{- with .Values.tolerations }} tolerations: diff --git a/charts/alfresco-search-service/templates/ingress.yaml b/charts/alfresco-search-service/templates/ingress.yaml index fa08ebeb2..b7ba97a84 100644 --- a/charts/alfresco-search-service/templates/ingress.yaml +++ b/charts/alfresco-search-service/templates/ingress.yaml @@ -1,18 +1,19 @@ {{- if .Values.ingress.enabled }} -{{- $serviceName := printf "%s-%s" (include "alfresco-search-service.fullname" .) "solr" -}} {{- $servicePort := .Values.service.name | default (include "alfresco-search.svcPort" .) -}} -{{- $backendSvc := dict "serviceName" $serviceName "servicePort" $servicePort "context" $ -}} +{{- $backendSvc := dict "serviceName" (include "alfresco-search-service.deployment.name" .) "servicePort" $servicePort "context" $ -}} apiVersion: {{ template "common.capabilities.ingress.apiVersion" . }} kind: Ingress metadata: - name: {{ template "alfresco-search-service.fullname" . }}-solr + name: {{ template "alfresco-search-service.deployment.name" . }} annotations: kubernetes.io/ingress.class: "nginx" - nginx.ingress.kubernetes.io/auth-secret: {{ $.Values.ingress.existingSecretName | default (printf "%s-ingress-secret" (include "alfresco-search-service.fullname" $)) }} - {{- if .Values.ingress.annotations -}} - {{ toYaml .Values.ingress.annotations | nindent 4 }} - {{- end }} + nginx.ingress.kubernetes.io/auth-secret: {{ $.Values.ingress.existingSecretName | default (include "alfresco-search-service.ingress-secret.name" .) }} + {{- if .Values.ingress.annotations -}} + {{- toYaml .Values.ingress.annotations | nindent 4 }} + {{- end }} + labels: + {{- include "alfresco-search-service.labels" . | nindent 4 }} spec: {{- if .Values.ingress.tls }} tls: diff --git a/charts/alfresco-search-service/templates/secret-ingress.yaml b/charts/alfresco-search-service/templates/secret-ingress.yaml index 0149def85..08dd4e364 100644 --- a/charts/alfresco-search-service/templates/secret-ingress.yaml +++ b/charts/alfresco-search-service/templates/secret-ingress.yaml @@ -2,10 +2,9 @@ apiVersion: v1 kind: Secret metadata: - name: {{ template "alfresco-search-service.fullname" . }}-ingress-secret + name: {{ template "alfresco-search-service.ingress-secret.name" . }} labels: - app: {{ template "alfresco-search-service.fullname" . }}-solr - release: {{ .Release.Name }} + {{- include "alfresco-search-service.labels" . | nindent 4 }} type: Opaque data: auth: {{ .Values.ingress.basicAuth | quote }} diff --git a/charts/alfresco-search-service/templates/secret-repository.yaml b/charts/alfresco-search-service/templates/secret-repository.yaml index ccf31a87c..9dcc1880a 100644 --- a/charts/alfresco-search-service/templates/secret-repository.yaml +++ b/charts/alfresco-search-service/templates/secret-repository.yaml @@ -1,9 +1,8 @@ -{{- if (not .Values.repository.existingSecret.name) }} -{{- if and (eq "secret" .Values.repository.securecomms) (not .Values.repository.existingConfigMap.name) }} +{{- if and (not .Values.repository.existingSecret.name) (eq "secret" .Values.repository.securecomms) }} apiVersion: v1 kind: Secret -metadata: {{- $ctx := dict "Values" (dict "nameOverride" (printf "%s-repository" $.Chart.Name )) "Chart" $.Chart "Release" $.Release }} - name: {{ template "alfresco-search-service.fullname" $ctx }} +metadata: + name: {{ template "alfresco-search-service.repository-config.name" . }} labels: {{ template "alfresco-search-service.labels" . }} type: Opaque @@ -12,4 +11,3 @@ data: {{- $shared_secret := required $reqmsg (index .Values.repository "sharedSecret") }} SOLR_ALFRESCO_SECURECOMMS_SECRET: {{ $shared_secret | b64enc | quote }} {{- end }} -{{- end }} diff --git a/charts/alfresco-search-service/templates/service.yaml b/charts/alfresco-search-service/templates/service.yaml index 51ed6b44c..dda2f7dc7 100644 --- a/charts/alfresco-search-service/templates/service.yaml +++ b/charts/alfresco-search-service/templates/service.yaml @@ -2,12 +2,9 @@ apiVersion: v1 kind: Service metadata: - name: {{ template "alfresco-search-service.fullname" . }}-solr + name: {{ template "alfresco-search-service.deployment.name" . }} labels: - app: {{ template "alfresco-search-service.fullname" . }}-solr - chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "alfresco-search-service.labels" . | nindent 4 }} spec: type: {{ .Values.service.type }} ports: @@ -15,5 +12,4 @@ spec: targetPort: {{ template "alfresco-search.containerPort" . }} name: {{ .Values.service.name }} selector: - app: {{ template "alfresco-search-service.fullname" . }}-solr - release: {{ .Release.Name }} + {{- include "alfresco-search-service.selectorLabels" . | nindent 4 }} diff --git a/charts/alfresco-search-service/tests/ingress_test.yaml b/charts/alfresco-search-service/tests/ingress_test.yaml index c38d31c64..4290b77ef 100644 --- a/charts/alfresco-search-service/tests/ingress_test.yaml +++ b/charts/alfresco-search-service/tests/ingress_test.yaml @@ -10,7 +10,7 @@ tests: asserts: - equal: path: metadata.name - value: RELEASE-NAME-alfresco-search-service-solr + value: RELEASE-NAME-solr template: ingress.yaml - equal: path: metadata.annotations['nginx.ingress.kubernetes.io/auth-secret'] diff --git a/charts/alfresco-search-service/values.yaml b/charts/alfresco-search-service/values.yaml index 9e9ca18ab..59c973a59 100644 --- a/charts/alfresco-search-service/values.yaml +++ b/charts/alfresco-search-service/values.yaml @@ -134,10 +134,10 @@ initContainer: global: alfrescoRegistryPullSecrets: quay-registry-secret - nodeSelector: {} tolerations: [] -affinity: {} +# -- Pod affinity, passed thru tpl function +affinity: |- serviceAccount: # -- Specifies whether a service account should be created