diff --git a/.github/tests/test_job.yaml b/.github/tests/test_job.yaml new file mode 100644 index 00000000..680b7d20 --- /dev/null +++ b/.github/tests/test_job.yaml @@ -0,0 +1,63 @@ +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: test-nextcloud + namespace: nextcloud +spec: + template: + metadata: + name: test-nextcloud + spec: + initContainers: + - name: 05-create-nextcloud-file + image: curlimages/curl + command: + - /bin/sh + - -c + - | + set -e + echo "download image:" + curl -s "https://upload.wikimedia.org/wikipedia/commons/d/df/Open_data.png" -o test_upload.png + echo "upload to nextcloud:" + curl \ + -s \ + -w "%{http_code}" \ + -u admin:changeme \ + -T test_upload.png \ + "http://nextcloud.nextcloud.svc.cluster.local:8080/remote.php/dav/files/admin/test_upload.png" || exit 1; + echo "done" + - name: 10-generate-preview + image: docker.io/library/nextcloud:latest + command: + - /bin/sh + - -c + - | + set -e + echo "fetch preview:" + OUTPUT=$(curl \ + -s \ + -w "%{http_code}" \ + -u admin:changeme \ + "http://nextcloud.nextcloud.svc.cluster.local:8080/index.php/core/preview.png?file=test_upload.png&x=128&y=128&mimeFallback=true&a=0" \ + -o - | file -) + echo "${OUTPUT}"; + if ! echo "${OUTPUT}" | grep -q "PNG"; then + echo "PNG was not detected" + exit 1; + fi + if ! echo "${OUTPUT}" | grep -q "256 x 256"; then + echo "Image size is incorrect" + exit 1; + fi + echo "done" + containers: + - name: final + image: curlimages/curl + command: + - /bin/sh + - -c + - | + set -e + echo "All tests run successfull (initContainer in given order)" + restartPolicy: Never diff --git a/.github/tests/test_upload_job.yaml b/.github/tests/test_upload_job.yaml deleted file mode 100644 index ec9b9a17..00000000 --- a/.github/tests/test_upload_job.yaml +++ /dev/null @@ -1,26 +0,0 @@ ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: create-nextcloud-file - namespace: nextcloud -spec: - template: - metadata: - name: create-nextcloud-file - spec: - containers: - - name: create-nextcloud-file - image: curlimages/curl - command: - - /bin/sh - - -c - - | - echo "testing123" > test_upload.txt && \ - curl \ - -w "%{http_code}" \ - -u admin:changeme \ - -T test_upload.txt \ - "http://nextcloud.nextcloud.svc.cluster.local:8080/remote.php/dav/files/admin/test_upload.txt" && \ - echo -e "\nTried to uploaded a file, test_upload.txt, to Nextcloud." - restartPolicy: Never diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index 4d136168..dd849ef9 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -88,6 +88,12 @@ jobs: # we need to skip the clean up so we can test adding a file helm_args: | --namespace nextcloud --skip-clean-up --helm-extra-set-args "--values charts/nextcloud/test-values/s3-as-primary-storage.yaml" + test: true + + # test the helm chart with imaginary + - name: Imaginary Enabled + helm_args: --namespace nextcloud --skip-clean-up --helm-extra-set-args "--create-namespace --values charts/nextcloud/test-values/imaginary.yaml" + test: true steps: - name: Checkout @@ -140,18 +146,20 @@ jobs: if: steps.list-changed.outputs.changed == 'true' run: ct install --target-branch ${{ github.event.repository.default_branch }} ${{ matrix.test_cases.helm_args }} - - name: Try adding a file to Nextcloud - if: matrix.test_cases.name == 'S3 Enabled as Primary Storage' + - name: Run test for Nextcloud + if: matrix.test_cases.test # applies a kubernetes job that uploads a file and then checks log of finished pod run: | + EXIT=0 kubectl config set-context --current --namespace=nextcloud && \ - kubectl apply -f ./.github/tests/test_upload_job.yaml --wait=true && \ + kubectl apply -f ./.github/tests/test_job.yaml --wait=true && \ sleep 2 && \ - kubectl wait --for=condition=Complete --timeout=2m job/create-nextcloud-file && \ - echo "Here's the logs from the job:" && \ - kubectl logs --tail=-1 -f -l batch.kubernetes.io/job-name=create-nextcloud-file && \ - echo "Here's the logs from the nextcloud pod:" && \ - kubectl logs -l app.kubernetes.io/name=nextcloud + kubectl wait --for=condition=Complete --timeout=2m job/test-nextcloud || EXIT=1 + echo "Here's the logs from the job:" + kubectl logs --ignore-errors --prefix --tail=-1 --all-containers=true -l batch.kubernetes.io/job-name=test-nextcloud + echo "Here's the logs from the nextcloud pod:" + kubectl logs --ignore-errors --prefix -l app.kubernetes.io/name=nextcloud + exit $EXIT summary: runs-on: ubuntu-latest-low diff --git a/charts/nextcloud/Chart.yaml b/charts/nextcloud/Chart.yaml index 6e7d78bb..8b3b58cc 100644 --- a/charts/nextcloud/Chart.yaml +++ b/charts/nextcloud/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: nextcloud -version: 6.4.1 +version: 6.5.0 appVersion: 30.0.4 description: A file sharing server that puts the control and security of your own data back into your hands. keywords: diff --git a/charts/nextcloud/README.md b/charts/nextcloud/README.md index 9a7d532a..67869d66 100644 --- a/charts/nextcloud/README.md +++ b/charts/nextcloud/README.md @@ -28,6 +28,7 @@ helm install my-release nextcloud/nextcloud * [Headers set on NGINX](#headers-set-on-nginx) * [Probes Configurations](#probes-configurations) * [Collabora Configuration](#collabora-configuration) + * [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) @@ -530,6 +531,42 @@ This section provides options to enable and configure the Collabora Online serve > > For more information, please check the [Collabora documentation](https://sdk.collaboraonline.com/docs/installation/index.html). +### 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 + +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.). diff --git a/charts/nextcloud/files/defaultConfigs/imaginary.config.php.tpl b/charts/nextcloud/files/defaultConfigs/imaginary.config.php.tpl new file mode 100644 index 00000000..628851d8 --- /dev/null +++ b/charts/nextcloud/files/defaultConfigs/imaginary.config.php.tpl @@ -0,0 +1,23 @@ + 'http://{{ template "nextcloud.fullname" . }}-imaginary', + 'enable_previews' => true, + 'enabledPreviewProviders' => array ( + 'OC\Preview\Imaginary', + 'OC\Preview\ImaginaryPDF', + /* + defaults: + https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#enabledpreviewproviders + */ + 'OC\Preview\BMP', + // 'OC\Preview\GIF', + // 'OC\Preview\JPEG', + 'OC\Preview\Krita', + 'OC\Preview\MarkDown', + 'OC\Preview\MP3', + 'OC\Preview\OpenDocument', + // 'OC\Preview\PNG', + 'OC\Preview\TXT', + 'OC\Preview\XBitmap', + ), +); diff --git a/charts/nextcloud/templates/imaginary/deployment.yaml b/charts/nextcloud/templates/imaginary/deployment.yaml new file mode 100644 index 00000000..3845a2a0 --- /dev/null +++ b/charts/nextcloud/templates/imaginary/deployment.yaml @@ -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 }} diff --git a/charts/nextcloud/templates/imaginary/service.yaml b/charts/nextcloud/templates/imaginary/service.yaml new file mode 100644 index 00000000..7f4b09e0 --- /dev/null +++ b/charts/nextcloud/templates/imaginary/service.yaml @@ -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 }} diff --git a/charts/nextcloud/test-values/imaginary.yaml b/charts/nextcloud/test-values/imaginary.yaml new file mode 100644 index 00000000..e055edbe --- /dev/null +++ b/charts/nextcloud/test-values/imaginary.yaml @@ -0,0 +1,12 @@ +fullnameOverride: nextcloud + +nextcloud: + host: nextcloud + trustedDomains: + - 'nextcloud.nextcloud.svc.cluster.local' + - 'nextcloud' + defaultConfigs: + imaginary.config.php: true + +imaginary: + enabled: true diff --git a/charts/nextcloud/test-values/s3-as-primary-storage.yaml b/charts/nextcloud/test-values/s3-as-primary-storage.yaml index 6e82f550..8baf27d2 100644 --- a/charts/nextcloud/test-values/s3-as-primary-storage.yaml +++ b/charts/nextcloud/test-values/s3-as-primary-storage.yaml @@ -8,6 +8,9 @@ nginx: nextcloud: host: nextcloud + trustedDomains: + - 'nextcloud.nextcloud.svc.cluster.local' + - 'nextcloud' objectStore: s3: enabled: true diff --git a/charts/nextcloud/values.yaml b/charts/nextcloud/values.yaml index 5bd685a0..b4a39c60 100644 --- a/charts/nextcloud/values.yaml +++ b/charts/nextcloud/values.yaml @@ -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 @@ -680,6 +682,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: