Skip to content

Commit

Permalink
Update KB chart (#13)
Browse files Browse the repository at this point in the history
* mount application.yaml to root folder

* updated chart version

* unique labels for api and frontend

* using labels in different locations, too
  • Loading branch information
js-sub authored Aug 23, 2024
1 parent 9c66308 commit dd353d0
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 18 deletions.
2 changes: 1 addition & 1 deletion charts/knowledge-base/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
32 changes: 26 additions & 6 deletions charts/knowledge-base/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,41 @@ 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 }}
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 }}
2 changes: 1 addition & 1 deletion charts/knowledge-base/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions charts/knowledge-base/templates/deployment_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions charts/knowledge-base/templates/deployment_frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion charts/knowledge-base/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions charts/knowledge-base/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -12,4 +12,4 @@ spec:
protocol: TCP
name: http
selector:
{{- include "knowledge-base.selectorLabels" . | nindent 4 }}
{{- include "knowledge-base-frontend.selectorLabels" . | nindent 4 }}

0 comments on commit dd353d0

Please sign in to comment.