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

Configurable DNS servers #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion deploy/cert-manager-webhook-ns1/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v1
appVersion: "v0.1.0"
description: NS1 Webhook for Cert Manager
name: cert-manager-webhook-ns1
version: 0.4.2
version: 0.4.3
4 changes: 4 additions & 0 deletions deploy/cert-manager-webhook-ns1/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ spec:
env:
- name: GROUP_NAME
value: {{ .Values.groupName | quote }}
{{- if .Values.nameservers }}
- name: NAMESERVERS
value: {{ join "," .Values.nameservers }}
{{- end }}
ports:
- name: https
containerPort: {{ .Values.containerPort }}
Expand Down
7 changes: 7 additions & 0 deletions deploy/cert-manager-webhook-ns1/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
# Users should not generally need to edit the groupName.
groupName: acme.nsone.net

# Nameservers is used to force the webhook to use specific name servers.
# This is useful when you have a split DNS service that might return
# SOA records internally that don't exist in NSOne.
nameservers:
#- 8.8.8.8:53
#- 1.1.1.1:53

certManager:
namespace: cert-manager
serviceAccountName: cert-manager
Expand Down
13 changes: 10 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@ import (
)

var groupName = os.Getenv("GROUP_NAME")
var nameservers []string

func main() {
if groupName == "" {
panic("GROUP_NAME must be specified")
}

if os.Getenv("NAMESERVERS") != "" {
nameservers = strings.Split(os.Getenv("NAMESERVERS"), ",")
} else {
nameservers = util.RecursiveNameservers
}

// This will register our NS1 DNS provider with the webhook serving
// library, making it available as an API under the provided groupName.
cmd.RunWebhookServer(groupName,
Expand Down Expand Up @@ -98,7 +105,7 @@ func (c *ns1DNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error {

_, err = c.ns1Client.Records.Create(record)
if err != nil {
if err != ns1API.ErrRecordExists {
if err != ns1API.ErrRecordExists {
return err
}
}
Expand Down Expand Up @@ -227,13 +234,13 @@ func (c *ns1DNSProviderSolver) parseChallenge(ch *v1alpha1.ChallengeRequest) (
) {

if zone, err = util.FindZoneByFqdn(
ch.ResolvedFQDN, util.RecursiveNameservers,
ch.ResolvedFQDN, nameservers,
); err != nil {
return "", "", err
}
zone = util.UnFqdn(zone)

if idx := strings.Index(ch.ResolvedFQDN, "." + ch.ResolvedZone); idx != -1 {
if idx := strings.Index(ch.ResolvedFQDN, "."+ch.ResolvedZone); idx != -1 {
domain = ch.ResolvedFQDN[:idx]
} else {
domain = util.UnFqdn(ch.ResolvedFQDN)
Expand Down