Skip to content

Commit 895f991

Browse files
committed
feat: kubernetes deployment
1 parent d643d62 commit 895f991

File tree

5 files changed

+269
-0
lines changed

5 files changed

+269
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
spring.jpa.show-sql=false

helm/withOpenAI/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v1
2+
appVersion: "1.0"
3+
description: AIDocumentLibraryChat Config
4+
name: aidocumentlibrarychat
5+
version: 0.1.0
6+
icon: "https://angular.io/assets/images/logos/angular/angular.png"
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "helm-chart.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "helm-chart.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "helm-chart.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
Create envApp values
35+
*/}}
36+
{{- define "helpers.list-envApp-variables"}}
37+
{{- $secretName := .Values.secret.nameApp -}}
38+
{{- range $key, $val := .Values.envApp.secret }}
39+
- name: {{ $key }}
40+
valueFrom:
41+
secretKeyRef:
42+
name: {{ $secretName }}
43+
key: {{ $key }}
44+
{{- end}}
45+
{{- range $key, $val := .Values.envApp.normal }}
46+
- name: {{ $key }}
47+
value: {{ $val | quote }}
48+
{{- end}}
49+
{{- end }}
50+
51+
Create envDb values
52+
*/}}
53+
{{- define "helpers.list-envDb-variables"}}
54+
{{- $secretName := .Values.secret.nameDb -}}
55+
{{- range $key, $val := .Values.envDb.secret }}
56+
- name: {{ $key }}
57+
valueFrom:
58+
secretKeyRef:
59+
name: {{ $secretName }}
60+
key: {{ $key }}
61+
{{- end}}
62+
{{- range $key, $val := .Values.envDb.normal }}
63+
- name: {{ $key }}
64+
value: {{ $val | quote }}
65+
{{- end}}
66+
{{- end }}
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: {{ .Values.secret.nameApp }}
5+
type: Opaque
6+
data:
7+
{{- range $key, $val := .Values.envApp.secret }}
8+
{{ $key }}: {{ $val | b64enc }}
9+
{{- end}}
10+
---
11+
apiVersion: v1
12+
kind: Secret
13+
metadata:
14+
name: {{ .Values.secret.nameDb }}
15+
type: Opaque
16+
data:
17+
{{- range $key, $val := .Values.envDb.secret }}
18+
{{ $key }}: {{ $val | b64enc }}
19+
{{- end}}
20+
---
21+
kind: PersistentVolume
22+
apiVersion: v1
23+
metadata:
24+
name: {{ .Values.persistentVolumeName }}
25+
labels:
26+
type: local
27+
spec:
28+
storageClassName: manual
29+
accessModes:
30+
- ReadWriteOnce
31+
capacity:
32+
storage: 1Gi
33+
hostPath:
34+
path: /data/postgreslc
35+
type: DirectoryOrCreate
36+
---
37+
apiVersion: v1
38+
kind: PersistentVolumeClaim
39+
metadata:
40+
name: {{ .Values.volumeClaimName }}
41+
labels:
42+
app: postgrespv
43+
spec:
44+
accessModes:
45+
- ReadWriteOnce
46+
# storageClassName: local-storage
47+
storageClassName: manual
48+
resources:
49+
requests:
50+
storage: 1Gi
51+
---
52+
apiVersion: apps/v1
53+
kind: Deployment
54+
metadata:
55+
name: {{ .Values.dbName }}
56+
labels:
57+
app: {{ .Values.dbName }}
58+
spec:
59+
replicas: 1
60+
selector:
61+
matchLabels:
62+
app: {{ .Values.dbName }}
63+
template:
64+
metadata:
65+
labels:
66+
app: {{ .Values.dbName }}
67+
spec:
68+
containers:
69+
- name: {{ .Values.dbName }}
70+
image: "{{ .Values.dbImageName }}:{{ .Values.dbImageVersion }}"
71+
resources:
72+
limits:
73+
memory: "2G"
74+
cpu: "1.5"
75+
requests:
76+
memory: "1G"
77+
cpu: "0.5"
78+
env:
79+
{{- include "helpers.list-envDb-variables" . | indent 10 }}
80+
ports:
81+
- containerPort: 5432
82+
volumeMounts:
83+
- name: hostvol
84+
mountPath: /var/lib/postgresql/data
85+
volumes:
86+
- name: hostvol
87+
persistentVolumeClaim:
88+
claimName: {{ .Values.volumeClaimName }}
89+
---
90+
apiVersion: v1
91+
kind: Service
92+
metadata:
93+
name: {{ .Values.dbServiceName }}
94+
labels:
95+
app: {{ .Values.dbServiceName }}
96+
spec:
97+
ports:
98+
- port: 5432
99+
protocol: TCP
100+
selector:
101+
app: {{ .Values.dbName }}
102+
---
103+
apiVersion: apps/v1
104+
kind: Deployment
105+
metadata:
106+
name: {{ .Values.webAppName }}
107+
labels:
108+
app: {{ .Values.webAppName }}
109+
spec:
110+
replicas: 1
111+
selector:
112+
matchLabels:
113+
app: {{ .Values.webAppName }}
114+
template:
115+
metadata:
116+
labels:
117+
app: {{ .Values.webAppName }}
118+
spec:
119+
containers:
120+
- name: {{ .Values.webAppName }}
121+
image: "{{ .Values.webImageName }}:{{ .Values.webImageVersion }}"
122+
imagePullPolicy: Always
123+
resources:
124+
limits:
125+
memory: "1G"
126+
cpu: "0.5"
127+
requests:
128+
memory: "768M"
129+
cpu: "0.5"
130+
env:
131+
{{- include "helpers.list-envApp-variables" . | indent 10 }}
132+
ports:
133+
- containerPort: 8080
134+
livenessProbe:
135+
httpGet:
136+
path: "/actuator/health/livenessState"
137+
port: 8080
138+
initialDelaySeconds: 5
139+
periodSeconds: 5
140+
startupProbe:
141+
httpGet:
142+
path: "/actuator/health/readinessState"
143+
port: 8080
144+
failureThreshold: 60
145+
periodSeconds: 5
146+
---
147+
apiVersion: v1
148+
kind: Service
149+
metadata:
150+
name: {{ .Values.webServiceName }}
151+
labels:
152+
run: {{ .Values.webServiceName }}
153+
spec:
154+
type: NodePort
155+
ports:
156+
- port: 8080
157+
protocol: TCP
158+
selector:
159+
app: {{ .Values.webAppName }}

helm/withOpenAI/values.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
webAppName: aidocumentlibrarychatapp
2+
dbName: postgresserver
3+
webImageName: angular2guy/aidocumentlibrarychat
4+
webImageVersion: latest
5+
dbImageName: ankane/pgvector
6+
dbImageVersion: latest
7+
volumeClaimName: postgres-pv-claim
8+
persistentVolumeName: task-pv-volume
9+
webServiceName: aidocumentlibrarychatservice
10+
dbServiceName: postgresservice
11+
#for production use replace the jwtTokenSecrect value with a random alphanumeric string of the same length or longer
12+
jwtTokenSecrect: secret-key1234567890abcdefghijklmnopqrstuvpxyz
13+
14+
secret:
15+
nameApp: app-env-secret
16+
nameDb: db-env-secret
17+
18+
envDb:
19+
normal:
20+
POSTGRES_URL: "jdbc:postgresql://postgresservice:5432/aidoclibchat"
21+
secret:
22+
POSTGRES_USER: dbuser
23+
POSTGRES_PASSWORD: passwordtoreplace
24+
POSTGRES_DB: movies
25+
26+
envApp:
27+
normal:
28+
JPA_SHOW_SQL: true
29+
H2_CONSOLE: false
30+
SHUTDOWN_PHASE: 10s
31+
SPRING_PROFILES_ACTIVE: "prod"
32+
secret:
33+
JWTTOKEN_SECRET: secret-key1234567890abcdefghijklmnopqrstuvwxyz
34+
POSTGRES_USER: dbuser
35+
POSTGRES_PASSWORD: passwordtoreplace
36+
POSTGRES_URL: "jdbc:postgresql://postgresservice:5432/aidoclibchat"
37+
TINK_JSON_KEY: '{"primaryKeyId":1047384356,"key":[{"keyData":{"typeUrl":"type.googleapis.com/google.crypto.tink.AesSivKey","value":"EkBtsrB3Aomkmsiq16f9KJQXZX2Y2ZfK3bN1QBBQuxGpSb/5pqQPgqXc5D5FETW6rrBsCv7qIsPyzoEAS2rXPgLx","keyMaterialType":"SYMMETRIC"},"status":"ENABLED","keyId":1047384356,"outputPrefixType":"TINK"}]}'

0 commit comments

Comments
 (0)