# yaml-language-server: $schema=./values.schema.json
image:
  repository: docker.io/teslamate/teslamate
  pullPolicy: IfNotPresent
  tag: 3.0.0@sha256:6569026b73bd657455bbec05965d07fa30b6d4d70eaab0bd5b343231c0429167

securityContext:
  container:
    readOnlyRootFilesystem: false

service:
  main:
    ports:
      main:
        protocol: http
        port: 4000

workload:
  main:
    replicas: 1
    strategy: RollingUpdate
    podSpec:
      containers:
        main:
          env:
            ENCRYPTION_KEY:
              secretKeyRef:
                name: teslamate-secrets
                key: TESLAMATE_ENCRYPTION_KEY
            DATABASE_USER: "{{ .Values.cnpg.main.user }}"
            DATABASE_PASS:
              secretKeyRef:
                name: cnpg-main-user
                key: password
            DATABASE_NAME: "{{ .Values.cnpg.main.database }}"
            DATABASE_HOST:
              secretKeyRef:
                name: cnpg-main-urls
                key: host
            DISABLE_MQTT: true
            MQTT_HOST: ""
            MQTT_PORT: 1883
            MQTT_USERNAME: ""
            MQTT_PASSWORD: ""

configmap:
  datasource:
    enabled: true
    labels:
      grafana_datasource: "1"
    data:
      datasourceteslamatepsql.yaml: |-
        apiVersion: 1
        datasources:
        - name: TeslaMate
          type: postgres
          uid: TeslaMate
          url: {{ printf "%s.%s:5432" (.Values.cnpg.main.creds.host | trimAll "\"") .Release.Namespace }}
          access: proxy
          user: {{ .Values.cnpg.main.user }}
          secureJsonData:
            password: {{ .Values.cnpg.main.creds.password | default "na" }}
          jsonData:
            database: {{ .Values.cnpg.main.database }}
            sslmode: 'disable' # disable/require/verify-ca/verify-full
            maxOpenConns: 100 # Grafana v5.4+
            maxIdleConns: 100 # Grafana v5.4+
            maxIdleConnsAuto: true # Grafana v9.5.1+
            connMaxLifetime: 14400 # Grafana v5.4+
            postgresVersion: 1500 # 903=9.3, 904=9.4, 905=9.5, 906=9.6, 1000=10
            timescaledb: false

cnpg:
  main:
    enabled: true
    user: teslamate
    database: teslamate
    cluster:
      initdb:
        postInitApplicationSQL:
          - ALTER USER teslamate WITH SUPERUSER
