# This file and its contents are licensed under the Apache License 2.0.
# Please see the included NOTICE for copyright information and LICENSE for a copy of the license.

dataNodes: 3

# To prevent very long names, we override the name, otherwise it would default to
# timescaledb-multinode (the name of the chart)
nameOverride: timescaledb

image:
  # Image was built from
  # https://github.com/timescale/timescaledb-docker-ha
  repository: timescale/timescaledb-ha
  tag: pg14.5-ts2.8.0-patroni-static-primary-latest
  pullPolicy: IfNotPresent

# Credentials used by PostgreSQL
credentials:
  accessNode:
    superuser: big_dick
  dataNode:
    superuser: big_dick

# Extra custom environment variables.
# These should be an EnvVar, as this allows you to inject secrets into the environment
# https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#envvar-v1-core
env:
  - name: LC_ALL
    value: C.UTF-8
  - name: LANG
    value: C.UTF-8
  - name: PGDATA
    # This should be a subdirectory of the persistentVolume (if any), as PostgreSQL will need to
    # fully manage permissions. Also, using /var/lib/postgresql/data is discouraged, as this is
    # a Docker Volume in many Docker images, which means the data is not actually persisted.
    value: /var/lib/postgresql/pgdata

persistentVolume:
  enabled: true
  size: 100G
  ## database data Persistent Volume Storage Class
  ## If defined, storageClassName: <storageClass>
  ## If set to "-", storageClassName: "", which disables dynamic provisioning
  ## If undefined (the default) or set to null, no storageClassName spec is
  ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
  ##   GKE, AWS & OpenStack)
  ##
  # storageClass: "-"
  subPath: ""
  mountPath: "/var/lib/postgresql"
  annotations: {}
  accessModes:
    - ReadWriteOnce

resources: {}

postgresql:
  databases:
    - postgres
    - scada
  parameters:
    max_connections: 100
    max_prepared_transactions: 150
    # This is rather small, but as this Helm Chart may be used to spin up
    # 1 access node and 4 data nodes on a single minikube/microk8s this is set
    # to a conservative value
    shared_buffers: 300MB
    work_mem: 16MB
    log_connections: 'on'
    log_line_prefix: "%t [%p]: [%c-%l] %u@%d,app=%a [%e] "
    log_min_duration_statement: '1s'
    log_statement: ddl
    log_checkpoints: 'on'
    log_lock_waits: 'on'
    # These values are set as the default data volume size
    # is small as well.
    min_wal_size: 256MB
    max_wal_size: 512MB
    temp_file_limit: 1GB

# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
nodeSelector: {}

# https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
tolerations: []

# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
affinityTemplate: |
  podAntiAffinity:
    preferredDuringSchedulingIgnoredDuringExecution:
    - weight: 100
      podAffinityTerm:
        topologyKey: "kubernetes.io/hostname"
        labelSelector:
          matchLabels:
            app:  {{ template "timescaledb.name" . }}
            release: {{ .Release.Name | quote }}
affinity: {}

## Use an alternate scheduler, e.g. "stork".
## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/
##
# schedulerName:

rbac:
  # Specifies whether RBAC resources should be created
  create: true

serviceAccount:
  # Specifies whether a ServiceAccount should be created
  create: true
  # The name of the ServiceAccount to use.
  # If not set and create is true, a name is generated using the fullname template
  name:
