nextcloud / helm

A community maintained helm chart for deploying Nextcloud on Kubernetes.
GNU Affero General Public License v3.0
334 stars 269 forks source link

S3: `failed to create resource: [...] spec.template.spec.containers[1].env[22].valueFrom.secretKeyRef.key: Required value]` #616

Closed unbelauscht closed 2 months ago

unbelauscht commented 3 months ago

Describe your Issue

Installing Nextcloud with Helm chart version 5.5.2 results in

failed to create resource: Deployment.apps "nextcloud" is invalid: [spec.template.spec.containers[0].env[22].valueFrom.secretKeyRef.key: Required value, spec.template.spec.containers[1].env[22].valueFrom.secretKeyRef.key: Required value]

Logs and Errors

Helm repo:

---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
  name: nextcloud
  namespace: nextcloud
spec:
  interval: 3h0m0s
  url: https://nextcloud.github.io/helm

Describe your Environment

apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
  name: nextcloud
  namespace: nextcloud
spec:
  timeout: 1h
  chart:
    spec:
      chart: nextcloud
      reconcileStrategy: ChartVersion
      sourceRef:
        kind: HelmRepository
        name: nextcloud
  interval: 12h
  values:
    replicaCount: 1
    image:
      flavor: apache
    internalDatabase:
      enabled: false
    externalDatabase:
      enabled: true
      type: postgresql
      host: nextcloud-rw
      database: nextcloud
      existingSecret:
        enabled: true
        secretName: nextcloud-db
        usernameKey: username
        passwordKey: password
    startupProbe:
      enabled: true
      initialDelaySeconds: 20
      failureThreshold: 10
    ingress:
      enabled: true
      servicePort: 80
      annotations:
        traefik.ingress.kubernetes.io/router.middlewares: nextcloud-maxrequestbodybytes@kubernetescrd
        external-dns.alpha.kubernetes.io/target: drive.example.com
        external-dns.alpha.kubernetes.io/cloudflare-proxied: "false"
      tls:
        - hosts:
            - drive.example.com
    persistence:
      enabled: true
      accessMode: ReadWriteOnce
      size: 10Gi
    redis:
      enabled: true
    nextcloud:
      host: drive.example.com
      objectStore:
        s3:
          enabled: true
          ssl: true
          port: "443"
          region: "eu-central-003"
          autocreate: false
          existingSecret: s3
          secretKeys:
            accessKey: accessKey
            secretKey: secretKey
            bucket: bucket
            host: host
      existingSecret:
        enabled: true
        secretName: nextcloud-user
        usernameKey: username
        passwordKey: password
      mail:
        enabled: false
    cronjob:
      enabled: true
    phpClientHttpsFix:
      enabled: true
      protocol: https

S3 credentials

---
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
  creationTimestamp: null
  name: s3
  namespace: nextcloud
spec:
  encryptedData:
    accessKey: *redacted*
    bucket: *redacted*
    host: *redacted*
    secretKey: *redacted*
  template:
    metadata:
      creationTimestamp: null
      name: s3
      namespace: nextcloud
unbelauscht commented 3 months ago

So apparently the sse_c_key must be set, because it doesn't render correctly if not supplied.

$ helm template ./nextcloud --values HelmRelease.yaml --generate-name
...
 - name: OBJECTSTORE_S3_SSE_C_KEY
    valueFrom:
      secretKeyRef:
        name: s3
        key:

EDIT: yep, the sse_c_key was missing, now it works. Maybe the helm chart docs need a little more love like: Which values are required and which ones override other and which one's don't need to be set if value x or y is set.

WladyX commented 2 months ago

On the same note, is SSE mandatory? anyway we can disable it? I have minio and don't have SSE enabled. Thank you!

unbelauscht commented 2 months ago

On the same note, is SSE mandatory? anyway we can disable it?

I couldn't make the chart work without it.

WladyX commented 2 months ago

Thank for update, I've ended up enabling the SSE, was not that hard, just had to add the certs and make the reverse proxy connect to the minio backend via SSL.

joshtrichards commented 2 months ago

Confirmed (at least by looking at the code; with the caveat that I'm more familiar with the underlying container image than the Helm chart). Looks like the issue is here on line 304:

https://github.com/nextcloud/helm/blob/58ecb7d32c1cdeff4452040f1953df6f7925c552/charts/nextcloud/templates/_helpers.tpl#L304-L315

The reference to .Values.nextcloud.objectStore.s3.secretKeys.bucket looks to be a typo. Probably should be .Values.nextcloud.objectStore.s3.secretKeys.sse_c_key.

Introduced recently in #464

jessebot commented 2 months ago

yep that is a typo! sorry about that and thanks @joshtrichards and @unbelauscht for catching this! I'll submit a PR to fix that. 🙏