---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: pihole
  labels:
    app: pihole
    release: pihole
spec:
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  selector:
    matchLabels:
      app: pihole
      release: pihole
  template:
    metadata:
      annotations:
        checksum.config.adlists: 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546
        checksum.config.blacklist: 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546
        checksum.config.regex: 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546
        checksum.config.whitelist: 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546
        checksum.config.dnsmasqConfig: ae1790f48ae96e3547fdea55324686c43e63d876837bfaeecf57045d535f701
      labels:
        app: pihole
        release: pihole
    spec:
      dnsPolicy: "None"
      dnsConfig:
        nameservers:
        - 127.0.0.1
        - 8.8.8.8
      hostNetwork: false
      containers:
        - name: cloudflared
          image: "crazymax/cloudflared:latest"
          imagePullPolicy: IfNotPresent
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          resources:
            limits:
              memory: 128Mi
          ports:
            - containerPort: 5053
              name: cloudflared-udp
              protocol: UDP
        - name: pihole
          env:
          - name: 'WEB_PORT'
            value: "80"
          - name: VIRTUAL_HOST
            value: pi.hole
          - name: WEBPASSWORD
            valueFrom:
              secretKeyRef:
                key: password
                name: pihole-password
          - name: 'DNS1'
            value: "127.0.0.1#5053"
          - name: 'DNS2'
            value: "127.0.0.1#5053"
          image: "pihole/pihole:v5.0"
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: false
          ports:
          - containerPort: 80
            name: http
            protocol: TCP
          - containerPort: 53
            name: dns
            protocol: TCP
          - containerPort: 53
            name: dns-udp
            protocol: UDP
          - containerPort:  443
            name: https
            protocol: TCP
          - containerPort: 67
            name: client-udp
            protocol: UDP
          livenessProbe:
            httpGet:
              path: /admin.index.php
              port: http
            initialDelaySeconds: 60
            failureThreshold: 10
            timeoutSeconds: 5
          readinessProbe:
            httpGet:
              path: /admin.index.php
              port: http
            initialDelaySeconds: 60
            failureThreshold: 3
            timeoutSeconds: 5
          volumeMounts:
          - mountPath: /etc/pihole
            name: config
          - mountPath: /etc/dnsmasq.d/02-custom.conf
            name: custom-dnsmasq
            subPath: 02-custom.conf
          - mountPath: /etc/addn-hosts
            name: custom-dnsmasq
            subPath: addn-hosts
          resources:
            {}
      volumes:
      - name: config
        persistentVolumeClaim:
          claimName: pihole
      - configMap:
          defaultMode: 420
          name: pihole-custom-dnsmasq
        name: custom-dnsmasq
