# Override the name for the application.
# If not set, the chart name will be used.
nameOverride: ""

# Override the name of the application component.
# Defaults to the same value as nameOverride.
componentOverride: ""

# Override the application "part-of" label.
# Defaults to the chart name if not set.
partOfOverride: ""

##########################################################
# Enterprise Configuration
##########################################################
enterprise:
  enabled: false
  licenseKey: ""

##########################################################
# Deployment Configuration
##########################################################
deployment:
  # Deployment strategy configuration
  strategy:
    type: RollingUpdate  # Type of deployment strategy (RollingUpdate/Recreate)
    # rollingUpdate:
    #   maxSurge: 25%
    #   maxUnavailable: 25%

  # Automatically reload deployment when ConfigMaps or Secrets change
  reloadOnChange: false

  # NodeSelector for scheduling pods on specific nodes
  nodeSelector: {}

  # Additional labels for Deployment
  additionalLabels: {}

  # Additional pod labels to be used in the Service's label selector
  additionalPodLabels: {}

  # Deployment annotations
  annotations: {}

  # Additional pod annotations
  additionalPodAnnotations: {}

  # Number of replicas
  replicas: 1

  # Image pull secrets for private container registries
  imagePullSecrets: ""

  # Environment variables from ConfigMaps or Secrets
  envFrom:
    # app-secrets:
    #   type: secret
    #   nameSuffix: app-secrets

  # Environment variables passed to the app container
  env:
    DOCKER_CRON_ENABLED:
      value: "0"

  # Tolerations for scheduling pods on tainted nodes
  tolerations: []

  # Pod affinity and anti-affinity rules
  affinity: {}

  # Topology spread constraints for better scheduling
  topologySpreadConstraints: []

  # Number of previous ReplicaSet versions to retain
  revisionHistoryLimit: 2

  # Application container image
  image:
    repository: "ghcr.io/formbricks/formbricks"
    digest: ""  # If set, digest takes precedence over the tag
    pullPolicy: IfNotPresent

  # Health probes configuration
  probes:
    startupProbe:
      failureThreshold: 30
      periodSeconds: 10
      tcpSocket:
        port: 3000

    readinessProbe:
      failureThreshold: 5
      periodSeconds: 10
      successThreshold: 1
      timeoutSeconds: 5
      initialDelaySeconds: 10
      httpGet:
        path: /health
        port: 3000

    livenessProbe:
      failureThreshold: 5
      periodSeconds: 10
      successThreshold: 1
      timeoutSeconds: 5
      initialDelaySeconds: 10
      httpGet:
        path: /health
        port: 3000

  # Resource requests and limits
  resources:
    limits:
      memory: 2Gi
    requests:
      memory: 1Gi
      cpu: "1"

  # Container security context
  containerSecurityContext:
    readOnlyRootFilesystem: true
    runAsNonRoot: true

  # Pod security context
  securityContext: {}

  # Command override
  command: []

  # Arguments override
  args: []

  # Container ports
  ports:
    http:
      containerPort: 3000
      protocol: TCP
      exposed: true
    metrics:
      containerPort: 9464
      protocol: TCP
      exposed: true

##########################################################
# Horizontal Pod Autoscaler (HPA)
##########################################################
autoscaling:
  enabled: true  # Enable/disable HPA
  additionalLabels: {}  # Additional labels for the HPA resource
  annotations: {}  # Annotations for HPA
  minReplicas: 1  # Minimum number of replicas
  maxReplicas: 10  # Maximum number of replicas
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 60
    - type: Resource
      resource:
        name: memory
        target:
          type: Utilization
          averageUtilization: 60

##########################################################
# Service Configuration
##########################################################
service:
  enabled: true  # Enable/disable Kubernetes Service
  additionalLabels: {}  # Additional labels for Service
  annotations: {}  # Annotations for Service
  type: ClusterIP  # Service type (ClusterIP, NodePort, LoadBalancer)
  ports: []  # Additional ports

##########################################################
# Role-Based Access Control (RBAC)
##########################################################
rbac:
  enabled: false  # Enable/disable RBAC
  serviceAccount:
    enabled: false  # Enable/disable ServiceAccount
    name: ""  # Custom ServiceAccount name
    additionalLabels: {}  # Additional labels
    annotations: {}  # Annotations

##########################################################
# Cron Job Configuration
##########################################################
cronJob:
  enabled: false  # Enable/disable CronJobs
  jobs: {}  # Define cron jobs

##########################################################
# Kubernetes Secret Configuration (Quick Start)
##########################################################
secret:
  enabled: true

##########################################################
# External Secrets Configuration
##########################################################
externalSecret:
  enabled: false  # Enable/disable ExternalSecrets
  secretStore:
    name: aws-secrets-manager  # Secret store reference name
    kind: ClusterSecretStore  # Type of secret store
  refreshInterval: "1h"  # Frequency of secret sync
  files: {}

##########################################################
# Ingress Configuration
##########################################################
ingress:
  enabled: false  # Enable/disable Ingress
  ingressClassName: alb  # Specify the Ingress class
  hosts:
    - host: k8s.formbricks.com
      paths:
        - path: /
          pathType: "Prefix"
          serviceName: "formbricks"
  annotations: {}  # Ingress annotations


##########################################################
# Redis Configuration
##########################################################
redis:
  enabled: true  # Enable/disable Redis
  externalRedisUrl: ""
  fullnameOverride: "formbricks-redis"
  architecture: standalone
  auth:
    enabled: true
    existingSecret: "formbricks-app-secrets"
    existingSecretPasswordKey: "REDIS_PASSWORD"
  networkPolicy:
    enabled: false
  master:
    persistence:
      enabled: true

##########################################################
# Service Monitor to collect Prometheus metrices
##########################################################
serviceMonitor:
  enabled: true

  # Additional labels
  additionalLabels:
  # key: value

  # Additional annotations
  annotations:
  # key: value

  # List of the endpoints of service from which prometheus will scrape data
  endpoints:
    - interval: 5s
      path: /metrics
      port: metrics

##########################################################
# PostgreSQL Configuration
##########################################################
postgresql:
  enabled: true  # Enable/disable PostgreSQL
  externalDatabaseUrl: ""
  global:
    security:
      allowInsecureImages: true
  fullnameOverride: "formbricks-postgresql"
  image:
    repository: pgvector/pgvector
    tag: 0.8.0-pg17
  auth:
    username: formbricks
    database: formbricks
    existingSecret: "formbricks-app-secrets"
    secretKeys:
      adminPasswordKey: "POSTGRES_ADMIN_PASSWORD"
      userPasswordKey: "POSTGRES_USER_PASSWORD"
  primary:
    networkPolicy:
      enabled: false
    persistence:
      enabled: true
      size: 10Gi
    podSecurityContext:
      enabled: true
      fsGroup: 1001
      runAsUser: 1001
    containerSecurityContext:
      enabled: true
      runAsUser: 1001
      readOnlyRootFilesystem: false
