From dd353d019f4948cb87b124f0bf083d218d78f603 Mon Sep 17 00:00:00 2001 From: Jan Stubenrauch <129169967+js-sub@users.noreply.github.com> Date: Fri, 23 Aug 2024 17:23:23 +0200 Subject: [PATCH] Update KB chart (#13) * mount application.yaml to root folder * updated chart version * unique labels for api and frontend * using labels in different locations, too --- charts/knowledge-base/Chart.yaml | 2 +- charts/knowledge-base/templates/_helpers.tpl | 32 +++++++++++++++---- charts/knowledge-base/templates/config.yaml | 2 +- .../templates/deployment_api.yaml | 8 ++--- .../templates/deployment_frontend.yaml | 6 ++-- charts/knowledge-base/templates/ingress.yaml | 2 +- charts/knowledge-base/templates/service.yaml | 4 +-- 7 files changed, 38 insertions(+), 18 deletions(-) diff --git a/charts/knowledge-base/Chart.yaml b/charts/knowledge-base/Chart.yaml index de7bc87..8d86532 100644 --- a/charts/knowledge-base/Chart.yaml +++ b/charts/knowledge-base/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: knowledge-base description: Knowledge Base frontend and API/backend type: application -version: 0.1.0 +version: 0.1.1 appVersion: "0.0.1" diff --git a/charts/knowledge-base/templates/_helpers.tpl b/charts/knowledge-base/templates/_helpers.tpl index 4c6be28..0aa661f 100644 --- a/charts/knowledge-base/templates/_helpers.tpl +++ b/charts/knowledge-base/templates/_helpers.tpl @@ -31,11 +31,11 @@ Create chart name and version as used by the chart label. {{- end }} {{/* -Common labels +Common labels API */}} -{{- define "knowledge-base.labels" -}} +{{- define "knowledge-base-api.labels" -}} helm.sh/chart: {{ include "knowledge-base.chart" . }} -{{ include "knowledge-base.selectorLabels" . }} +{{ include "knowledge-base-api.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} @@ -43,9 +43,29 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} {{/* -Selector labels +Common labels Frontend */}} -{{- define "knowledge-base.selectorLabels" -}} -app.kubernetes.io/name: {{ include "knowledge-base.name" . }} +{{- define "knowledge-base-frontend.labels" -}} +helm.sh/chart: {{ include "knowledge-base.chart" . }} +{{ include "knowledge-base-frontend.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels API +*/}} +{{- define "knowledge-base-api.selectorLabels" -}} +app.kubernetes.io/name: "{{ include "knowledge-base.name" . }}-api" +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Selector labels Frontend +*/}} +{{- define "knowledge-base-frontend.selectorLabels" -}} +app.kubernetes.io/name: "{{ include "knowledge-base.name" . }}-frontend" app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} diff --git a/charts/knowledge-base/templates/config.yaml b/charts/knowledge-base/templates/config.yaml index 676165e..f80a497 100644 --- a/charts/knowledge-base/templates/config.yaml +++ b/charts/knowledge-base/templates/config.yaml @@ -3,7 +3,7 @@ kind: ConfigMap metadata: name: {{ include "knowledge-base.fullname" . }} labels: - {{- include "knowledge-base.labels" . | nindent 4 }} + {{- include "knowledge-base-api.labels" . | nindent 4 }} data: application.yml: |- sophora: diff --git a/charts/knowledge-base/templates/deployment_api.yaml b/charts/knowledge-base/templates/deployment_api.yaml index 55623b4..1e65318 100644 --- a/charts/knowledge-base/templates/deployment_api.yaml +++ b/charts/knowledge-base/templates/deployment_api.yaml @@ -3,12 +3,12 @@ kind: Deployment metadata: name: "{{ include "knowledge-base.fullname" . }}-api" labels: - {{- include "knowledge-base.labels" . | nindent 4 }} + {{- include "knowledge-base-api.labels" . | nindent 4 }} spec: replicas: 1 selector: matchLabels: - {{- include "knowledge-base.selectorLabels" . | nindent 6 }} + {{- include "knowledge-base-api.selectorLabels" . | nindent 6 }} template: metadata: annotations: @@ -18,7 +18,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "knowledge-base.selectorLabels" . | nindent 8 }} + {{- include "knowledge-base-api.selectorLabels" . | nindent 8 }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: @@ -31,7 +31,7 @@ spec: imagePullPolicy: {{ .Values.api.image.pullPolicy }} volumeMounts: - name: config - mountPath: "/workspace/application.yml" + mountPath: "/application.yml" subPath: "application.yml" env: - name: sophora.client.server-connection.username diff --git a/charts/knowledge-base/templates/deployment_frontend.yaml b/charts/knowledge-base/templates/deployment_frontend.yaml index d66c151..d27300d 100644 --- a/charts/knowledge-base/templates/deployment_frontend.yaml +++ b/charts/knowledge-base/templates/deployment_frontend.yaml @@ -3,12 +3,12 @@ kind: Deployment metadata: name: "{{ include "knowledge-base.fullname" . }}-frontend" labels: - {{- include "knowledge-base.labels" . | nindent 4 }} + {{- include "knowledge-base-frontend.labels" . | nindent 4 }} spec: replicas: 1 selector: matchLabels: - {{- include "knowledge-base.selectorLabels" . | nindent 6 }} + {{- include "knowledge-base-frontend.selectorLabels" . | nindent 6 }} template: metadata: annotations: @@ -17,7 +17,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "knowledge-base.selectorLabels" . | nindent 8 }} + {{- include "knowledge-base-frontend.selectorLabels" . | nindent 8 }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: diff --git a/charts/knowledge-base/templates/ingress.yaml b/charts/knowledge-base/templates/ingress.yaml index 28b1501..026c3de 100644 --- a/charts/knowledge-base/templates/ingress.yaml +++ b/charts/knowledge-base/templates/ingress.yaml @@ -6,7 +6,7 @@ kind: Ingress metadata: name: {{ $fullName }} labels: - {{- include "knowledge-base.labels" . | nindent 4 }} + {{- include "knowledge-base-frontend.labels" . | nindent 4 }} {{- with .Values.ingress.annotations }} annotations: {{- toYaml . | nindent 4 }} diff --git a/charts/knowledge-base/templates/service.yaml b/charts/knowledge-base/templates/service.yaml index a0caf9a..d59bb9e 100644 --- a/charts/knowledge-base/templates/service.yaml +++ b/charts/knowledge-base/templates/service.yaml @@ -3,7 +3,7 @@ kind: Service metadata: name: {{ include "knowledge-base.fullname" . }} labels: - {{- include "knowledge-base.labels" . | nindent 4 }} + {{- include "knowledge-base-frontend.labels" . | nindent 4 }} spec: type: {{ .Values.service.type }} ports: @@ -12,4 +12,4 @@ spec: protocol: TCP name: http selector: - {{- include "knowledge-base.selectorLabels" . | nindent 4 }} + {{- include "knowledge-base-frontend.selectorLabels" . | nindent 4 }}