Skip to content

Commit ce3ef92

Browse files
committed
update README, group name and add test logging
1 parent 420adde commit ce3ef92

File tree

5 files changed

+100
-12
lines changed

5 files changed

+100
-12
lines changed

README.md

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ The default configuration of ExternalDNS needs altering for this integration to
1717
If you are deploying with the [official Helm chart](https://artifacthub.io/packages/helm/external-dns/external-dns) you can accomplish this by including this in your values file:
1818

1919
```yaml
20-
extraArgs:
21-
- --managed-record-types=A #
22-
- --managed-record-types=AAAA # ├ Default values
23-
- --managed-record-types=CNAME #
24-
- --managed-record-types=TXT # ─ New value
20+
managedRecordTypes:
21+
- A #
22+
- AAAA # ├ Default values
23+
- CNAME #
24+
- TXT # ─ New value
2525

2626
sources:
2727
- service # ┬ Default values
@@ -35,7 +35,72 @@ Any supported version of cert-manager supports DNS webhooks, for documentation o
3535
3636
## Installing
3737
38-
TODO
38+
### Using Helm
39+
40+
The webhook can be installed using Helm:
41+
42+
```bash
43+
# Add the repository
44+
helm repo add cert-manager-webhook-external-dns oci://ghcr.io/lion7/cert-manager-webhook-external-dns
45+
46+
# Install the webhook
47+
helm install cert-manager-webhook-external-dns \
48+
cert-manager-webhook-external-dns/cert-manager-webhook-external-dns \
49+
--namespace cert-manager \
50+
--create-namespace
51+
```
52+
53+
### Using OCI Registry
54+
55+
You can also install directly from the OCI registry:
56+
57+
```bash
58+
helm install cert-manager-webhook-external-dns \
59+
oci://ghcr.io/lion7/cert-manager-webhook-external-dns \
60+
--namespace cert-manager \
61+
--create-namespace
62+
```
63+
64+
### Configuration
65+
66+
The default values should work for most installations. You can customize the installation by creating a values file:
67+
68+
```yaml
69+
# values.yaml
70+
image:
71+
repository: ghcr.io/lion7/cert-manager-webhook-external-dns
72+
tag: latest
73+
pullPolicy: IfNotPresent
74+
75+
replicaCount: 1
76+
77+
resources:
78+
limits:
79+
cpu: 100m
80+
memory: 128Mi
81+
requests:
82+
cpu: 100m
83+
memory: 128Mi
84+
85+
# Webhook configuration
86+
webhook:
87+
port: 8443
88+
89+
# cert-manager configuration
90+
certManager:
91+
namespace: cert-manager
92+
serviceAccountName: cert-manager
93+
```
94+
95+
Then install with:
96+
97+
```bash
98+
helm install cert-manager-webhook-external-dns \
99+
oci://ghcr.io/lion7/cert-manager-webhook-external-dns \
100+
--namespace cert-manager \
101+
--create-namespace \
102+
-f values.yaml
103+
```
39104

40105
## Usage
41106

@@ -52,7 +117,7 @@ spec:
52117
solvers:
53118
- dns01:
54119
webhook:
55-
groupName: external-dns.acme.cert-manager.io
120+
groupName: cert-manager-webhook.lion7.dev
56121
solverName: external-dns
57122
```
58123

deploy/external-dns-webhook/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# The name will need to be referenced in each Issuer's `webhook` stanza to
99
# inform cert-manager of where to send ChallengePayload resources in order to
1010
# solve the DNS01 challenge.
11-
groupName: external-dns.acme.cert-manager.io
11+
groupName: cert-manager-webhook.lion7.dev
1212

1313
replicaCount: 1
1414

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var (
3030

3131
// GroupName is the Kubernetes group name that will be forwarded to this
3232
// extension-apiserver.
33-
GroupName = "external-dns.acme.cert-manager.io"
33+
GroupName = "cert-manager-webhook.lion7.dev"
3434

3535
// RequestTimeout is the timeout for each request
3636
RequestTimeout = time.Second * 5

testing/registry.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package testing
33
import (
44
"context"
55
"fmt"
6+
"log"
67
"strings"
78
"sync"
89
"testing"
@@ -28,6 +29,8 @@ func NewTestRegistry(t *testing.T, addr string, domains ...string) *Registry {
2829
records: make(map[endpoint.EndpointKey]*endpoint.Endpoint),
2930
}
3031

32+
log.Printf("[TEST REGISTRY] Starting DNS server on %s for domains: %v", addr, domains)
33+
3134
server := &dns.Server{
3235
Addr: addr,
3336
Net: "udp",
@@ -39,6 +42,7 @@ func NewTestRegistry(t *testing.T, addr string, domains ...string) *Registry {
3942
}()
4043

4144
t.Cleanup(func() {
45+
log.Printf("[TEST REGISTRY] Shutting down DNS server")
4246
_ = server.Shutdown()
4347
})
4448

@@ -54,22 +58,33 @@ func (r *Registry) Records(ctx context.Context) ([]*endpoint.Endpoint, error) {
5458
records = append(records, record.DeepCopy())
5559
}
5660

61+
log.Printf("[TEST REGISTRY] Records() returning %d records", len(records))
62+
for _, record := range records {
63+
log.Printf("[TEST REGISTRY] - %s %s %v", record.DNSName, record.RecordType, record.Targets)
64+
}
65+
5766
return records, nil
5867
}
5968

6069
func (r *Registry) ApplyChanges(ctx context.Context, changes *plan.Changes) error {
6170
r.mu.Lock()
6271
defer r.mu.Unlock()
6372

73+
log.Printf("[TEST REGISTRY] ApplyChanges() - Create: %d, Update: %d, Delete: %d",
74+
len(changes.Create), len(changes.UpdateNew), len(changes.Delete))
75+
6476
for _, change := range changes.Create {
77+
log.Printf("[TEST REGISTRY] CREATE: %s %s %v", change.DNSName, change.RecordType, change.Targets)
6578
r.records[change.Key()] = change.DeepCopy()
6679
}
6780

6881
for _, change := range changes.UpdateNew {
82+
log.Printf("[TEST REGISTRY] UPDATE: %s %s %v", change.DNSName, change.RecordType, change.Targets)
6983
r.records[change.Key()] = change.DeepCopy()
7084
}
7185

7286
for _, change := range changes.Delete {
87+
log.Printf("[TEST REGISTRY] DELETE: %s %s %v", change.DNSName, change.RecordType, change.Targets)
7388
delete(r.records, change.Key())
7489
}
7590

@@ -103,9 +118,12 @@ func (r *Registry) handleDNSRequest(w dns.ResponseWriter, req *dns.Msg) {
103118
}
104119

105120
func (r *Registry) addDNSAnswer(q dns.Question, msg *dns.Msg, req *dns.Msg) error {
121+
log.Printf("[TEST REGISTRY] DNS Query: %s %s", q.Name, dns.TypeToString[q.Qtype])
122+
106123
switch q.Qtype {
107124
// Always return loopback for any A query
108125
case dns.TypeA:
126+
log.Printf("[TEST REGISTRY] A record query for %s, returning 127.0.0.1", q.Name)
109127
rr, err := dns.NewRR(fmt.Sprintf("%s 5 IN A 127.0.0.1", q.Name))
110128
if err != nil {
111129
return err
@@ -121,8 +139,12 @@ func (r *Registry) addDNSAnswer(q dns.Question, msg *dns.Msg, req *dns.Msg) erro
121139
}
122140

123141
found := false
142+
queryName := strings.TrimSuffix(q.Name, ".")
143+
log.Printf("[TEST REGISTRY] TXT record query for %s", queryName)
144+
124145
for _, record := range records {
125-
if record.DNSName == strings.TrimSuffix(q.Name, ".") && record.RecordType == endpoint.RecordTypeTXT {
146+
if record.DNSName == queryName && record.RecordType == endpoint.RecordTypeTXT {
147+
log.Printf("[TEST REGISTRY] Found matching record: %s -> %v", record.DNSName, record.Targets)
126148
for _, target := range record.Targets {
127149
rr, err := dns.NewRR(fmt.Sprintf("%s 5 IN TXT %s", q.Name, target))
128150
if err != nil {
@@ -136,6 +158,7 @@ func (r *Registry) addDNSAnswer(q dns.Question, msg *dns.Msg, req *dns.Msg) erro
136158
}
137159

138160
if !found {
161+
log.Printf("[TEST REGISTRY] No TXT record found for %s, returning NXDOMAIN", queryName)
139162
msg.SetRcode(req, dns.RcodeNameError)
140163
return nil
141164
}

testing/solver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ func (s *Solver) Initialize(config *rest.Config, stopCh <-chan struct{}) error {
6969
}
7070

7171
// Create source for new config
72-
source, err := source.NewCRDSource(restClient, "", "DNSEndpoint", "", labels.Everything(), runtimeScheme, false)
72+
crdSource, err := source.NewCRDSource(restClient, "", "DNSEndpoint", "", labels.Everything(), runtimeScheme, false)
7373
if err != nil {
7474
return err
7575
}
7676

7777
// Setup the external-dns controller
7878
externalDNS := controller.Controller{
79-
Source: source,
79+
Source: crdSource,
8080
Registry: s.Registry,
8181
Policy: &plan.SyncPolicy{},
8282
DomainFilter: s.Registry.domains,

0 commit comments

Comments
 (0)