apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: znc
  namespace: irc
spec:
  interval: 5m
  chart:
    spec:
      chart: app-template
      version: 1.3.x
      sourceRef:
        kind: HelmRepository
        name: bjws-charts
        namespace: flux-system

  values:
    podLabels:
      needsAuthentik: "yes"

    # Add init container for pulling znc modules and putting them into the modules directory
    initContainers:
      pull-module-source:
        image: alpine:3.21.0
        command:
          - "sh"
          - "-c"
          - "rm -f /znc-data/modules/ctcp_notifier.*; wget https://raw.githubusercontent.com/Zarthus/znc-modules/master/ctcp_notifier.cpp -P /znc-data/modules; rm -f /znc-data/modules/push.*; wget https://raw.githubusercontent.com/SeanOMik/znc-push/master/push.cpp -P /znc-data/modules"
        volumeMounts:
          - mountPath: /znc-data
            name: config

    image:
      repository: znc
      tag: "1.9.1"
    
    service:
      main:
        ports:
          http:
            port: 6501
      irc:
        enabled: true
        type: NodePort
        ports:
          irc:
            enabled: true
            port: 6667
            protocol: TCP
            nodePort: 30652
    
    probes:
      liveness:
        enabled: false
    
    ingress:
      main:
        enabled: true
        annotations:
          cert-manager.io/cluster-issuer: letsencrypt-production
          traefik.ingress.kubernetes.io/router.entrypoints: websecure
        hosts:
          - host: &host "znc.${SECRET_NEW_DOMAIN}"
            paths:
              - path: /
                pathType: Prefix
        tls:
          - hosts:
              - *host

    persistence:
      config:
        enabled: true
        type: hostPath
        hostPath: /mnt/MainPool/Kubernetes/znc
        mountPath: /znc-data

    resources:
      requests:
        cpu: 1m
        memory: 40Mi
      limits:
        memory: 1Gi # this will likely not happen during normal running, but compiling modules requires this