Add Designate support for externaldns.

This change allows to pass Openstack credentials to externaldns when provider
is Designate.

Change-Id: I951686409c32a5d5d5caf93119c164f6343ae38f
diff --git a/README.rst b/README.rst
index 60ef3b4..e157e20 100644
--- a/README.rst
+++ b/README.rst
@@ -126,6 +126,28 @@
                 domain: company.mydomain
                 provider: coredns
 
+Enable external DNS addon with Designate provider
+
+.. code-block:: yaml
+
+    parameters:
+      kubernetes:
+        common:
+          addons:
+            externaldns:
+              externaldns:
+                enabled: True
+                domain: company.mydomain
+                provider: designate
+                designate_os_options:
+                  OS_AUTH_URL: https://keystone_auth_endpoint:5000
+                  OS_PROJECT_DOMAIN_NAME: default
+                  OS_USER_DOMAIN_NAME: default
+                  OS_PROJECT_NAME: admin
+                  OS_USERNAME: admin
+                  OS_PASSWORD: password
+                  OS_REGION_NAME: RegionOne
+
 Enable OpenStack cloud provider
 
 .. code-block:: yaml
diff --git a/kubernetes/files/kube-addons/externaldns/externaldns-deploy.yml b/kubernetes/files/kube-addons/externaldns/externaldns-deploy.yml
index 39723b1..8892c2b 100644
--- a/kubernetes/files/kube-addons/externaldns/externaldns-deploy.yml
+++ b/kubernetes/files/kube-addons/externaldns/externaldns-deploy.yml
@@ -29,8 +29,13 @@
         #- --policy=upsert-only # would prevent ExternalDNS from deleting any records, omit to enable full synchronization
         - --registry=txt
         - --txt-owner-id=my-identifier
-        {% if common.addons.externaldns.provider == "coredns" %}
+        - --publish-internal-services
+        {%- if common.addons.externaldns.provider == "coredns" %}
         env:
         - name: ETCD_URLS
           value: "https://coredns-etcd:2379"
-        {% endif %}
+        {%- elif common.addons.externaldns.provider == "designate" %}
+        envFrom:
+        - secretRef:
+            name: designate-os-secret
+        {%- endif %}
diff --git a/kubernetes/files/kube-addons/externaldns/externaldns-designate-secret.yaml b/kubernetes/files/kube-addons/externaldns/externaldns-designate-secret.yaml
new file mode 100644
index 0000000..de1f6e8
--- /dev/null
+++ b/kubernetes/files/kube-addons/externaldns/externaldns-designate-secret.yaml
@@ -0,0 +1,14 @@
+{%- from "kubernetes/map.jinja" import common with context -%}
+---
+apiVersion: v1
+kind: Secret
+metadata:
+  name: designate-os-secret
+  namespace: kube-system
+  labels:
+    addonmanager.kubernetes.io/mode: EnsureExists
+type: Opaque
+data:
+{%- for option, value in common.addons.externaldns.designate_os_options.items() %}
+  {{ option }}: {{ salt['hashutil.base64_b64encode'](value) }}
+{%- endfor %}
diff --git a/kubernetes/master/kube-addons.sls b/kubernetes/master/kube-addons.sls
index 8344337..565a082 100644
--- a/kubernetes/master/kube-addons.sls
+++ b/kubernetes/master/kube-addons.sls
@@ -182,6 +182,16 @@
     - dir_mode: 755
     - makedirs: True
 
+{%- if common.addons.externaldns.get('provider') == 'designate' %}
+/etc/kubernetes/addons/externaldns/externaldns-designate-secret.yaml:
+  file.managed:
+    - source: salt://kubernetes/files/kube-addons/externaldns/externaldns-designate-secret.yaml
+    - template: jinja
+    - group: root
+    - dir_mode: 755
+    - makedirs: True
+{% endif %}
+
 {% endif %}
 
 {%- if common.addons.get('dashboard', {'enabled': False}).enabled %}