Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pihole): support v5 and v6 #5203

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3604f2d
:construction: Init commit
tJouve Feb 23, 2025
5ccd2d3
Select the correct client imp
tJouve Feb 23, 2025
5eae8a9
Impl list record + Auth and retry
tJouve Feb 23, 2025
5936c53
Add and remove impl
tJouve Feb 26, 2025
e1579bd
Fixing tests and a small logic error
Feb 27, 2025
3970fbb
Removed unnecessary comments
Feb 27, 2025
9c9c114
Fixed TestListRecordsV6 test
Feb 27, 2025
a583e09
Fixed TestListRecordsV6 test some more
Feb 27, 2025
d3800d5
Fixed TestCreateRecordV6 and TestDeleteRecordV6
Feb 27, 2025
698d8ea
Add PiholeApiVersion param
tJouve Feb 27, 2025
a6de9b5
Merge pull request #1 from divStar/feat/piholev6
tJouve Feb 27, 2025
6a4d847
Add PiholeApiVersion param
tJouve Mar 2, 2025
27c24c0
Merge pull request #4 from tJouve/fix/flags
tJouve Mar 2, 2025
08c1eb3
Update Documentation
tJouve Mar 20, 2025
ffc1b11
Merge pull request #5 from tJouve/fix/flags
tJouve Mar 20, 2025
e11ba60
:construction: Init commit
tJouve Feb 23, 2025
5d52048
Select the correct client imp
tJouve Feb 23, 2025
b233c82
Impl list record + Auth and retry
tJouve Feb 23, 2025
90764c3
Add and remove impl
tJouve Feb 26, 2025
bf843ac
Add PiholeApiVersion param
tJouve Feb 27, 2025
eb16427
Fixing tests and a small logic error
Feb 27, 2025
15b5833
Removed unnecessary comments
Feb 27, 2025
6e43134
Fixed TestListRecordsV6 test
Feb 27, 2025
b71f4e3
Fixed TestListRecordsV6 test some more
Feb 27, 2025
e58d62c
Fixed TestCreateRecordV6 and TestDeleteRecordV6
Feb 27, 2025
f76efac
Add PiholeApiVersion param
tJouve Mar 2, 2025
941fbca
Update Documentation
tJouve Mar 20, 2025
6998527
Merge remote-tracking branch 'origin/feat/piholev6' into feat/piholev6
tJouve Mar 20, 2025
77b0ad3
Apply suggestions from code review
tJouve Mar 20, 2025
629768a
Add deprecation notice for PiHole V5
tJouve Mar 20, 2025
20aae28
Fix spacing and Lintmarkdown job
tJouve Mar 20, 2025
e79cce9
Update provider/pihole/clientV6_test.go
tJouve Mar 20, 2025
b7c0a39
Fix Lintmarkdown job
tJouve Mar 21, 2025
cfe03f5
Fix golangci-lint Redundant break statements
tJouve Mar 21, 2025
3caa451
Fix unit test on types
tJouve Mar 21, 2025
6e8c29d
Merge remote-tracking branch 'origin/feat/piholev6' into feat/piholev6
tJouve Mar 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
| `--pihole-server=""` | When using the Pihole provider, the base URL of the Pihole web server (required when --provider=pihole) |
| `--pihole-password=""` | When using the Pihole provider, the password to the server if it is protected |
| `--[no-]pihole-tls-skip-verify` | When using the Pihole provider, disable verification of any TLS certificates |
| `--pihole-api-version="5"` | When using the Pihole provider, specify the pihole API version |
| `--plural-cluster=""` | When using the plural provider, specify the cluster name you're running with |
| `--plural-provider=""` | When using the plural provider, specify the provider name you're running with |
| `--policy=sync` | Modify how DNS records are synchronized between sources and providers (default: sync, options: sync, upsert-only, create-only) |
Expand Down
11 changes: 9 additions & 2 deletions docs/tutorials/pihole.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ There is a pseudo-API exposed that ExternalDNS is able to use to manage these re

__NOTE:__ Your Pi-hole must be running [version 5.9 or newer](https://pi-hole.net/blog/2022/02/12/pi-hole-ftl-v5-14-web-v5-11-and-core-v5-9-released).

__NOTE:__ Provider for Pi-hole version prior to 6.0 is now deprecated and will be removed in future release.

__NOTE:__ Since Pi-hole version 6, you should use the flag *--pihole-api-version=6*

## Deploy ExternalDNS

You can skip to the [manifest](#externaldns-manifest) if authentication is disabled on your Pi-hole instance or you don't want to use secrets.

If your Pi-hole server's admin dashboard is protected by a password, you'll likely want to create a secret first containing its value.
This is optional since you _do_ retain the option to pass it as a flag with `--pihole-password`.
This is optional since you *do* retain the option to pass it as a flag with `--pihole-password`.

You can create the secret with:

Expand Down Expand Up @@ -98,6 +102,8 @@ spec:
# the policy to upsert-only so they do not get deleted.
- --policy=upsert-only
- --provider=pihole
# Switch to pihole V6 API
- --pihole-api-version=6
# Change this to the actual address of your Pi-hole web server
- --pihole-server=http://pihole-web.pihole.svc.cluster.local
securityContext:
Expand All @@ -109,6 +115,7 @@ spec:
- `--pihole-server (env: EXTERNAL_DNS_PIHOLE_SERVER)` - The address of the Pi-hole web server
- `--pihole-password (env: EXTERNAL_DNS_PIHOLE_PASSWORD)` - The password to the Pi-hole web server (if enabled)
- `--pihole-tls-skip-verify (env: EXTERNAL_DNS_PIHOLE_TLS_SKIP_VERIFY)` - Skip verification of any TLS certificates served by the Pi-hole web server.
- `--pihole-api-version (env: EXTERNAL_DNS_PIHOLE_API_VERSION)` - Specify the pihole API version (default is 5. Eligible values are 5 or 6).

## Verify ExternalDNS Works

Expand Down Expand Up @@ -181,7 +188,7 @@ spec:

You can then query your Pi-hole to see if the record was created.

_Change `@192.168.100.2` to the actual address of your DNS server_
Change *@192.168.100.2* to the actual address of your DNS server

```bash
$ dig +short @192.168.100.2 nginx.external-dns-test.homelab.com
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ func main() {
TLSInsecureSkipVerify: cfg.PiholeTLSInsecureSkipVerify,
DomainFilter: domainFilter,
DryRun: cfg.DryRun,
APIVersion: cfg.PiholeApiVersion,
},
)
case "ibmcloud":
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/externaldns/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ type Config struct {
PiholeServer string
PiholePassword string `secure:"yes"`
PiholeTLSInsecureSkipVerify bool
PiholeApiVersion string
PluralCluster string
PluralProvider string
WebhookProviderURL string
Expand Down Expand Up @@ -368,6 +369,7 @@ var defaultConfig = &Config{
PiholeServer: "",
PiholePassword: "",
PiholeTLSInsecureSkipVerify: false,
PiholeApiVersion: "5",
PluralCluster: "",
PluralProvider: "",
WebhookProviderURL: "http://localhost:8888",
Expand Down Expand Up @@ -602,6 +604,7 @@ func App(cfg *Config) *kingpin.Application {
app.Flag("pihole-server", "When using the Pihole provider, the base URL of the Pihole web server (required when --provider=pihole)").Default(defaultConfig.PiholeServer).StringVar(&cfg.PiholeServer)
app.Flag("pihole-password", "When using the Pihole provider, the password to the server if it is protected").Default(defaultConfig.PiholePassword).StringVar(&cfg.PiholePassword)
app.Flag("pihole-tls-skip-verify", "When using the Pihole provider, disable verification of any TLS certificates").BoolVar(&cfg.PiholeTLSInsecureSkipVerify)
app.Flag("pihole-api-version", "When using the Pihole provider, specify the pihole API version").Default(defaultConfig.PiholeApiVersion).StringVar(&cfg.PiholeApiVersion)

// Flags related to the Plural provider
app.Flag("plural-cluster", "When using the plural provider, specify the cluster name you're running with").Default(defaultConfig.PluralCluster).StringVar(&cfg.PluralCluster)
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/externaldns/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ var (
IBMCloudConfigFile: "/etc/kubernetes/ibmcloud.json",
TencentCloudConfigFile: "/etc/kubernetes/tencent-cloud.json",
TencentCloudZoneType: "",
PiholeApiVersion: "5",
WebhookProviderURL: "http://localhost:8888",
WebhookProviderReadTimeout: 5 * time.Second,
WebhookProviderWriteTimeout: 10 * time.Second,
Expand Down Expand Up @@ -242,6 +243,7 @@ var (
IBMCloudConfigFile: "ibmcloud.json",
TencentCloudConfigFile: "tencent-cloud.json",
TencentCloudZoneType: "private",
PiholeApiVersion: "6",
WebhookProviderURL: "http://localhost:8888",
WebhookProviderReadTimeout: 5 * time.Second,
WebhookProviderWriteTimeout: 10 * time.Second,
Expand Down Expand Up @@ -352,6 +354,7 @@ func TestParseFlags(t *testing.T) {
"--aws-sd-create-tag=key1=value1",
"--aws-sd-create-tag=key2=value2",
"--no-aws-evaluate-target-health",
"--pihole-api-version=6",
"--policy=upsert-only",
"--registry=noop",
"--txt-owner-id=owner-1",
Expand Down Expand Up @@ -474,6 +477,7 @@ func TestParseFlags(t *testing.T) {
"EXTERNAL_DNS_AWS_SD_SERVICE_CLEANUP": "true",
"EXTERNAL_DNS_AWS_SD_CREATE_TAG": "key1=value1\nkey2=value2",
"EXTERNAL_DNS_DYNAMODB_TABLE": "custom-table",
"EXTERNAL_DNS_PIHOLE_API_VERSION": "6",
"EXTERNAL_DNS_POLICY": "upsert-only",
"EXTERNAL_DNS_REGISTRY": "noop",
"EXTERNAL_DNS_TXT_OWNER_ID": "owner-1",
Expand Down
Loading
Loading