diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index cb1d06ca8..389da29e9 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -325,3 +325,8 @@ objectStorage: # Seriously. Do NOT fill out the above settings if you're self-hosting. # They're much better off being set from the control panel. {{- end }} + + +{{- define "iceshrimp.datapvc" -}} +{{- default (printf "%s-data-pvc" (include "iceshrimp.fullname" .) ) .Values.iceshrimp.localStorage.claimName }} +{{- end }} diff --git a/chart/templates/deployment.yaml b/chart/templates/deployment.yaml index 05d381834..9485ae7c3 100644 --- a/chart/templates/deployment.yaml +++ b/chart/templates/deployment.yaml @@ -29,9 +29,16 @@ spec: securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} volumes: - - name: config-volume - secret: - secretName: {{ template "iceshrimp.fullname" . }}-config + - name: config-volume + secret: + secretName: {{ template "iceshrimp.fullname" . }}-config + - name: data-volume + {{- if .Values.iceshrimp.localStorage.enabled }} + persistentVolumeClaim: + claimName: {{ include "iceshrimp.datapvc" . }} + {{- else }} + emptyDir: + {{- end }} containers: - name: {{ .Chart.Name }} securityContext: @@ -41,13 +48,15 @@ spec: command: - yarn - run - - migrateandstart + - start env: - name: "NODE_ENV" value: "production" volumeMounts: - name: config-volume mountPath: /iceshrimp/.config + - name: data-volume + mountPath: /iceshrimp/files ports: - name: http containerPort: 3000 diff --git a/chart/templates/job-db-migrate.yaml b/chart/templates/job-db-migrate.yaml index 6451e24a7..ac980a2d9 100644 --- a/chart/templates/job-db-migrate.yaml +++ b/chart/templates/job-db-migrate.yaml @@ -38,7 +38,7 @@ spec: command: - yarn - run - - migrateandstart + - migrate env: - name: "NODE_ENV" value: "production" diff --git a/chart/templates/pvc.yaml b/chart/templates/pvc.yaml new file mode 100644 index 000000000..0e44164e7 --- /dev/null +++ b/chart/templates/pvc.yaml @@ -0,0 +1,23 @@ +{{- if .Values.iceshrimp.localStorage.enabled }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ include "iceshrimp.datapvc" . }} + labels: + {{- include "iceshrimp.labels" . | nindent 4 }} + annotations: + {{- .Values.iceshrimp.localStorage.annotations | toYaml | nindent 4}} +spec: + accessModes: + {{- .Values.iceshrimp.localStorage.accessModes | toYaml | nindent 4 }} + volumeMode: Filesystem + {{- if .Values.iceshrimp.localStorage.class }} + storageClassName: {{ .Values.iceshrimp.localStorage.class }} + {{- end }} + {{- with .Values.iceshrimp.localStorage.volumeName }} + volumeName: {{ . }} + {{- end }} + resources: + requests: + storage: {{ .Values.iceshrimp.localStorage.size }} +{{- end }} diff --git a/chart/values.yaml b/chart/values.yaml index 355624ab1..d5c6a36f5 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -42,7 +42,18 @@ iceshrimp: prefix: files endpoint: "" # e.g. "nyc3.digitaloceanspaces.com:443" region: "" # e.g. "nyc3" - + + localStorage: + enabled: true + claimName: null + accessModes: + - ReadWriteOnce + labels: {} + class: + annotations: + helm.sh/resource-policy: keep + size: 10Gi + # -- If you want to allow iceshrimp to connect to private ips, enter the cidrs here. allowedPrivateNetworks: [] # - "10.0.0.0/8"