Self-Hosted Pihole on Kubernetes for a DNS server & Ads Blocker
The Pi-hole® is a DNS sinkhole that protects your devices from unwanted content without installing any client-side software.
Preqre
- Helm
- Kubernetes cluster, my homelab is using k3s-cluster.
Installation
We will use mojo2600/pihole helm repo in ArtifactHub
helm add repo.
1
2
helm repo add mojo2600 https://mojo2600.github.io/pihole-kubernetes/
helm repo update
get the values.yml of mojo2600/pihole and configure it first.
1
helm show values mojo2600/pihole > values.yml
Values.yml
I changed the DNS and https type to LoadBalancer
and set the loadBalancerIP: '10.0.50.77'
, cause I’m using metallb service.
And configure the storageClass: 'longhorn'
and the adminPassword
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
serviceDns:
type: LoadBalancer
port: 53
loadBalancerIP: "10.0.50.77"
annotations:
metallb.universe.tf/allow-shared-ip: pihole-svc
serviceWeb:
http:
enabled: true
port: 80
https:
enabled: true
port: 443
type: LoadBalancer
loadBalancerIP: 10.0.50.77
annotations:
metallb.universe.tf/allow-shared-ip: pihole-svc
persistentVolumeClaim:
enabled: true
accessModes:
- ReadWriteOnce
size: "2Gi"
storageClass: "longhorn"
adminPassword: "P@ssw0rd"
extraEnvVars:
TZ: Asia/Hong_Kong
DNS1: "1.1.1.1"
DNS2: "8.8.8.8"
podDnsConfig:
enabled: true
policy: "None"
nameservers:
- 127.0.0.1
- 1.1.1.1
Helm Install
1
helm install pihole mojo2600/pihole -n pihole --create-namespaces -f values.yml
Web UI
access http://10.0.50.77/admin
update the ads block list first
you can setup your dns records as your local network dns server
then bind your devices dns to pihole, you will see the traffice display on dashboard.
This post is licensed under CC BY 4.0 by the author.