MoJo2600 / pihole-kubernetes

PiHole on kubernetes
506 stars 178 forks source link

DHCP Range #163

Closed braucktoon closed 3 years ago

braucktoon commented 3 years ago

This is fantastic work. I am migrating my existing pihole from docker to k3s. One config I cannot find is the DHCP range. For example, I want only to give out addresses between .100 and .254 for example. Is this possible?

Thanks!

braucktoon commented 3 years ago

I should have also mentioned that I am not using persistent storage. I am trying to keep the config stateless.

MoJo2600 commented 3 years ago

Hello, there is currently no option in this helm chart to set the properties. But the properties are there on the docker container so it should be straight forward to enable this. It would be nice to have all DHCP options in the chart.

Right now I'm not able to implement this but if you'd like to create a merge request, I'm happy to integrate this feature.

Docker Environment Var. Description
DHCP_ACTIVE: <"true"\|"false">
Optional Default: "false"
Enable DHCP server. Static DHCP leases can be configured with a custom /etc/dnsmasq.d/04-pihole-static-dhcp.conf
DHCP_START: <Start IP>
Optional Default: Not Set
Start of the range of IP addresses to hand out by the DHCP server (mandatory if DHCP server is enabled).
DHCP_END: <End IP>
Optional Default: Not Set
End of the range of IP addresses to hand out by the DHCP server (mandatory if DHCP server is enabled).
DHCP_ROUTER: <Router's IP>
Optional Default: Not Set
Router (gateway) IP address sent by the DHCP server (mandatory if DHCP server is enabled).
DHCP_LEASETIME: <hours>
Optional Default: 24
DHCP lease time in hours.
PIHOLE_DOMAIN: <domain>
Optional Default: lan
Domain name sent by the DHCP server.
DHCP_IPv6: <"true"\|"false">
Optional Default: "false"
Enable DHCP server IPv6 support (SLAAC + RA).
DHCP_rapid_commit <"true"\|"false">
Optional Default: "false"
Enable DHCPv4 rapid commit (fast address assignment).

See: https://github.com/pi-hole/docker-pi-hole

braucktoon commented 3 years ago

Thank you Christian, I saw that link and that the properties are available in the container. So, I came to the same conclusion. I would love to contribute, I will see if I can find some time :-). Thanks for the confirmation.

braucktoon commented 3 years ago

@MoJo2600 after further inspection I see deployment.yaml has a provision for a list of extra env vars, extraEnvVars
I can specify the DHCP properties in values.yaml but the pod crashes. I can specify TZ in this list successfully. I can see the variables are being included in the pod but can’t seem to find an error anywhere. Do you think this should work? Perhaps there is a dependency I’m missing somewhere. Thanks.

MoJo2600 commented 3 years ago

Could you maybe just create a pull request with the things you did? I will then have a look at it.

braucktoon commented 3 years ago

I didn't make any code changes, my values file simply includes the extraEnvVars list of variables.

persistentVolumeClaim: enabled: false

serviceWeb: loadBalancerIP: 10.0.0.2 annotations: metallb.universe.tf/allow-shared-ip: pihole-svc type: LoadBalancer

serviceDns: loadBalancerIP: 10.0.0.2 annotations: metallb.universe.tf/allow-shared-ip: pihole-svc type: LoadBalancer

DNS1: "1.1.1.1" DNS2: "1.0.0.1"

extraEnvVars: TZ: "America/New_York" DHCP_ACTIVE: true DHCP_START: 10.0.0.75 DHCP_END: 10.0.0.200 DHCP_ROUTER: 10.0.0.1

adlists:

https://firebog.net - Sus lists

whitelist:

If you want to provide whitelisted domains, add them here.

blacklist:

If you want to have special domains blacklisted, add them here

- *.blackist.com

adminPassword: *****


helm dry-run shows this (snip):

containers:

Pihole log just sends a kill to all services (snip): [s6-finish] waiting for services. [s6-finish] sending all processes the TERM signal. [s6-finish] sending all processes the KILL signal and exiting.

MoJo2600 commented 3 years ago

OK, understood. I have to look into this :)

rodriguestiago0 commented 3 years ago

Hey, I specified the DCHP on the extraEnvVars and it worked without an issue.

extraEnvVars: 
  TZ: "Europe/Lisbon"
  ServerIP: 192.168.1.13
  DHCP_ACTIVE: true
  DHCP_START: 192.168.1.24
  DHCP_END: 192.168.1.199
  DHCP_ROUTER: 192.168.1.1
MoJo2600 commented 3 years ago

Thank you for testing @rodriguestiago0 - I will close this ticket, please reopen if it is not working for anyone else.

RossWilliamson commented 2 years ago

Just tried using the extraEnvVars and can confirm this does not work. Swapping between DHCP_ACTIVE true/false has no difference to pihole, nor does changing the range or router. Perhaps @rodriguestiago0 had default values in there already

EDIT: Works I think if you have privileged: true