Skip to content

Commit 9c66308

Browse files
authored
new chart for knowledge base (#12)
* basic kb chart * cleaned up ingress.yaml * added values-test.yaml to template each file
1 parent 96edf07 commit 9c66308

File tree

9 files changed

+411
-0
lines changed

9 files changed

+411
-0
lines changed

charts/knowledge-base/Chart.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: knowledge-base
3+
description: Knowledge Base frontend and API/backend
4+
type: application
5+
version: 0.1.0
6+
appVersion: "0.0.1"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "knowledge-base.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "knowledge-base.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "knowledge-base.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "knowledge-base.labels" -}}
37+
helm.sh/chart: {{ include "knowledge-base.chart" . }}
38+
{{ include "knowledge-base.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "knowledge-base.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "knowledge-base.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "knowledge-base.fullname" . }}
5+
labels:
6+
{{- include "knowledge-base.labels" . | nindent 4 }}
7+
data:
8+
application.yml: |-
9+
sophora:
10+
client:
11+
server-connection:
12+
urls:
13+
{{- range .Values.api.sophora.connection.urls }}
14+
- {{ . | quote }}
15+
{{- end }}
16+
tool-info:
17+
name: "knowledge-base-backend"
18+
server:
19+
port: 8181
20+
21+
spring:
22+
groovy:
23+
template:
24+
check-template-location: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: "{{ include "knowledge-base.fullname" . }}-api"
5+
labels:
6+
{{- include "knowledge-base.labels" . | nindent 4 }}
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
{{- include "knowledge-base.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
annotations:
15+
"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"
16+
checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }}
17+
{{- with .Values.podAnnotations }}
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "knowledge-base.selectorLabels" . | nindent 8 }}
22+
spec:
23+
{{- with .Values.imagePullSecrets }}
24+
imagePullSecrets:
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
restartPolicy: Always
28+
containers:
29+
- name: "{{ .Chart.Name }}-api"
30+
image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag | default .Chart.AppVersion }}"
31+
imagePullPolicy: {{ .Values.api.image.pullPolicy }}
32+
volumeMounts:
33+
- name: config
34+
mountPath: "/workspace/application.yml"
35+
subPath: "application.yml"
36+
env:
37+
- name: sophora.client.server-connection.username
38+
valueFrom:
39+
secretKeyRef:
40+
key: {{ .Values.api.sophora.authentication.secret.usernameKey }}
41+
name: {{ required "A valid secret name must be provided in .Values.api.sophora.authentication.secret.name" .Values.api.sophora.authentication.secret.name | quote }}
42+
- name: sophora.client.server-connection.password
43+
valueFrom:
44+
secretKeyRef:
45+
key: {{ .Values.api.sophora.authentication.secret.passwordKey }}
46+
name: {{ required "A valid secret name must be provided in .Values.api.sophora.authentication.secret.name" .Values.api.sophora.authentication.secret.name | quote }}
47+
ports:
48+
- name: http
49+
containerPort: 8181
50+
protocol: TCP
51+
livenessProbe:
52+
httpGet:
53+
path: /
54+
port: http
55+
readinessProbe:
56+
httpGet:
57+
path: /
58+
port: http
59+
resources:
60+
{{- toYaml .Values.api.container.resources | nindent 12 }}
61+
volumes:
62+
- name: config
63+
configMap:
64+
name: {{ include "knowledge-base.fullname" . }}
65+
{{- with .Values.nodeSelector }}
66+
nodeSelector:
67+
{{- toYaml . | nindent 8 }}
68+
{{- end }}
69+
{{- with .Values.affinity }}
70+
affinity:
71+
{{- toYaml . | nindent 8 }}
72+
{{- end }}
73+
{{- with .Values.tolerations }}
74+
tolerations:
75+
{{- toYaml . | nindent 8 }}
76+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: "{{ include "knowledge-base.fullname" . }}-frontend"
5+
labels:
6+
{{- include "knowledge-base.labels" . | nindent 4 }}
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
{{- include "knowledge-base.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
annotations:
15+
"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"
16+
{{- with .Values.podAnnotations }}
17+
{{- toYaml . | nindent 8 }}
18+
{{- end }}
19+
labels:
20+
{{- include "knowledge-base.selectorLabels" . | nindent 8 }}
21+
spec:
22+
{{- with .Values.imagePullSecrets }}
23+
imagePullSecrets:
24+
{{- toYaml . | nindent 8 }}
25+
{{- end }}
26+
restartPolicy: Always
27+
containers:
28+
- name: "{{ .Chart.Name }}-frontend"
29+
image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag | default .Chart.AppVersion }}"
30+
imagePullPolicy: {{ .Values.frontend.image.pullPolicy }}
31+
env:
32+
- name: API_ADDRESS
33+
value: {{ .Values.frontend.apiBaseAddress }}
34+
ports:
35+
- name: http
36+
containerPort: 80
37+
protocol: TCP
38+
livenessProbe:
39+
httpGet:
40+
path: /
41+
port: http
42+
readinessProbe:
43+
httpGet:
44+
path: /
45+
port: http
46+
resources:
47+
{{- toYaml .Values.frontend.container.resources | nindent 12 }}
48+
volumes:
49+
- name: config
50+
configMap:
51+
name: {{ include "knowledge-base.fullname" . }}
52+
{{- with .Values.nodeSelector }}
53+
nodeSelector:
54+
{{- toYaml . | nindent 8 }}
55+
{{- end }}
56+
{{- with .Values.affinity }}
57+
affinity:
58+
{{- toYaml . | nindent 8 }}
59+
{{- end }}
60+
{{- with .Values.tolerations }}
61+
tolerations:
62+
{{- toYaml . | nindent 8 }}
63+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{- if .Values.ingress.enabled -}}
2+
{{- $fullName := include "knowledge-base.fullname" . -}}
3+
{{- $svcPort := .Values.service.port -}}
4+
apiVersion: networking.k8s.io/v1
5+
kind: Ingress
6+
metadata:
7+
name: {{ $fullName }}
8+
labels:
9+
{{- include "knowledge-base.labels" . | nindent 4 }}
10+
{{- with .Values.ingress.annotations }}
11+
annotations:
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
spec:
15+
{{- if .Values.ingress.ingressClassName }}
16+
ingressClassName: {{ .Values.ingress.ingressClassName }}
17+
{{- end -}}
18+
{{- if .Values.ingress.tls }}
19+
tls:
20+
{{- range .Values.ingress.tls }}
21+
- hosts:
22+
{{- range .hosts }}
23+
- {{ . | quote }}
24+
{{- end }}
25+
secretName: {{ .secretName }}
26+
{{- end }}
27+
{{- end }}
28+
rules:
29+
{{- range .Values.ingress.hosts }}
30+
- host: {{ .host | quote }}
31+
http:
32+
paths:
33+
- path: /
34+
pathType: Prefix
35+
backend:
36+
service:
37+
name: {{ $fullName }}
38+
port:
39+
number: {{ $svcPort }}
40+
{{- end }}
41+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "knowledge-base.fullname" . }}
5+
labels:
6+
{{- include "knowledge-base.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.service.port }}
11+
targetPort: http
12+
protocol: TCP
13+
name: http
14+
selector:
15+
{{- include "knowledge-base.selectorLabels" . | nindent 4 }}
+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
frontend:
2+
image:
3+
repository: docker.subshell.com/labday/knowledge-base/kb-frontend
4+
pullPolicy: Always
5+
tag: "1.0.0"
6+
container:
7+
resources:
8+
requests:
9+
cpu: 999m
10+
memory: 123Mi
11+
limits:
12+
cpu: 888m
13+
memory: 4321Mi
14+
apiBaseAddress: "test-api.address"
15+
16+
api:
17+
image:
18+
repository: docker.subshell.com/labday/knowledge-base/kb-api
19+
pullPolicy: Always
20+
tag: "1.0.0"
21+
container:
22+
resources:
23+
requests:
24+
cpu: 222m
25+
memory: 42Mi
26+
limits:
27+
cpu: 333m
28+
memory: 1337Mi
29+
sophora:
30+
connection:
31+
urls:
32+
- "http://sophora-server1"
33+
- "http://sophora-server2"
34+
authentication:
35+
secret:
36+
name: "knowledge-base-sophora-credentials"
37+
usernameKey: "sophora-user"
38+
passwordKey: "sophora-password"
39+
40+
imagePullSecrets: []
41+
nameOverride: "testNameOverride"
42+
fullnameOverride: "fullTestNameOverride"
43+
44+
podAnnotations:
45+
my/test/annotation: "foo"
46+
my/other/annotation: "bar"
47+
48+
service:
49+
type: ClusterIP
50+
port: 80
51+
52+
ingress:
53+
enabled: true
54+
annotations:
55+
kubernetes.io/ingress.class: nginx
56+
# kubernetes.io/tls-acme: "true"
57+
hosts:
58+
- host: frontend.knowledge-base.test
59+
tls: []
60+
# - secretName: chart-example-tls
61+
# hosts:
62+
# - chart-example.local
63+
64+
nodeSelector: {}
65+
66+
tolerations: []
67+
68+
affinity: {}

0 commit comments

Comments
 (0)