apiVersion: apps/v1
kind: Deployment
metadata:
  name: pihole
  labels:
    app: pihole
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pihole
  template:
    metadata:
      labels:
        app: pihole
        name: pihole
    spec:
      securityContext:
        fsGroup: 2000
      containers:
      - name: pihole
        image: pihole/pihole:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
          name: pihole-http
          protocol: TCP
        - containerPort: 53
          name: pihole-dns
          protocol: TCP
        - containerPort: 53
          name: pihole-dns-udp
          protocol: UDP
        - containerPort: 443
          name: pihole-ssl
          protocol: TCP
        - containerPort: 67
          name: client-udp
          protocol: UDP
        env:
        - name: TZ
          value: "Europe/Rome" 
        - name: WEBPASSWORD
          valueFrom:
            secretKeyRef:
              name: pihole-pass
              key: password
        volumeMounts:
        - name: data-volume
          mountPath: /etc/pihole
          subPath: etc_pihole
        - name: data-volume
          mountPath: /etc/dnsmasq.d
          subPath: etc_dnsmasq.d
      volumes:
      - name: data-volume
        persistentVolumeClaim:
          claimName: pvc-pihole