Skip to content

Commit d31d67b

Browse files
committed
add pvc for image store
1 parent 96f8715 commit d31d67b

15 files changed

Lines changed: 534 additions & 81 deletions

charts/codimd/Chart.yaml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
apiVersion: v1
22
name: codimd
33
description: A CodiMD Helm chart for Kubernetes
4+
icon: https://hackmd.io/favicon.png
5+
keywords:
6+
- codimd
7+
- markdown
8+
- collaboration
9+
maintainers:
10+
- name: HackMD Inc.
11+
email: support@hackmd.io
12+
- name: Raccoon Li
13+
email: raccoon@hackmd.io
14+
15+
sources:
16+
- https://github.com/hackmdio/codimd
17+
- https://github.com/hackmdio/codimd-helm
18+
19+
kubeVersion: ">=1.14.0-0"
420

521
# This is the chart version. This version number should be incremented each time you make changes
622
# to the chart and its templates, including the app version.
@@ -9,13 +25,3 @@ version: 0.1.0
925
# This is the version number of the application being deployed. This version number should be
1026
# incremented each time you make changes to the application.
1127
appVersion: 2.0.0
12-
13-
dependencies:
14-
- name: postgresql
15-
version: 8.6.10
16-
condition: postgresql.enabled, global.postgresql.enabled
17-
repository: https://charts.bitnami.com/bitnami
18-
- name: mariadb
19-
version: 7.3.16
20-
condition: mariadb.enabled, global.mariadb.enabled
21-
repository: https://charts.bitnami.com/bitnami

charts/codimd/README.md

Lines changed: 216 additions & 0 deletions
Large diffs are not rendered by default.

charts/codimd/requirements.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
dependencies:
22
- name: postgresql
33
repository: https://charts.bitnami.com/bitnami
4-
version: 8.6.10
4+
version: ~8.6.10
55
- name: mariadb
66
repository: https://charts.bitnami.com/bitnami
7-
version: 7.3.16
8-
digest: sha256:2888f71590a564fb34afdacbee86a5c71a3a74107cb61d3328fdaaf15c545c45
9-
generated: "2020-03-31T10:20:46.491342+08:00"
7+
version: ~7.3.16
8+
digest: sha256:fe33265de0d9cfca53db9536d7aa5f38b2e391e2c240b4039829484b81b741a5
9+
generated: "2020-04-05T00:57:10.506914+08:00"

charts/codimd/requirements.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dependencies:
2+
- name: postgresql
3+
version: ~8.6.10
4+
condition: postgresql.enabled
5+
repository: https://charts.bitnami.com/bitnami
6+
- name: mariadb
7+
version: ~7.3.16
8+
condition: mariadb.enabled
9+
repository: https://charts.bitnami.com/bitnami

charts/codimd/requirements.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

charts/codimd/templates/NOTES.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Thank you for installing {{ .Chart.Name }}
2+
3+
Your release is named {{ .Release.Name }}.
4+
5+
Browse https://hackmd.io/c/codimd-documentation to get more information about CodiMD.
6+
7+
{{ if contains "changeit" .Values.codimd.security.sessionSecret }}
8+
For the security reason, please consider change codimd.security.sessionSecret to random secret.
9+
{{ end }}
10+
===========================
11+
12+
{{ if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "codimd.fullname" . }} '
15+
{{ else if .Values.ingress.enabled }}
16+
{{ if .Values.ingress.tlsSecret }}
17+
Your CodiMD is located in: http://{{ .Values.ingress.hostname }}/
18+
{{ else }}
19+
Your CodiMD is located in: https://{{ .Values.ingress.hostname }}/
20+
{{ end }}
21+
{{ end }}

charts/codimd/templates/_helpers.tpl

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
2222
{{- end -}}
2323
{{- end -}}
2424

25+
{{- define "codimd.shortName" -}}
26+
{{- $name := include "codimd.fullname" . }}
27+
{{- printf "%s" $name | trunc 50 | trimSuffix "-" -}}
28+
{{- end -}}
29+
2530
{{/*
2631
Create chart name and version as used by the chart label.
2732
*/}}
@@ -90,4 +95,50 @@ Embedded MariaDB service name
9095
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
9196
{{- end -}}
9297
{{- end -}}
93-
{{- end -}}
98+
{{- end -}}
99+
100+
{{/*
101+
Return the appropriate apiVersion for deployment.
102+
*/}}
103+
{{- define "codimd.deployment.apiVersion" -}}
104+
{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}}
105+
{{- print "extensions/v1beta1" -}}
106+
{{- else -}}
107+
{{- print "apps/v1" -}}
108+
{{- end -}}
109+
{{- end -}}
110+
111+
{{/*
112+
Return the proper Storage Class for the master
113+
*/}}
114+
{{- define "codimd.storageClass" -}}
115+
{{/*
116+
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
117+
but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic.
118+
*/}}
119+
{{- if .Values.global -}}
120+
{{- if .Values.global.storageClass -}}
121+
{{- if (eq "-" .Values.global.storageClass) -}}
122+
{{- printf "storageClassName: \"\"" -}}
123+
{{- else }}
124+
{{- printf "storageClassName: %s" .Values.global.storageClass -}}
125+
{{- end -}}
126+
{{- else -}}
127+
{{- if .Values.codimd.imageStorePersistentVolume.storageClass -}}
128+
{{- if (eq "-" .Values.codimd.imageStorePersistentVolume.storageClass) -}}
129+
{{- printf "storageClassName: \"\"" -}}
130+
{{- else }}
131+
{{- printf "storageClassName: %s" .Values.codimd.imageStorePersistentVolume.storageClass -}}
132+
{{- end -}}
133+
{{- end -}}
134+
{{- end -}}
135+
{{- else -}}
136+
{{- if .Values.codimd.imageStorePersistentVolume.storageClass -}}
137+
{{- if (eq "-" .Values.codimd.imageStorePersistentVolume.storageClass) -}}
138+
{{- printf "storageClassName: \"\"" -}}
139+
{{- else }}
140+
{{- printf "storageClassName: %s" .Values.codimd.imageStorePersistentVolume.storageClass -}}
141+
{{- end -}}
142+
{{- end -}}
143+
{{- end -}}
144+
{{- end -}}

charts/codimd/templates/auth-secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: Secret
33
metadata:
4-
name: {{ template "codimd.fullname" . }}-auth-env
4+
name: {{ template "codimd.shortName" . }}-auth-env
55
stringData:
66
CMD_EMAIL: {{ .Values.codimd.authentication.local.enabled | toString | quote }}
77
CMD_ALLOW_EMAIL_REGISTER: {{ .Values.codimd.authentication.local.allowRegister | toString | quote }}

charts/codimd/templates/db-secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: Secret
33
metadata:
4-
name: {{ template "codimd.fullname" . }}-database-secret
4+
name: {{ template "codimd.shortName" . }}-db-secret
55
stringData:
66
{{ if .Values.postgresql.enabled }}
77
connection: "postgres://{{ .Values.postgresql.postgresqlUsername }}:{{ .Values.postgresql.postgresqlPassword }}@{{ template "codimd.postgresql-svc" . }}/{{ .Values.postgresql.postgresqlDatabase }}"

charts/codimd/templates/deployment.yaml

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: apps/v1
1+
apiVersion: {{ template "codimd.deployment.apiVersion" . }}
22
kind: Deployment
33
metadata:
44
name: {{ template "codimd.fullname" . }}
@@ -20,33 +20,109 @@ spec:
2020
annotations:
2121
{{ toYaml .Values.codimd.podAnnotations | nindent 8 }}
2222
spec:
23+
{{ if .Values.codimd.securityContext }}
24+
securityContext:
25+
{{ toYaml .Values.codimd.securityContext | nindent 8 }}
26+
{{ end }}
27+
{{ if .Values.codimd.affinity }}
2328
affinity:
2429
{{ toYaml .Values.codimd.affinity | nindent 8 }}
30+
{{ end }}
31+
{{ if .Values.codimd.tolerations }}
2532
tolerations:
2633
{{ toYaml .Values.codimd.tolerations | nindent 8 }}
34+
{{ end }}
35+
{{ if .Values.codimd.nodeSelector }}
2736
nodeSelector:
2837
{{ toYaml .Values.codimd.nodeSelector | nindent 8 }}
29-
38+
{{ end }}
3039
{{ if .Values.image.pullSecrets }}
3140
imagePullSecrets:
32-
{{ .Values.image.pullSecrets | nindent 8 }}
41+
{{ toYaml .Values.image.pullSecrets | nindent 8 }}
3342
{{end }}
3443
containers:
3544
- name: codimd
3645
image: {{ template "codimd.image" . }}
37-
imagePullPolicy: {{ .Values.image.pullPolicy }}
46+
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
3847
env:
3948
- name: CMD_USE_CDN
4049
value: {{ .Values.codimd.security.useCDN | quote }}
4150
- name: CMD_DB_URL
4251
valueFrom:
4352
secretKeyRef:
44-
name: {{ template "codimd.fullname" . }}-database-secret
53+
name: {{ template "codimd.shortName" . }}-db-secret
4554
key: connection
55+
- name: CMD_SESSION_LIFE
56+
value: {{ .Values.codimd.security.sessionLife | quote }}
57+
- name: CMD_HSTS_ENABLE
58+
value: {{ .Values.codimd.security.hstsEnabled | quote }}
59+
- name: CMD_HSTS_MAX_AGE
60+
value: {{ .Values.codimd.security.hstsMaxAge | quote }}
61+
- name: CMD_HSTS_INCLUDE_SUBDOMAINS
62+
value: {{ .Values.codimd.security.hstsIncludeSubdomain | quote }}
63+
- name: CMD_HSTS_PRELOAD
64+
value: {{ .Values.codimd.security.hstsPreload | quote }}
65+
- name: CMD_CSP_ENABLE
66+
value: {{ .Values.codimd.security.cspEnabled | quote }}
67+
{{ if .Values.codimd.security.cspReportUri }}
68+
- name: CMD_CSP_REPORTURI
69+
value: {{ .Values.codimd.security.cspReportUri | quote }}
70+
{{ end }}
71+
{{ if .Values.codimd.security.allowOrigin }}
72+
- name: CMD_ALLOW_ORIGIN
73+
value: {{ .Values.codimd.security.allowOrigin | quote }}
74+
{{ end }}
75+
- name: CMD_ALLOW_GRAVATAR
76+
value: {{ .Values.codimd.security.allowGravatar | quote }}
77+
- name: CMD_RESPONSE_MAX_LAG
78+
value: {{ .Values.codimd.responseMaxLag | quote }}
79+
- name: CMD_ALLOW_FREEURL
80+
value: {{ .Values.codimd.noteCreation.freeUrlEnabled | quote }}
81+
- name: CMD_FORBIDDEN_NOTE_IDS
82+
value: {{ .Values.codimd.noteCreation.freeUrlForbiddenNoteIds | quote }}
83+
- name: CMD_DEFAULT_PERMISSION
84+
value: {{ .Values.codimd.noteCreation.defaultPermission | quote }}
85+
- name: CMD_ALLOW_ANONYMOUS_EDITS
86+
value: {{ .Values.codimd.notePermission.allowAnonymousEdit | quote}}
87+
- name: CMD_ALLOW_ANONYMOUS_VIEWS
88+
value: {{ .Values.codimd.notePermission.allowAnonymousView | quote}}
89+
- name: CMD_ALLOW_PDF_EXPORT
90+
value: {{ .Values.codimd.allowPDFExport | quote }}
91+
{{ if .Values.codimd.markdown.plantUMLServer }}
92+
- name: CMD_PLANTUML_SERVER
93+
value: {{ .Values.codimd.markdown.plantUMLServer }}
94+
{{ end }}
95+
- name: CMD_DEFAULT_USE_HARD_BREAK
96+
value: {{ .Values.codimd.markdown.useHardBreak | quote }}
97+
- name: CMD_LINKIFY_HEADER_STYLE
98+
value: {{ .Values.codimd.markdown.linkifyHeaderStyle | quote }}
99+
- name: CMD_AUTO_VERSION_CHECK
100+
value: {{ .Values.codimd.versionCheck | quote }}
101+
{{ if .Values.codimd.extraEnvironmentVariables }}
102+
{{ range $key, $val := .Values.codimd.extraEnvironmentVariables }}
103+
- name: {{ $key | quote }}
104+
value: {{ $val | quote }}
105+
{{ end }}
106+
{{ end }}
46107
envFrom:
47108
- secretRef:
48-
name: {{ template "codimd.fullname" . }}-auth-env
109+
name: {{ template "codimd.shortName" . }}-auth-env
110+
{{ if .Values.codimd.security.sessionSecret }}
111+
- secretRef:
112+
name: {{ template "codimd.shortName" . }}-session
113+
{{ end }}
49114
ports:
50115
- name: http
51116
containerPort: 3000
117+
{{ if .Values.codimd.imageStorePersistentVolume.enabled }}
118+
volumeMounts:
119+
- mountPath: /home/hackmd/app/public/uploads
120+
name: image-store
121+
{{ end }}
52122
restartPolicy: Always
123+
{{ if .Values.codimd.imageStorePersistentVolume.enabled }}
124+
volumes:
125+
- name: image-store
126+
persistentVolumeClaim:
127+
claimName: {{ template "codimd.fullname" . }}
128+
{{ end }}

0 commit comments

Comments
 (0)