---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: adguard-home
  labels:
    helm.sh/chart: adguard-home-5.2.0
    app.kubernetes.io/name: adguard-home
spec:
  revisionHistoryLimit: 3
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/name: adguard-home
  template:
    metadata:
      labels:
        app.kubernetes.io/name: adguard-home
    spec:
      serviceAccountName: default
      automountServiceAccountToken: true
      dnsPolicy: ClusterFirst
      enableServiceLinks: true
      initContainers:
        - command:
            - sh
            - -c
            - |
              if [ ! -f /opt/adguardhome/conf/AdGuardHome.yaml ]; then
                mkdir -p /opt/adguardhome/conf
                cp /tmp/AdGuardHome.yaml /opt/adguardhome/conf/AdGuardHome.yaml
              fi
          image: busybox
          imagePullPolicy: IfNotPresent
          name: copy-configmap
          securityContext:
            runAsUser: 0
          volumeMounts:
            - mountPath: /tmp/AdGuardHome.yaml
              name: adguard-home-config
              subPath: AdGuardHome.yaml
            - mountPath: /opt/adguardhome/conf
              name: config
      containers:
        - name: adguard-home
          image: "adguard/adguardhome:v0.107.7"
          imagePullPolicy: IfNotPresent
          args:

            - --config
            - /opt/adguardhome/conf/AdGuardHome.yaml
            - --work-dir
            - /opt/adguardhome/work
            - --no-check-update
          env:
            - name: "TZ"
              value: "Europe/Berlin"
          ports:
            - name: dns-tcp
              containerPort: 53
              protocol: TCP
            - name: dns-udp
              containerPort: 53
              protocol: UDP
            - name: http
              containerPort: 3000
              protocol: TCP
          volumeMounts:
            - name: adguard-home-config
              mountPath: /tmp/AdGuardHome.yaml
              subPath: AdGuardHome.yaml
            - name: config
              mountPath: /opt/adguardhome/conf
          livenessProbe:
            tcpSocket:
              port: 3000
            initialDelaySeconds: 0
            failureThreshold: 3
            timeoutSeconds: 1
            periodSeconds: 10
          readinessProbe:
            tcpSocket:
              port: 3000
            initialDelaySeconds: 0
            failureThreshold: 3
            timeoutSeconds: 1
            periodSeconds: 10
          startupProbe:
            tcpSocket:
              port: 3000
            initialDelaySeconds: 0
            failureThreshold: 30
            timeoutSeconds: 1
            periodSeconds: 5
      volumes:
        - name: adguard-home-config
          configMap:
            name: adguard-home-config
        - name: config
          persistentVolumeClaim:
            claimName: adguard-home-config
