From 6aee54cdaf20587fa5b82534ff636e436e5bf29e Mon Sep 17 00:00:00 2001 From: boarder981 <30509979+boarder981@users.noreply.github.com> Date: Fri, 12 Jul 2019 11:29:06 -0400 Subject: [PATCH] Add support for PowerDNS to external-dns chart (#14793) - Add pdns-specific parameters to stable/external-dns/values.yaml - Modify stable/external-dns/templates/secret.yaml to support pdns API key as kubernetes secret - Modify stable/external-dns/templates/deployment.yaml to support args and environment variables for pdns Signed-off-by: Craig Etienne --- stable/external-dns/Chart.yaml | 2 +- stable/external-dns/README.md | 3 +++ stable/external-dns/templates/_helpers.tpl | 26 +++++++++++++++++++ stable/external-dns/templates/deployment.yaml | 13 ++++++++++ stable/external-dns/templates/secret.yaml | 5 +++- stable/external-dns/values-production.yaml | 7 +++++ stable/external-dns/values.yaml | 7 +++++ 7 files changed, 61 insertions(+), 2 deletions(-) diff --git a/stable/external-dns/Chart.yaml b/stable/external-dns/Chart.yaml index 3490f99171..8322251256 100644 --- a/stable/external-dns/Chart.yaml +++ b/stable/external-dns/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: external-dns -version: 2.2.3 +version: 2.3.0 appVersion: 0.5.15 description: ExternalDNS is a Kubernetes addon that configures public DNS servers with information about exposed Kubernetes services to make them discoverable. keywords: diff --git a/stable/external-dns/README.md b/stable/external-dns/README.md index cbb0fd5b36..09ba113a66 100644 --- a/stable/external-dns/README.md +++ b/stable/external-dns/README.md @@ -95,6 +95,9 @@ The following table lists the configurable parameters of the external-dns chart | `rfc2136.tsigKeyname` | When using the rfc2136 provider, specify the tsig keyname to enable security (optional) | `"externaldns-key"` | | `rfc2136.tsigSecretAlg` | When using the rfc2136 provider, specify the tsig secret to enable security (optional) | `"hmac-sha256"` | | `rfc2136.tsigAxfr` | When using the rfc2136 provider, enable AFXR to enable security (optional) | `true` | +| `pdns.apiUrl` | When using the PowerDNS provider, specify the API URL of the server. | `""` | +| `pdns.apiPort` | When using the PowerDNS provider, specify the API port of the server. | `8081` | +| `pdns.apiKey` | When using the PowerDNS provider, specify the API key of the server. | `""` | | `annotationFilter` | Filter sources managed by external-dns via annotation using label selector (optional) | `""` | | `domainFilters` | Limit possible target zones by domain suffixes (optional) | `[]` | | `zoneIdFilters` | Limit possible target zones by zone id (optional) | `[]` | diff --git a/stable/external-dns/templates/_helpers.tpl b/stable/external-dns/templates/_helpers.tpl index 15519eb8cd..c3f2e61d88 100644 --- a/stable/external-dns/templates/_helpers.tpl +++ b/stable/external-dns/templates/_helpers.tpl @@ -130,6 +130,8 @@ Compile all warnings into a single message, and call fail. {{- $messages := append $messages (include "external-dns.validateValues.aws" .) -}} {{- $messages := append $messages (include "external-dns.validateValues.infoblox.gridHost" .) -}} {{- $messages := append $messages (include "external-dns.validateValues.infoblox.wapiPassword" .) -}} +{{- $messages := append $messages (include "external-dns.validateValues.pdns.apiUrl" .) -}} +{{- $messages := append $messages (include "external-dns.validateValues.pdns.apiKey" .) -}} {{- $messages := without $messages "" -}} {{- $message := join "\n" $messages -}} @@ -201,6 +203,30 @@ external-dns: infoblox.wapiPassword {{- end -}} {{- end -}} +{{/* +Validate values of External DNS: +- must provide the PowerDNS API URL when provider is "pdns" +*/}} +{{- define "external-dns.validateValues.pdns.apiUrl" -}} +{{- if and (eq .Values.provider "pdns") (not .Values.pdns.apiUrl) -}} +external-dns: pdns.apiUrl + You must provide the the PowerDNS API URL when provider="pdns". + Please set the apiUrl parameter (--set pdns.apiUrl="xxxx") +{{- end -}} +{{- end -}} + +{{/* +Validate values of External DNS: +- must provide the PowerDNS API key when provider is "pdns" +*/}} +{{- define "external-dns.validateValues.pdns.apiKey" -}} +{{- if and (eq .Values.provider "pdns") (not .Values.pdns.apiKey) -}} +external-dns: pdns.apiKey + You must provide the the PowerDNS API key when provider="pdns". + Please set the apiKey parameter (--set pdns.apiKey="xxxx") +{{- end -}} +{{- end -}} + {{/* Check if there are rolling tags in the images */}} {{- define "external-dns.checkRollingTags" -}} {{- if and (contains "bitnami/" .Values.image.repository) (not (.Values.image.tag | toString | regexFind "-r\\d+$|sha256:")) }} diff --git a/stable/external-dns/templates/deployment.yaml b/stable/external-dns/templates/deployment.yaml index db01a014bc..861d32d261 100755 --- a/stable/external-dns/templates/deployment.yaml +++ b/stable/external-dns/templates/deployment.yaml @@ -152,6 +152,11 @@ spec: - --rfc2136-insecure {{- end }} {{- end }} + # PowerDNS arguments + {{- if eq .Values.provider "pdns" }} + - --pdns-server={{ .Values.pdns.apiUrl }}:{{ .Values.pdns.apiPort }} + - --pdns-api-key=$(PDNS_API_KEY) + {{- end }} # Extra arguments {{- range $key, $value := .Values.extraArgs }} {{- if $value }} @@ -236,6 +241,14 @@ spec: - name: OPENSTACK_CA_FILE value: {{ .Values.designate.customCA.mountPath }}/{{ .Values.designate.customCA.filename }} {{- end }} + # PowerDNS environment variables + {{- if and (eq .Values.provider "pdns") .Values.pdns.apiKey }} + - name: PDNS_API_KEY + valueFrom: + secretKeyRef: + name: {{ template "external-dns.fullname" . }} + key: pdns_api_key + {{- end }} # Extra environment variables {{- $root := . -}} {{- range .Values.extraEnv }} diff --git a/stable/external-dns/templates/secret.yaml b/stable/external-dns/templates/secret.yaml index 9083a821a3..56d54f751e 100644 --- a/stable/external-dns/templates/secret.yaml +++ b/stable/external-dns/templates/secret.yaml @@ -1,4 +1,4 @@ -{{- if or .Values.aws.assumeRoleArn (and .Values.aws.credentials.secretKey .Values.aws.credentials.accessKey) .Values.cloudflare.apiKey .Values.digitalocean.apiToken .Values.google.serviceAccountKey (and .Values.infoblox.wapiUsername .Values.infoblox.wapiPassword) .Values.rfc2136.tsigSecret .Values.extraEnv }} +{{- if or .Values.aws.assumeRoleArn (and .Values.aws.credentials.secretKey .Values.aws.credentials.accessKey) .Values.cloudflare.apiKey .Values.digitalocean.apiToken .Values.google.serviceAccountKey (and .Values.infoblox.wapiUsername .Values.infoblox.wapiPassword) .Values.rfc2136.tsigSecret .Values.pdns.apiKey .Values.extraEnv }} apiVersion: v1 kind: Secret metadata: @@ -30,6 +30,9 @@ data: {{- if .Values.rfc2136.tsigSecret }} rfc2136_tsig_secret: {{ .Values.rfc2136.tsigSecret | b64enc | quote }} {{- end }} + {{- if .Values.pdns.apiKey }} + pdns_api_key: {{ .Values.pdns.apiKey | b64enc | quote }} + {{- end }} {{- range $key, $value := .Values.extraEnv }} {{ $key }}: {{ $value | b64enc | quote }} {{- end }} diff --git a/stable/external-dns/values-production.yaml b/stable/external-dns/values-production.yaml index b1864bed6e..9df69898d9 100644 --- a/stable/external-dns/values-production.yaml +++ b/stable/external-dns/values-production.yaml @@ -159,6 +159,13 @@ rfc2136: tsigKeyname: externaldns-key tsigAxfr: true +## PowerDNS configuration to be set via arguments/env. variables +## +pdns: + apiUrl: "" + apiPort: "8081" + apiKey: "" + ## Limit possible target zones by domain suffixes (optional) ## domainFilters: [] diff --git a/stable/external-dns/values.yaml b/stable/external-dns/values.yaml index a3feff30f3..469bb09760 100644 --- a/stable/external-dns/values.yaml +++ b/stable/external-dns/values.yaml @@ -159,6 +159,13 @@ rfc2136: tsigKeyname: externaldns-key tsigAxfr: true +## PowerDNS configuration to be set via arguments/env. variables +## +pdns: + apiUrl: "" + apiPort: "8081" + apiKey: "" + ## Limit possible target zones by domain suffixes (optional) ## domainFilters: []