---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: pihole
  namespace: pihole
  labels:
    app: pihole
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pihole
  template:
    metadata:
      labels:
        app: pihole
    spec:
      containers:
        - name: pihole
          image: pihole/pihole:latest
          imagePullPolicy: Always
          ports:

            - containerPort: 53
              name: dns-tcp
              protocol: TCP

            - containerPort: 53
              name: dns-udp
              protocol: UDP

            - containerPort: 67
              name: client-udp
              protocol: UDP

            - containerPort: 80
              name: http
              protocol: TCP

          env:
            - name: TZ
              value: Africa/Johannaesburg
            - name: VIRTUAL_HOST
              value: pihole.lan
            - name: PIHOLE_DNS
              value: 192.168.1.1
            - name: REV_SERVER
              value: "true"
            - name: REV_SERVER_DOMAIN
              value: lan
            - name: REV_SERVER_CIDR
              value: 192.168.1.0/24
            - name: REV_SERVER_TARGET
              value: 192.168.1.1
            - name: WEBPASSWORD
              valueFrom:
                secretKeyRef:
                  name: pihole
                  key: password

          resources:
            limits:
              cpu: 200m
              memory: 250Mi
            requests:
              cpu: 100m
              memory: 128Mi

          volumeMounts:
            - mountPath: /etc/pihole/
              name: pihole
            - mountPath: /etc/dnsmasq.d/
              name: dnsmasq
      volumes:
        - name: pihole
          hostPath:
            type: Directory
            path: /home/docker/pihole/etc/pihole/
        - name: dnsmasq
          hostPath:
            type: Directory
            path: /home/docker/pihole/etc/dnsmasq.d/
