Code Monkey home page Code Monkey logo

pihole-k8-public's Introduction

Pihole K8 Public

Pihole is awesome. It will greatly reduce the amount of "ad spam" and tracking while using the Internet. But all those DNS requests are not private and can be intercepted.

This project will setup pihole to use DNS over HTTPS (DoH) along with a default ad blocking list (~800K domains blocked). This will keep your DNS requests private from your ISP and prevent them from doing "ISP Shenanigans" such as tracking what you do and selling that info to other companies, injecting ads, etc.

Getting Started

Prerequisites

For microk8s, make sure the following add-ons are enabled:

  • dns
  • ingress
  • metallb

MetalLb is a load balancer that allows us to assign a fixed ip address "in front of" our k8 pods. K8 will handle the mapping to the proper node (for clusters) and pod. We just use the assigned load balancer ip.

Follow the tutorial and make note of whatever ip address pool you assign to metallb. It should be an unused range on your network (i.e. outside of any DHCP scope or other statically assigned addresses.)

Microk8s - Single Host or Cluster?

You can install microk8s on a single computer ("host.") You will get all the k8 benefits such as pod lifecycle management, host resource management, etc.

The various setup files will still work, you'll just lose out on any "high availability" (HA) benefits, such as if the single host barfs, pihole will stop working. In a k8 cluster/HA scenario, the pihole workload would get moved to another host in the cluster.

https://microk8s.io/docs/addon-metallb

Installing

Best practice is to use K8 namespaces to segment up your cluster resources. Our first step is to create our pihole namespace

kubectl apply -f pihole-namespace.yml

When the pod hosting our pihole container is running it will need disk storage. My k8 is setup to use a NFS server for storage. If you are using host-path or just want ephemeral storage, edit the file and replace nfs-csi with "" (a quoted empty string)

kubectl apply -f pihole-pvc-pihole.yml
kubectl apply -f pihole-pvc-dnsmasq.yml

Pihole uses two files:

  1. adlists.list is used during the very first bootstrapping to populate the gravity database with the domains to blacklist.
  2. custom.list is used for local dns entries. For instance, if you get tired of remembering various ip addresses on your network, you can make an entry in this file to map the ip address to a fully-qualified-domain-name.

We are going to use a k8 feature called a ConfigMap. Later, we will "volumeMount" these configMaps into the pod's filesystem. Run the helper scripts. If you get an error about not finding the kubectl command, just copy the command from the script file and run in your terminal window.

install-k8-adlists-list.sh
install-k8-custom-list.sh

This step creates a "deployment." We're gonna spin up two containers in the pod:

  1. Cloudflared - this creates our HTTPs tunnel to the CloudFlare 1.1.1.1 DNS servers
  2. Pihole - this will become our network DNS server

Because both of these containers live in a pod, we can share address space.
The pihole environment variable DNS points to 127.0.0.1#5053 which is the port we've setup Cloudflared to use.

kubectl apply -f pihole-deployment.yaml

If your deployment step was successful, pihole should be running

kubectl get pod -n pihole

The last step is to create a service to allow the outside world to interact/connect to our pihole pod. Pihole will be used as the DNS server for your network, so it's important to use a static/fixed ip address. Select an available ip address in your metallb load balancer address space. Then edit this file and replace the xxx.xxx.xxx.xxx with the correct ip address.

kubectl apply -f pihole-service.yml

If the service installed successfully, you should be able to login to your pihole instance using the loadbalancer ip address you selected in the previous step. The default password is 'nojunk' (set in the pihole-deployment.yml file) http://xxx.xxx.xxx.xxx/admin

Built With

  • MicroK8s - Used as the kubernetes cluster software
  • Raspberry Pi - Use as the compute host infrastructure
  • Pi-hole - Network wide ad blocking

pihole-k8-public's People

Contributors

sean-foley avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.