Skip to content

Commit e5dbc81

Browse files
committed
refactor: Use helm for traq
1 parent cd6da02 commit e5dbc81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+671
-464
lines changed

.common/traq/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

.common/traq/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: traq
3+
description: A Helm chart for traQ - a real-time communication tool
4+
type: application
5+
version: "0.1.0"
6+
appVersion: "0.1.0"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- with $.Values.backend }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ $.Release.Name }}
6+
namespace: {{ $.Release.Namespace }}
7+
annotations:
8+
{{- .service.annotations | toYaml | nindent 4 }}
9+
10+
spec:
11+
type: ClusterIP
12+
selector:
13+
app: {{ $.Release.Name }}
14+
ports:
15+
- name: http
16+
port: 3000
17+
targetPort: http
18+
19+
{{- end }}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{{- with $.Values.backend }}
2+
kind: Deployment
3+
apiVersion: apps/v1
4+
metadata:
5+
name: {{ $.Release.Name }}
6+
namespace: {{ $.Release.Namespace }}
7+
8+
spec:
9+
revisionHistoryLimit: 0
10+
replicas: {{ .replicas }}
11+
strategy:
12+
type: Recreate
13+
14+
selector:
15+
matchLabels:
16+
app: {{ $.Release.Name }}-backend
17+
template:
18+
metadata:
19+
labels:
20+
app: {{ $.Release.Name }}-backend
21+
spec:
22+
enableServiceLinks: false
23+
{{- if .nodeSelector }}
24+
nodeSelector:
25+
{{- .nodeSelector | toYaml | nindent 8 }}
26+
{{- end }}
27+
volumes:
28+
- name: config
29+
configMap:
30+
name: {{ .configMap.existingName }}
31+
- name: keys
32+
secret:
33+
secretName: {{ .keysSecret.existingName }}
34+
- name: cache
35+
emptyDir: {}
36+
37+
containers:
38+
- name: traq
39+
image: {{ .image }}
40+
imagePullPolicy: Always
41+
ports:
42+
- name: http
43+
containerPort: 3000
44+
env:
45+
# TODO: use "envFrom" for less configuration mess
46+
- name: TRAQ_MARIADB_PASSWORD
47+
valueFrom:
48+
secretKeyRef:
49+
name: {{ .secret.existingName }}
50+
key: mariadb_password
51+
- name: TRAQ_STORAGE_S3_ACCESSKEY
52+
valueFrom:
53+
secretKeyRef:
54+
name: {{ .secret.existingName }}
55+
key: storage_s3_access_key
56+
- name: TRAQ_STORAGE_S3_SECRETKEY
57+
valueFrom:
58+
secretKeyRef:
59+
name: {{ .secret.existingName }}
60+
key: storage_s3_secretKey
61+
- name: TRAQ_SKYWAY_SECRETKEY
62+
valueFrom:
63+
secretKeyRef:
64+
name: {{ .secret.existingName }}
65+
key: skyway_secretKey
66+
- name: TRAQ_ES_PASSWORD
67+
valueFrom:
68+
secretKeyRef:
69+
name: {{ .secret.existingName }}
70+
key: es_password
71+
- name: TRAQ_LIVEKIT_APIKEY
72+
valueFrom:
73+
secretKeyRef:
74+
name: {{ .secret.existingName }}
75+
key: livekit_apiKey
76+
- name: TRAQ_LIVEKIT_APISECRET
77+
valueFrom:
78+
secretKeyRef:
79+
name: {{ .secret.existingName }}
80+
key: livekit_apiSecret
81+
volumeMounts:
82+
- name: config
83+
mountPath: /app/config.yml
84+
subPath: config.yml
85+
- name: keys
86+
mountPath: /keys
87+
- name: cache
88+
mountPath: /storage
89+
{{- if .resources }}
90+
resources:
91+
{{- .resources | toYaml | nindent 12 }}
92+
{{- end }}
93+
94+
{{- end }}

.common/traq/templates/es/cm.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- with $.Values.es }}
2+
{{- if .enabled }}
3+
apiVersion: v1
4+
kind: ConfigMap
5+
metadata:
6+
name: {{ $.Release.Name }}-es
7+
namespace: {{ $.Release.Namespace }}
8+
9+
data:
10+
es_jvm.options: {{ .jvmOptions | quote }}
11+
12+
{{- end }}
13+
{{- end }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- with $.Values.es }}
2+
{{- if .enabled }}
3+
apiVersion: v1
4+
kind: Service
5+
metadata:
6+
name: {{ $.Release.Name }}-es
7+
namespace: {{ $.Release.Namespace }}
8+
annotations:
9+
{{- .service.annotations | toYaml | nindent 4 }}
10+
11+
spec:
12+
type: ClusterIP
13+
selector:
14+
app: {{ $.Release.Name }}-es
15+
ports:
16+
- name: es
17+
port: 9200
18+
targetPort: es
19+
- name: exporter
20+
port: 9114
21+
targetPort: exporter
22+
23+
{{- end }}
24+
{{- end }}

.common/traq/templates/es/sts.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{{- with $.Values.es }}
2+
{{- if .enabled }}
3+
kind: StatefulSet
4+
apiVersion: apps/v1
5+
metadata:
6+
name: {{ $.Release.Name }}-es
7+
namespace: {{ $.Release.Namespace }}
8+
9+
spec:
10+
serviceName: {{ $.Release.Name }}-es
11+
podManagementPolicy: Parallel
12+
revisionHistoryLimit: 0
13+
replicas: {{ .replicas }}
14+
15+
selector:
16+
matchLabels:
17+
app: {{ $.Release.Name }}-es
18+
template:
19+
metadata:
20+
labels:
21+
app: {{ $.Release.Name }}-es
22+
spec:
23+
enableServiceLinks: false
24+
{{- if .nodeSelector }}
25+
nodeSelector:
26+
{{- .nodeSelector | toYaml | nindent 8 }}
27+
{{- end }}
28+
volumes:
29+
- name: config
30+
configMap:
31+
name: {{ $.Release.Name }}-es
32+
- name: data
33+
hostPath:
34+
{{- .dataVolume.hostPath | toYaml | nindent 12 }}
35+
36+
containers:
37+
- name: traq-es
38+
image: {{ .image }}
39+
ports:
40+
- name: http
41+
containerPort: 9200
42+
env:
43+
- name: discovery.type
44+
value: single-node
45+
# TODO: use "envFrom" for less configuration mess
46+
- name: ELASTIC_PASSWORD
47+
valueFrom:
48+
secretKeyRef:
49+
name: {{ .secret.existingName }}
50+
key: es-password
51+
volumeMounts:
52+
- name: config
53+
mountPath: /usr/share/elasticsearch/config/jvm.options.d/es_jvm.options
54+
subPath: es_jvm.options
55+
- name: data
56+
mountPath: /usr/share/elasticsearch/data
57+
{{- if .resources }}
58+
resources:
59+
{{- .resources | toYaml | nindent 12 }}
60+
{{- end }}
61+
62+
{{- if .exporter.enabled }}
63+
- name: exporter
64+
image: {{ .exporter.image }}
65+
args:
66+
- --es.uri=http://elastic:$(ELASTIC_PASSWORD)@localhost:9200
67+
- --es.all
68+
- --es.indices
69+
- --es.shards
70+
env:
71+
- name: ELASTIC_PASSWORD
72+
valueFrom:
73+
secretKeyRef:
74+
name: {{ .secret.existingName }}
75+
key: es-password
76+
ports:
77+
- name: exporter
78+
containerPort: 9114
79+
{{- if .exporter.resources }}
80+
resources:
81+
{{- .exporter.resources | toYaml | nindent 12 }}
82+
{{- end }}
83+
{{- end }}
84+
85+
{{- end }}
86+
{{- end }}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{{- with $.Values.frontend }}
2+
kind: Deployment
3+
apiVersion: apps/v1
4+
metadata:
5+
name: {{ $.Release.Name }}-frontend
6+
namespace: {{ $.Release.Namespace }}
7+
8+
spec:
9+
replicas: {{ .replicas }}
10+
revisionHistoryLimit: 0
11+
selector:
12+
matchLabels:
13+
app: {{ $.Release.Name }}-frontend
14+
template:
15+
metadata:
16+
labels:
17+
app: {{ $.Release.Name }}-frontend
18+
spec:
19+
enableServiceLinks: false
20+
{{- if .nodeSelector }}
21+
nodeSelector:
22+
{{- .nodeSelector | toYaml | nindent 8 }}
23+
{{- end }}
24+
{{- if.overrideConfig }}
25+
volumes:
26+
- name: config
27+
configMap:
28+
name: frontend-config
29+
{{- end }}
30+
31+
containers:
32+
- name: traq-frontend
33+
image: {{ .image }}
34+
ports:
35+
- name: http
36+
containerPort: 80
37+
{{- if .extraEnvs }}
38+
env:
39+
# TODO: use "envFrom" for less configuration mess
40+
{{- .extraEnvs | toYaml | nindent 12 }}
41+
{{- end }}
42+
{{- if .overrideConfig }}
43+
volumeMounts:
44+
- mountPath: /app/override/config.js
45+
name: config
46+
subPath: config.js
47+
{{- end }}
48+
{{- if .resources }}
49+
resources:
50+
{{- .resources | toYaml | nindent 12 }}
51+
{{- end }}
52+
53+
{{- end }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{- with $.Values.frontend }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ $.Release.Name }}-frontend
6+
namespace: {{ $.Release.Namespace }}
7+
8+
spec:
9+
type: ClusterIP
10+
selector:
11+
app: {{ $.Release.Name }}-frontend
12+
ports:
13+
- name: http
14+
port: 80
15+
targetPort: http
16+
17+
{{- end }}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{{- with .Values.ingressRoute }}
2+
{{- if .enabled }}
3+
apiVersion: traefik.io/v1alpha1
4+
kind: IngressRoute
5+
metadata:
6+
name: {{ $.Release.Name }}
7+
namespace: {{ $.Release.Namespace }}
8+
9+
spec:
10+
entryPoints:
11+
{{- if .tls }}
12+
- websecure
13+
{{- else }}
14+
- web
15+
{{- end }}
16+
{{- if .tls }}
17+
tls:
18+
secretName: {{ .tls }}
19+
{{- end }}
20+
routes:
21+
- kind: Rule
22+
match: Host(`{{ $.Values.host }}`) && (PathPrefix(`/api`) || PathPrefix(`/.well-known`))
23+
services:
24+
- namespace: {{ $.Release.Namespace }}
25+
kind: Service
26+
name: {{ $.Release.Name }}
27+
port: http
28+
scheme: http
29+
30+
- kind: Rule
31+
match: Host(`{{ $.Values.host }}`) && PathPrefix(`/widget`)
32+
middlewares:
33+
- name: {{ $.Release.Name }}-widget-strip
34+
services:
35+
- namespace: {{ $.Release.Namespace }}
36+
kind: Service
37+
name: {{ $.Release.Name }}-widget
38+
port: http
39+
scheme: http
40+
41+
- kind: Rule
42+
match: Host(`{{ $.Values.host }}`)
43+
services:
44+
- namespace: {{ $.Release.Namespace }}
45+
kind: Service
46+
name: {{ $.Release.Name }}-frontend
47+
port: http
48+
scheme: http
49+
50+
{{- end }}
51+
{{- end }}

0 commit comments

Comments
 (0)