# Default values for the Plone chart.
#
# The defaults install Plone 6 with the Volto frontend, a PostgreSQL database
# managed by CloudNativePG, and a Gateway API HTTPRoute. See the README for the
# other scenarios and the values to set for each of them.

nameOverride: ""
fullnameOverride: ""
imagePullSecrets: []

global:
  # What the VCL of Varnish needs to know about the Services of this chart. The
  # VCL is rendered by the varnish-cache chart, which only shares the global
  # values with this chart. With varnish.enabled, the chart fails if these don't
  # match the values they mirror.
  plone:
    # Must match fullnameOverride.
    fullnameOverride: ""
    # Must match backend.service.port.
    backendPort: 8080
    # Must match frontend.service.port.
    frontendPort: 3000

# The Plone site.
site:
  # Id of the Plone site object in Zope.
  id: Plone
  # Create the site, if it doesn't exist yet, with a Job that runs after each
  # install and upgrade of the chart. Its type follows frontend.enabled: a Volto
  # site with the frontend, a Classic UI site without it.
  create: true
  # Add-on profiles to apply when creating the site, comma separated.
  profiles: ""
  # Default language of the site, such as "en" or "pt-br".
  defaultLanguage: ""

# Storage of the Plone database (ZODB).
storage:
  # relstorage: RelStorage on PostgreSQL. The database is the CloudNativePG
  #   cluster of this chart (postgresql.enabled), or an external server.
  # zeo: a ZEO server. It's deployed by this chart, unless storage.zeo.address
  #   points to an external one. Set postgresql.enabled to false.
  type: relstorage

  relstorage:
    # PostgreSQL host. Defaults to the read-write service of the CloudNativePG
    # cluster, <release>-postgresql-rw. Required with postgresql.enabled false.
    host: ""
    port: 5432
    # Secret with the database name, user name, and password.
    secret:
      # Defaults to the secret generated by CloudNativePG,
      # <release>-postgresql-app. Required with postgresql.enabled false.
      name: ""
      # Keys of the database name, user name, and password in the secret.
      # Default to the keys of the CloudNativePG secret (dbname, username,
      # password) with postgresql.enabled, and to database-name, database-user,
      # database-password without it.
      keys: {}
        # database: database-name
        # user: database-user
        # password: database-password
    # Keep the history of the objects, needed for undo.
    keepHistory: true
    # Size of the blob cache of each backend pod.
    blobCacheSize: 100mb

  zeo:
    # host:port of an external ZEO server. Leave empty to deploy a ZEO server
    # with this chart.
    address: ""
    # Size of the ZEO client cache of each backend pod.
    clientCacheSize: 128MB
    # The ZEO server deployed when storage.zeo.address is empty.
    server:
      image:
        repository: docker.io/plone/plone-zeo
        tag: "6.0.0"
        pullPolicy: IfNotPresent
      persistence:
        enabled: true
        # storageClass: ""
        accessMode: ReadWriteOnce
        size: 5Gi
      # Extra environment variables, see
      # https://6.docs.plone.org/install/containers/images/zeo.html
      env: []
      resources:
        requests:
          cpu: 50m
          memory: 48Mi
      podAnnotations: {}
      # The user of the plone-zeo image. fsGroup makes the volume writable by it.
      # These defaults comply with the Pod Security restricted profile.
      podSecurityContext:
        runAsNonRoot: true
        runAsUser: 500
        runAsGroup: 500
        fsGroup: 500
        fsGroupChangePolicy: OnRootMismatch
        seccompProfile:
          type: RuntimeDefault
      securityContext:
        allowPrivilegeEscalation: false
        capabilities:
          drop:
            - ALL
      nodeSelector: {}
      tolerations: []
      affinity: {}

# Packs the database regularly, removing old object revisions and unused
# objects. Uses zodbpack with RelStorage and zeopack with ZEO.
pack:
  enabled: true
  schedule: "45 9 * * *"
  # Keep the history of the last days, so that undo works for them. 0 removes
  # all of the history.
  days: 7
  # Retries of a failed pack, until the next schedule.
  backoffLimit: 1
  # Stop a pack running for longer than this, 23 hours by default, so that a
  # stuck pack doesn't block the next one. Keep it below the schedule interval.
  activeDeadlineSeconds: 82800
  resources: {}

# The Plone backend (plone-backend image): the REST API for Volto, or the
# whole site with the Classic UI.
backend:
  image:
    repository: docker.io/plone/plone-backend
    # Defaults to the chart appVersion.
    tag: ""
    pullPolicy: IfNotPresent
  replicas: 1
  # Only created with more than one replica.
  podDisruptionBudget:
    enabled: true
    minAvailable: 50%
    # maxUnavailable:
  # Size of the ZODB object cache, in objects.
  zodbCacheSize: 50000
  # Extra environment variables, see
  # https://6.docs.plone.org/install/containers/images/backend.html
  env: []
  #  - name: ZOPE_FORM_MEMORY_LIMIT
  #    value: 8MB
  service:
    type: ClusterIP
    port: 8080
  resources:
    requests:
      cpu: 100m
      memory: 300Mi
  # The first start is slow, while the database is initialized.
  startupProbe:
    httpGet:
      path: /
      port: http
    periodSeconds: 10
    timeoutSeconds: 15
    failureThreshold: 60
  readinessProbe:
    httpGet:
      path: /
      port: http
    periodSeconds: 10
    timeoutSeconds: 15
    failureThreshold: 3
  livenessProbe:
    httpGet:
      path: /
      port: http
    periodSeconds: 10
    timeoutSeconds: 15
    failureThreshold: 3
  podAnnotations: {}
  podSecurityContext: {}
  securityContext: {}
  nodeSelector: {}
  tolerations: []
  affinity: {}

# The Volto frontend (plone-frontend image). Set enabled to false for the
# Classic UI, which is rendered by the backend.
frontend:
  enabled: true
  image:
    repository: docker.io/plone/plone-frontend
    tag: "19.7.0"
    pullPolicy: IfNotPresent
  replicas: 1
  # Only created with more than one replica.
  podDisruptionBudget:
    enabled: true
    minAvailable: 50%
    # maxUnavailable:
  # Extra environment variables, see
  # https://6.docs.plone.org/install/containers/images/frontend.html
  env: []
  service:
    type: ClusterIP
    port: 3000
  resources:
    requests:
      cpu: 50m
      memory: 200Mi
  readinessProbe:
    httpGet:
      path: /ok
      port: http
    periodSeconds: 10
  livenessProbe:
    httpGet:
      path: /ok
      port: http
    periodSeconds: 10
  podAnnotations: {}
  podSecurityContext: {}
  securityContext: {}
  nodeSelector: {}
  tolerations: []
  affinity: {}

# PostgreSQL cluster managed by the CloudNativePG operator (cnpg/cluster chart),
# used with storage.type relstorage.
# See https://github.com/cloudnative-pg/charts/tree/main/charts/cluster for all options.
postgresql:
  enabled: true
  cluster:
    # A single instance. For high availability, use 3 instances and set
    # enablePDB to true.
    instances: 1
    enablePDB: false
    # Plone only needs the database owner created by initdb.
    enableSuperuserAccess: false
    storage:
      size: 8Gi
    initdb:
      database: plone
      owner: plone

# Varnish cache in front of the backend (varnish-cache chart by Varnish Software).
# See https://github.com/varnish/helm-varnish-cache for all options.
varnish:
  enabled: false
  # Whether the default VCL sends requests to the Volto frontend. It must match
  # frontend.enabled: set it to false for the Classic UI. The VCL is rendered
  # by varnish-cache, which can't read frontend.enabled itself.
  ploneFrontend: true
  server:
    replicas: 1
    # With a single replica, a PodDisruptionBudget would block node drains.
    # Enable it when running more replicas.
    pdb:
      enabled: false
      minAvailable: 50%
    service:
      type: ClusterIP
      http:
        port: 6081
    # Prefer, rather than require as varnish-cache does by default, to run each
    # Varnish pod on a different node. Requiring it blocks the rolling updates
    # of Varnish, such as after a change of the VCL, on clusters with no spare
    # node, like single-node clusters.
    affinity: |
      podAntiAffinity:
        preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              labelSelector:
                matchLabels:
                  app.kubernetes.io/name: {{ include "varnish-cache.name" . }}
                  app.kubernetes.io/instance: {{ .Release.Name }}
              topologyKey: kubernetes.io/hostname
    # VCL of Varnish, rendered as a template by the varnish-cache chart, which
    # restarts the Varnish pods when it changes. Varnish receives all the
    # requests of the site, and sends them to the backend and frontend
    # Services, which balance the connections between their pods.
    # Rendered with the values of varnish-cache, so the Services come from
    # global.plone and the plone.vcl.fullname template.
    vclConfig: |
      vcl 4.1;

      # The Plone backend: the API requests with Volto, all requests with the
      # Classic UI.
      backend plone {
          .host = "{{ include "plone.vcl.fullname" . }}-backend";
          .port = "{{ .Values.global.plone.backendPort }}";
      }
      {{- if .Values.ploneFrontend }}

      # The Volto frontend: the pages and static assets of the site.
      backend volto {
          .host = "{{ include "plone.vcl.fullname" . }}-frontend";
          .port = "{{ .Values.global.plone.frontendPort }}";
      }
      {{- end }}

      sub vcl_recv {
          {{- if .Values.ploneFrontend }}
          # The routing rewrites the API requests to Zope virtual host paths.
          if (req.url ~ "^/VirtualHostBase/") {
              set req.backend_hint = plone;
          } else {
              set req.backend_hint = volto;
              # The static assets of Volto don't depend on cookies, which
              # would prevent caching them.
              if (req.url ~ "^/static/") {
                  unset req.http.Cookie;
              }
          }
          {{- else }}
          set req.backend_hint = plone;
          {{- end }}
      }

# Routing of the requests to Plone.
# With the Volto frontend:
# - /++api++ goes to the backend (through Varnish if enabled), rewritten to the
#   Zope virtual host path /VirtualHostBase/<scheme>/<hostname>:<port>/<site.id>/++api++/VirtualHostRoot
# - everything else goes to the frontend
# With the Classic UI, everything goes to the backend (through Varnish if
# enabled), rewritten to /VirtualHostBase/<scheme>/<hostname>:<port>/<site.id>/VirtualHostRoot
routing:
  # gateway: a Gateway API HTTPRoute attached to an existing Gateway
  # ingress-nginx: Ingress resources with ingress-nginx annotations
  # none: no routing resources, bring your own
  type: gateway
  # Public hostname of the site.
  hostname: localhost
  # Whether clients reach the site over HTTPS, and on which port (defaults to
  # 443 with HTTPS, 80 without). Used to build the virtual host URLs; TLS
  # itself is terminated by the Gateway or the ingress controller.
  https: false
  port: ""

  gateway:
    # Gateway the HTTPRoute attaches to, required with the gateway type.
    # It must exist already, usually managed by the cluster administrator.
    # Gateway API has no default Gateway, so there is no sensible default.
    name: ""
    # Namespace of the Gateway. Defaults to the namespace of the release.
    namespace: ""
    # Listener of the Gateway to attach to, such as http or https. Defaults to
    # all the listeners that accept the route.
    sectionName: ""
    # To attach the HTTPRoute to several Gateways, list them here instead, as
    # Gateway API parentRefs. Takes precedence over name, namespace, and
    # sectionName.
    parentRefs: []
    #  - name: plone
    #    namespace: gateway-system
    #    sectionName: https
    annotations: {}

  # The ingress-nginx project is retired since March 2026 and gets no more
  # security fixes. Prefer the gateway type for new installations.
  ingressNginx:
    className: nginx
    annotations: {}
      # cert-manager.io/cluster-issuer: "letsencrypt-prod"
    tls: []
    #  - secretName: plone-tls
    #    hosts:
    #      - plone.example.com
