Add externaldns addon with CoreDNS support
Change-Id: If1ec70e59c328e350104585e70ec4a2231529929
diff --git a/README.rst b/README.rst
index 4d375e8..0ec06d2 100644
--- a/README.rst
+++ b/README.rst
@@ -110,6 +110,22 @@
- secondcluster.mydomain
- thirdcluster.mydomain
+Enable external DNS addon with CoreDNS provider
+
+.. code-block:: yaml
+
+ parameters:
+ kubernetes:
+ common:
+ addons:
+ externaldns:
+ coredns:
+ enabled: True
+ externaldns:
+ enabled: True
+ domain: company.mydomain
+ provider: coredns
+
Configure service verbosity
.. code-block:: yaml
diff --git a/kubernetes/files/kube-addons/coredns/coredns-cm.yml b/kubernetes/files/kube-addons/coredns/coredns-cm.yml
index 616b026..0cd3a48 100644
--- a/kubernetes/files/kube-addons/coredns/coredns-cm.yml
+++ b/kubernetes/files/kube-addons/coredns/coredns-cm.yml
@@ -11,11 +11,20 @@
data:
Corefile: |
.:53 {
+{% if master.federation.enabled %}
etcd {{ master.federation.name }} {
stubzones
path /skydns
endpoint http://coredns-etcd:2379
}
+{% endif %}
+{% if common.addons.externaldns.enabled %}
+ etcd {{ common.addons.externaldns.domain }} {
+ stubzones
+ path /skydns
+ endpoint http://coredns-etcd:2379
+ }
+{% endif %}
errors
log stdout
health
diff --git a/kubernetes/files/kube-addons/externaldns/externaldns-deploy.yml b/kubernetes/files/kube-addons/externaldns/externaldns-deploy.yml
new file mode 100644
index 0000000..39723b1
--- /dev/null
+++ b/kubernetes/files/kube-addons/externaldns/externaldns-deploy.yml
@@ -0,0 +1,36 @@
+{%- from "kubernetes/map.jinja" import common with context -%}
+---
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+ namespace: {{ common.addons.externaldns.namespace }}
+ name: external-dns
+ labels:
+ addonmanager.kubernetes.io/mode: Reconcile
+spec:
+ strategy:
+ type: Recreate
+ template:
+ metadata:
+ labels:
+ app: external-dns
+ spec:
+ tolerations:
+ - key: node-role.kubernetes.io/master
+ effect: NoSchedule
+ containers:
+ - name: external-dns
+ image: {{ common.addons.externaldns.image }}
+ args:
+ - --source=service
+ - --source=ingress
+ - --domain-filter={{ common.addons.externaldns.domain }} # will make ExternalDNS see only the hosted zones matching provided domain, omit to process all available hosted zones
+ - --provider={{ common.addons.externaldns.provider }}
+ #- --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" %}
+ env:
+ - name: ETCD_URLS
+ value: "https://coredns-etcd:2379"
+ {% endif %}
diff --git a/kubernetes/master/kube-addons.sls b/kubernetes/master/kube-addons.sls
index 75f7c26..812c84b 100644
--- a/kubernetes/master/kube-addons.sls
+++ b/kubernetes/master/kube-addons.sls
@@ -153,6 +153,16 @@
{% endif %}
+{%- if common.addons.get('externaldns', {}).get('enabled') %}
+/etc/kubernetes/addons/externaldns/externaldns-deploy.yaml:
+ file.managed:
+ - source: salt://kubernetes/files/kube-addons/externaldns/externaldns-deploy.yml
+ - template: jinja
+ - group: root
+ - dir_mode: 755
+ - makedirs: True
+{% endif %}
+
{%- if common.addons.dashboard.enabled %}
/etc/kubernetes/addons/dashboard/dashboard-service.yaml:
diff --git a/metadata/service/common.yml b/metadata/service/common.yml
index 8b1052c..8c921db 100644
--- a/metadata/service/common.yml
+++ b/metadata/service/common.yml
@@ -46,6 +46,12 @@
namespace: kube-system
image: coredns/coredns:latest
etcd_image: quay.io/coreos/etcd:v3.1.0
+ externaldns:
+ enabled: True
+ namespace: kube-system
+ image: mirantis/external-dns:latest
+ domain: ${_param:kubernetes_cluster_domain}
+ provider: coredns
virtlet:
enabled: False
namespace: kube-system