Skip to content

Commit

Permalink
feat(nextcloud): Add support of imaginary an externalPreviewProvider
Browse files Browse the repository at this point in the history
Signed-off-by: WrenIX <[email protected]>
  • Loading branch information
wrenix committed Oct 22, 2024
1 parent 671f4c2 commit cb01438
Show file tree
Hide file tree
Showing 8 changed files with 259 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ jobs:
helm_args: |
--namespace nextcloud --skip-clean-up --helm-extra-set-args "--set=fullnameOverride=nextcloud --set=nextcloud.objectStore.s3.enabled=true --set=nextcloud.objectStore.s3.accessKey=nextcloud --set=nextcloud.objectStore.s3.secretKey=rootpass123 --set=nextcloud.objectStore.s3.host=minio.nextcloud.svc.cluster.local --set=nextcloud.objectStore.s3.port=9000 --set=nextcloud.objectStore.s3.ssl=false --set=nextcloud.objectStore.s3.bucket=nextcloud --set=nextcloud.objectStore.s3.usePathStyle=true --set=image.flavor=fpm --set=nginx.enabled=true --set=nextcloud.host=nextcloud --set=nextcloud.trustedDomains[0]='*'"
# test the helm chart with imaginary
- name: Imaginary Enabled
helm_args: --helm-extra-set-args "--values charts/nextcloud/test-values/imaginary.yaml"

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion charts/nextcloud/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: nextcloud
version: 6.2.0
version: 6.3.0
appVersion: 30.0.1
description: A file sharing server that puts the control and security of your own data back into your hands.
keywords:
Expand Down
45 changes: 45 additions & 0 deletions charts/nextcloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ helm install my-release nextcloud/nextcloud
* [Metrics Configurations](#metrics-configurations)
* [Headers set on nginx](#headers-set-on-nginx)
* [Probes Configurations](#probes-configurations)
* [Imaginary](#imaginary)
* [Cron jobs](#cron-jobs)
* [Using the nextcloud docker image auto-configuration via env vars](#using-the-nextcloud-docker-image-auto-configuration-via-env-vars)
* [Multiple config.php file](#multiple-configphp-file)
Expand Down Expand Up @@ -457,6 +458,50 @@ The nextcloud deployment includes a series of different probes you can use to de
> [!Note]
> If you are getting errors on initialization (such as `Fatal error: require_once(): Failed opening required '/var/www/html/lib/versioncheck.php'`, but you can get other errors as well), a good first step is to try and enable the startupProbe and/or increase the `initialDelaySeconds` for the `livenessProbe` and `readinessProbe` to something much greater (consider using `120` seconds instead of `10`. This is an especially good idea if your cluster is running on older hardware, has a slow internet connection, or you're using a slower storage class, such as NFS that's running with older disks or a slow connection.
### Imaginary
We include an optional external preview provider from [h2non/imaginary](https://github.com/h2non/imaginary).
| Parameter | Description | Default |
|----------------------------------------|-----------------------------------------------------------------------------------------|-------------------|
| `imaginary.enabled` | Start Imaginary | `false` |
| `imaginary.replicaCount` | Number of imaginary pod replicas to deploy | `1` |
| `imaginary.image.registry` | Imaginary image name | `docker.io` |
| `imaginary.image.repository` | Imaginary image name | `h2non/imaginary` |
| `imaginary.image.tag` | Imaginary image tag | `1.2.4` |
| `imaginary.image.pullPolicy` | Imaginary image pull policy | `IfNotPresent` |
| `imaginary.image.pullSecrets` | Imaginary image pull secrets | `nil` |
| `imaginary.podAnnotations` | Additional annotations for imaginary | `{}` |
| `imaginary.podLabels` | Additional labels for imaginary | `{}` |
| `imaginary.resources` | imaginary resources | `{}` |
| `imaginary.securityContext` | Optional security context for the Imaginary container | `nil` |
| `imaginary.podSecurityContext` | Optional security context for the Imaginary pod (applies to all containers in the pod) | `nil` |
| `imaginary.service.type` | Imaginary: Kubernetes Service type | `ClusterIP` |
| `imaginary.service.loadBalancerIP` | Imaginary: LoadBalancerIp for service type LoadBalancer | `nil` |
| `imaginary.service.nodePort` | Imaginary: NodePort for service type NodePort | `nil` |
| `imaginary.service.annotations` | Additional annotations for service imaginary | `{}` |
| `imaginary.service.labels` | Additional labels for service imaginary | `{}` |
> [!Note]
> You also need to setup nextcloud, to use imaginary
```yaml
nextcloud:
defaultConfigs:
imaginary.config.php: true
configs:
previews.config.php: |-
<?php
$CONFIG = array(
'enabledPreviewProviders' => array(
0 => 'OC\\Preview\\Imaginary',
1 => 'OC\\Preview\\ImaginaryPDF',
);
imaginary:
enabled: true
```
## Cron jobs
To execute [background tasks](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/background_jobs_configuration.html) by using system cron instead of default Ajax cron, set `cronjob.enabled` parameter to `true`. Background jobs are important for tasks that do not necessarily need user intervention, but still need to be executed frequently (cleaning up, sending some notifications, pulling RSS feeds, etc.).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$CONFIG = array (
'preview_imaginary_url' => 'http://{{ template "nextcloud.fullname" . }}-imaginary',
);
88 changes: 88 additions & 0 deletions charts/nextcloud/templates/imaginary/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{{- if .Values.imaginary.enabled }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "nextcloud.fullname" . }}-imaginary
labels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
helm.sh/chart: {{ include "nextcloud.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: imaginary
spec:
replicas: {{ .Values.imaginary.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: imaginary
template:
metadata:
annotations:
{{- toYaml .Values.imaginary.podAnnotations | nindent 8 }}
labels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: imaginary
{{- with .Values.imaginary.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imaginary.image.pullSecrets }}
imagePullSecrets:
{{- range . }}
- name: {{ . }}
{{- end}}
{{- end }}
containers:
- name: imaginary
{{- with .Values.imaginary.image }}
image: "{{ .registry }}/{{ .repository }}:{{ .tag }}"
imagePullPolicy: {{ .pullPolicy }}
{{- end }}
env:
- name: PORT
value: "9000"
ports:
- name: http
containerPort: 9000
{{- with .Values.imaginary.readinessProbe }}
{{- if .enabled }}
readinessProbe:
httpGet:
path: /health
port: http
scheme: HTTP
failureThreshold: {{ .failureThreshold }}
successThreshold: {{ .successThreshold }}
periodSeconds: {{ .periodSeconds }}
timeoutSeconds: {{ .timeoutSeconds }}
{{- end }}
{{- end }}
{{- with .Values.imaginary.livenessProbe }}
{{- if .enabled }}
livenessProbe:
httpGet:
path: /health
port: http
scheme: HTTP
failureThreshold: {{ .failureThreshold }}
successThreshold: {{ .successThreshold }}
periodSeconds: {{ .periodSeconds }}
timeoutSeconds: {{ .timeoutSeconds }}
{{- end }}
{{- end }}
{{- with .Values.imaginary.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.imaginary.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.imaginary.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
36 changes: 36 additions & 0 deletions charts/nextcloud/templates/imaginary/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if .Values.imaginary.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ template "nextcloud.fullname" . }}-imaginary
labels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
helm.sh/chart: {{ include "nextcloud.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: imaginary
{{- with .Values.imaginary.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.imaginary.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.imaginary.service.type }}
{{- with .Values.imaginary.service.loadBalancerIP }}
loadBalancerIP: {{ . }}
{{- end }}
ports:
- name: http
port: 80
targetPort: http
{{- with .Values.imaginary.service.nodePort }}
nodePort: {{ . }}
{{- end }}
selector:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: imaginary
{{- end }}
14 changes: 14 additions & 0 deletions charts/nextcloud/test-values/imaginary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
nextcloud:
defaultConfigs:
imaginary.config.php: true
configs:
previews.config.php: |-
<?php
$CONFIG = array(
'enabledPreviewProviders' => array(
0 => 'OC\\Preview\\Imaginary',
1 => 'OC\\Preview\\ImaginaryPDF',
);
imaginary:
enabled: true
67 changes: 67 additions & 0 deletions charts/nextcloud/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ nextcloud:
swift.config.php: true
# disables the web based updater as the default nextcloud docker image does not support it
upgrade-disable-web.config.php: true
# -- imaginary support config
imaginary.config.php: false

# Extra config files created in /var/www/html/config/
# ref: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-config-php-file
Expand Down Expand Up @@ -621,6 +623,71 @@ dnsConfig: {}
# - name: ndots
# value: "1"

imaginary:
# -- Start Imgaginary
enabled: false
# -- Number of imaginary pod replicas to deploy
replicaCount: 1

image:
# -- Imaginary image registry
registry: docker.io
# -- Imaginary image name
repository: h2non/imaginary
# -- Imaginary image tag
tag: 1.2.4
# -- Imaginary image pull policy
pullPolicy: IfNotPresent
# -- Imaginary image pull secrets
pullSecrets: []

# -- Additional annotations for imaginary
podAnnotations: {}
# -- Additional labels for imaginary
podLabels: {}
# -- imaginary resources
resources: {}

# -- Optional security context for the Imaginary container
securityContext:
runAsUser: 1000
runAsNonRoot: true
# allowPrivilegeEscalation: false
# capabilities:
# drop:
# - ALL

# -- Optional security context for the Imaginary pod (applies to all containers in the pod)
podSecurityContext: {}
# runAsNonRoot: true
# seccompProfile:
# type: RuntimeDefault

readinessProbe:
enabled: true
failureThreshold: 3
successThreshold: 1
periodSeconds: 10
timeoutSeconds: 1
livenessProbe:
enabled: true
failureThreshold: 3
successThreshold: 1
periodSeconds: 10
timeoutSeconds: 1

service:
# -- Imaginary: Kubernetes Service type
type: ClusterIP
# -- Imaginary: LoadBalancerIp for service type LoadBalancer
loadBalancerIP:
# -- Imaginary: NodePort for service type NodePort
nodePort:
# -- Additional annotations for service imaginary
annotations: {}
# -- Additional labels for service imaginary
labels: {}

## Prometheus Exporter / Metrics
##
metrics:
Expand Down

0 comments on commit cb01438

Please sign in to comment.