---
# yaml-language-server: $schema=https://raw.githubusercontent.com/bjw-s/helm-charts/main/charts/other/app-template/schemas/helmrelease-helm-v2.schema.json
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: &app scrutiny
spec:
  interval: 30m
  chart:
    spec:
      chart: app-template
      version: 3.5.1
      sourceRef:
        kind: HelmRepository
        name: bjw-s
        namespace: flux-system
  install:
    remediation:
      retries: 3
  upgrade:
    cleanupOnFail: true
    remediation:
      retries: 3
      strategy: rollback
  values:
    controllers:
      scrutiny-collector:
        type: cronjob
        annotations:
          reloader.stakater.com/auto: "true"
        cronjob:
          schedule: "@daily"
        containers:
          app:
            image:
              repository: ghcr.io/analogj/scrutiny
              tag: v0.8.1-collector
            env:
              TZ: America/Chicago
              COLLECTOR_API_ENDPOINT: http://scrutiny.observability.svc.cluster.local:8080
              COLLECTOR_HOST_ID:
                valueFrom:
                  fieldRef:
                    fieldPath: spec.nodeName
            args:
              - /opt/scrutiny/bin/scrutiny-collector-metrics
              - run
            securityContext:
              privileged: true
              readOnlyRootFilesystem: true
            resources:
              requests:
                cpu: 10m
              limits:
                memory: 128Mi
      scrutiny:
        containers:
          app:
            image:
              repository: ghcr.io/analogj/scrutiny
              tag: v0.8.1-web
            env:
              SCRUTINY_WEB_INFLUXDB_BUCKET: scrutiny
              SCRUTINY_WEB_INFLUXDB_HOST: influxdb2.database.svc.cluster.local
              SCRUTINY_WEB_INFLUXDB_ORG: scrutiny
              TZ: America/Chicago
            envFrom:
              - secretRef:
                  name: scrutiny-secret
            securityContext:
              allowPrivilegeEscalation: false
              readOnlyRootFilesystem: true
              capabilities: { drop: ["ALL"] }
            probes:
              liveness: &probe
                enabled: true
                custom: true
                spec:
                  httpGet:
                    path: /api/health
                    port: &port 8080
              readiness: *probe
              startup:
                enabled: false

    service:
      scrutiny:
        controller: scrutiny
        ports:
          http:
            port: *port
    ingress:
      scrutiny:
        className: internal-nginx
        hosts:
          - host: "{{ .Release.Name }}.jahanson.tech"
            paths:
              - path: /
                service:
                  identifier: scrutiny
                  port: http
    persistence:
      scrutiny-config:
        existingClaim: *app
        advancedMounts:
          scrutiny:
            app:
              - path: /opt/scrutiny/config
      collector-config:
        enabled: true
        type: emptyDir
        advancedMounts:
          scrutiny-collector:
            app:
              - path: /config
      dev:
        type: hostPath
        hostPath: /dev
        hostPathType: Directory
      udev:
        type: hostPath
        hostPath: /run/udev
        hostPathType: Directory