Skip to content

Commit

Permalink
Merge pull request #4 from a01fe/master
Browse files Browse the repository at this point in the history
Add persistence and document server support
  • Loading branch information
sebagarayco authored Jul 24, 2022
2 parents b2a6030 + cab84a8 commit eabed17
Show file tree
Hide file tree
Showing 10 changed files with 259 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/filestash/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 0.2.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
13 changes: 12 additions & 1 deletion charts/filestash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

| Value | Description | Default |
| ----------------------------------------------- | -------------------------------------------------- | ---------------------------- |
| `replicaCount` | Number of pod replicas | 1 |
| `replicaCount` | Number of filestash pod replicas | 1 |
| `image.repository` | Docker image to use | docker.io/machines/filestash |
| `image.pullPolicy` | Pull policy to use | IfNotPresent |
| `image.tag` | Overrides image tag set in chart appVersion | "" |
Expand All @@ -19,6 +19,17 @@
| `autoscaling.maxReplicas` | Number of maximum replicas when using HPA | 4 |
| `autoscaling.targetCPUUtilizationPercentage` | %CPU Utilization when using HPA | 80 |
| `autoscaling.targetMemoryUtilizationPercentage` | %Memory Utilization when using HPA | 80 |
| `documentServer.enabled` | Whether to deploy deploy document server | false |
| `documentServer.nameOverride` | Name prefix for document server objects | document-server |
| `documentServer.image.repository` | Docker image to use | onlyoffice/documentserver |
| `documentServer.image.pullPolicy` | Pull policy to use | IfNotPresent |
| `documentServer.image.tag` | Overrides image tag set in chart appVersion | "" |
| `documentServer.replicaCount` | Number of document server pod replicas | 1 |
| `persistence.filestashState.enabled` | Create PVC to persist filestash configuration | false |
| `persistence.filestashState.accessMode` | Volume access mode | ReadWriteOnce |
| `persistence.filestashState.annotations` | PVC annotations | (none) |
| `persistence.filestashState.storageClass` | PVC storage cloas | (none) |
| `persistence.filestashState.storageSize` | PVC storage size | 100Mi |

## Usage

Expand Down
24 changes: 24 additions & 0 deletions charts/filestash/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ If release name contains chart name it will be used as a full name.
{{- end }}
{{- end }}

{{/*
Create a default fully qualified app name for the document server.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "filestash.documentServer.fullname" -}}
{{- if .Values.documentServer.fullnameOverride }}
{{- .Values.documentServer.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" ( include "filestash.fullname" . ) .Values.documentServer.nameOverride }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
Expand Down Expand Up @@ -50,6 +63,17 @@ app.kubernetes.io/name: {{ include "filestash.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Common component labels
*/}}
{{- define "filestash.componentLabels.webapp" -}}
app.kubernetes.io/component: webapp
{{- end }}

{{- define "filestash.componentLabels.documentServer" -}}
app.kubernetes.io/component: document-server
{{- end }}

{{/*
Create the name of the service account to use
*/}}
Expand Down
103 changes: 103 additions & 0 deletions charts/filestash/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ metadata:
name: {{ include "filestash.fullname" . }}
labels:
{{- include "filestash.labels" . | nindent 4 }}
{{- include "filestash.componentLabels.webapp" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "filestash.selectorLabels" . | nindent 6 }}
{{- include "filestash.componentLabels.webapp" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
Expand All @@ -19,6 +21,7 @@ spec:
{{- end }}
labels:
{{- include "filestash.selectorLabels" . | nindent 8 }}
{{- include "filestash.componentLabels.webapp" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand All @@ -33,6 +36,16 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if or .Values.env .Values.documentServer.enabled }}
env:
{{- with .Values.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.documentServer.enabled }}
- name: ONLYOFFICE_URL
value: "http://{{ include "filestash.documentServer.fullname" . }}"
{{- end }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
Expand All @@ -47,6 +60,95 @@ spec:
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- mountPath: /app/data/state
name: {{ template "filestash.fullname" . }}-state
securityContext:
fsGroup: 1000
runAsUser: 1000
runAsGroup: 1000
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: {{ template "filestash.fullname" . }}-state
{{- if .Values.persistence.filestashState.enabled }}
persistentVolumeClaim:
claimName: {{ template "filestash.fullname" . }}-state
{{- else }}
emptyDir: {}
{{- end }}
{{- if .Values.documentServer.enabled }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "filestash.documentServer.fullname" . }}
labels:
{{- include "filestash.labels" . | nindent 4 }}
{{- include "filestash.componentLabels.documentServer" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.documentServer.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "filestash.selectorLabels" . | nindent 6 }}
{{- include "filestash.componentLabels.documentServer" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "filestash.selectorLabels" . | nindent 8 }}
{{- include "filestash.componentLabels.documentServer" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "filestash.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Values.documentServer.nameOverride }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.documentServer.image.repository }}:{{ .Values.documentServer.image.tag | default "latest" }}"
imagePullPolicy: {{ .Values.documentServer.image.pullPolicy }}
{{- if .Values.documentServer.env }}
env:
{{- with .Values.documentServer.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 180
readinessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 180
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand All @@ -59,3 +161,4 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
7 changes: 6 additions & 1 deletion charts/filestash/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ metadata:
name: {{ $fullName }}
labels:
{{- include "filestash.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
{{- if or .Values.ingress.annotations .Values.ingress.isTraefik }}
annotations:
{{- with .Values.ingress.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.ingress.isTraefik }}
traefik.ingress.kubernetes.io/router.middlewares: "{{ printf "%s-%s" .Release.Namespace $fullName }}-add-headers@kubernetescrd"
{{- end }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
Expand Down
10 changes: 10 additions & 0 deletions charts/filestash/templates/middleware.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if and .Values.ingress.isTraefik .Values.ingress.enabled (.Capabilities.APIVersions.Has "traefik.containo.us/v1alpha1/Middleware") -}}
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: "{{ include "filestash.fullname" . | printf "%s-add-headers" }}"
spec:
headers:
customRequestHeaders:
X-Forwarded-Proto: https
{{- end }}
25 changes: 25 additions & 0 deletions charts/filestash/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.persistence.filestashState.enabled }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "filestash.fullname" . }}-state
labels:
{{- include "filestash.labels" . | nindent 4 }}
{{- if .Values.persistence.filestashState.annotations }}
annotations:
{{ toYaml .Values.persistence.filestashState.annotations | indent 4 }}
{{- end }}
spec:
accessModes:
- {{ .Values.persistence.filestashState.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.filestashState.storageSize | quote }}
{{- if .Values.persistence.filestashState.storageClass }}
{{- if (eq "-" .Values.persistence.filestashState.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.filestashState.storageClass }}"
{{- end }}
{{- end }}
{{- end }}
22 changes: 22 additions & 0 deletions charts/filestash/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: {{ include "filestash.fullname" . }}
labels:
{{- include "filestash.labels" . | nindent 4 }}
{{- include "filestash.componentLabels.webapp" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
Expand All @@ -13,3 +14,24 @@ spec:
name: http
selector:
{{- include "filestash.selectorLabels" . | nindent 4 }}
{{- include "filestash.componentLabels.webapp" . | nindent 4 }}
{{- if .Values.documentServer.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "filestash.documentServer.fullname" . }}
labels:
{{- include "filestash.labels" . | nindent 4 }}
{{- include "filestash.componentLabels.documentServer" . | nindent 4 }}
spec:
type: {{ .Values.documentServer.service.type }}
ports:
- port: {{ .Values.documentServer.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "filestash.selectorLabels" . | nindent 4 }}
{{- include "filestash.componentLabels.documentServer" . | nindent 4 }}
{{- end }}
18 changes: 18 additions & 0 deletions charts/filestash/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,21 @@ spec:
command: ['wget']
args: ['{{ include "filestash.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
{{- if .Values.documentServer.enabled }}
---
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "filestash.documentServer.fullname" . }}-test-connection"
labels:
{{- include "filestash.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "filestash.documentServer.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
{{- end }}
38 changes: 38 additions & 0 deletions charts/filestash/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ imagePullSecrets: []
nameOverride: "filestash"
fullnameOverride: ""

# Environment variables passed to filestash
env: []
# - name: TZ
# value: UTC

serviceAccount:
# Specifies whether a service account should be created
create: true
Expand All @@ -36,13 +41,36 @@ securityContext: {}
# runAsNonRoot: true
# runAsUser: 1000

documentServer:
enabled: false
nameOverride: "document-server"
fullnameOverride: ""
image:
repository: onlyoffice/documentserver
pullPolicy: IfNotPresent
tag: ""
replicaCount: 1
# Environment variables passed to document server
env: []
# - name: TZ
# value: UTC

service:
type: ClusterIP
port: 80

service:
type: ClusterIP
port: 8334

ingress:
enabled: false
className: ""
# Set "isTraefik: true" if Traefik is the ingress provider. When true, a middleware
# is created that adds an "X-Forwarded-Proto: https" header, and an annotation is
# added to the ingress to attach this middleware. Document server integration with
# filestash does not work correctly with traefik if this is not done.
isTraefik: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
Expand Down Expand Up @@ -77,6 +105,16 @@ autoscaling:

nodeSelector: {}

persistence:
filestashState:
enabled: false
# Note that ReadWriteOnce will not work with replicaCount > 1 or autoscaling
accessMode: ReadWriteOnce
# annotations:
# "helm.sh/resource-policy": keep
# storageClass: "default"
storageSize: 100Mi

tolerations: []

affinity: {}

0 comments on commit eabed17

Please sign in to comment.