From 76c5d9a6c86d77c66de2bf9b14740cd7912dff2d Mon Sep 17 00:00:00 2001 From: Harm Weites Date: Fri, 29 May 2015 20:21:47 +0200 Subject: [PATCH] Add the Designate DNSaaS services. This is a complete DNS solution, with hidden master and bind9 slave. It lacks the designate-sink service, because there is no true specification to implement that. It listens for Nova/Neutron events and creates records though adding those to just 1 domain isn't helping much in an environment with multiple tenants. Change-Id: I500fb6058b118d25a4ccfd1d3479830c36af7e2a Blueprint: designate-container --- compose/designate.yml | 54 +++++++++++++++++ .../binary/designate/designate-api/Dockerfile | 10 ++++ .../binary/designate/designate-api/build | 1 + .../binary/designate/designate-api/start.sh | 37 ++++++++++++ .../designate-backend-bind9-data/Dockerfile | 6 ++ .../designate-backend-bind9-data/build | 1 + .../designate-backend-bind9/Dockerfile | 10 ++++ .../designate/designate-backend-bind9/build | 1 + .../designate-backend-bind9/start.sh | 60 +++++++++++++++++++ .../designate/designate-base/Dockerfile | 17 ++++++ .../binary/designate/designate-base/build | 1 + .../designate-base/config-designate.sh | 58 ++++++++++++++++++ .../designate/designate-central/Dockerfile | 10 ++++ .../binary/designate/designate-central/build | 1 + .../designate/designate-central/start.sh | 24 ++++++++ .../designate/designate-mdns/Dockerfile | 9 +++ .../binary/designate/designate-mdns/build | 1 + .../binary/designate/designate-mdns/start.sh | 17 ++++++ .../designate-poolmanager/Dockerfile | 12 ++++ .../designate/designate-poolmanager/build | 1 + .../designate/designate-poolmanager/start.sh | 49 +++++++++++++++ docs/integration-guide.md | 13 ++++ tools/genenv | 39 ++++++++++++ 23 files changed, 432 insertions(+) create mode 100644 compose/designate.yml create mode 100644 docker/centos/binary/designate/designate-api/Dockerfile create mode 120000 docker/centos/binary/designate/designate-api/build create mode 100755 docker/centos/binary/designate/designate-api/start.sh create mode 100644 docker/centos/binary/designate/designate-backend-bind9-data/Dockerfile create mode 120000 docker/centos/binary/designate/designate-backend-bind9-data/build create mode 100644 docker/centos/binary/designate/designate-backend-bind9/Dockerfile create mode 120000 docker/centos/binary/designate/designate-backend-bind9/build create mode 100755 docker/centos/binary/designate/designate-backend-bind9/start.sh create mode 100644 docker/centos/binary/designate/designate-base/Dockerfile create mode 120000 docker/centos/binary/designate/designate-base/build create mode 100755 docker/centos/binary/designate/designate-base/config-designate.sh create mode 100644 docker/centos/binary/designate/designate-central/Dockerfile create mode 120000 docker/centos/binary/designate/designate-central/build create mode 100755 docker/centos/binary/designate/designate-central/start.sh create mode 100644 docker/centos/binary/designate/designate-mdns/Dockerfile create mode 120000 docker/centos/binary/designate/designate-mdns/build create mode 100755 docker/centos/binary/designate/designate-mdns/start.sh create mode 100644 docker/centos/binary/designate/designate-poolmanager/Dockerfile create mode 120000 docker/centos/binary/designate/designate-poolmanager/build create mode 100755 docker/centos/binary/designate/designate-poolmanager/start.sh diff --git a/compose/designate.yml b/compose/designate.yml new file mode 100644 index 0000000000..96d0219528 --- /dev/null +++ b/compose/designate.yml @@ -0,0 +1,54 @@ +# The DNSaaS REST api from where zones and records are added or removed. +designateapi: + image: kollaglue/centos-rdo-designate-api:latest + name: designate-api + net: "host" + restart: always + env_file: + - openstack.env + +# The central dispatches the API requests and pushes requests further down to +# pool-manager and the database for storage. +designatecentral: + image: kollaglue/centos-rdo-designate-central:latest + name: designate-central + net: "host" + restart: always + env_file: + - openstack.env + +# The pool-manager will push new zones to the backend so they can slave them. +designatepoolmanager: + image: kollaglue/centos-rdo-designate-poolmanager:latest + name: designate-poolmanager + net: "host" + restart: always + env_file: + - openstack.env + +# Bind9 backend and state storage. +designatebackendbind9data: + image: kollaglue/centos-rdo-designate-backend-bind9-data:latest + name: designate-backend-bind9-data + restart: on-failure + +designatebackendbind9: + image: kollaglue/centos-rdo-designate-backend-bind9:latest + name: designate-backend-bind9 + net: "host" + restart: always + env_file: + - openstack.env + volumes_from: + - designatebackendbind9data + +# The MDNS service acts as the primary (or hidden-master) nameserver and uses +# AXFR/IXFR commands to inform the slaves (which realy listen for queries from +# $world) about updates. +designatemdns: + image: kollaglue/centos-rdo-designate-mdns:latest + name: designate-mdns + net: "host" + restart: always + env_file: + - openstack.env diff --git a/docker/centos/binary/designate/designate-api/Dockerfile b/docker/centos/binary/designate/designate-api/Dockerfile new file mode 100644 index 0000000000..b68da474fd --- /dev/null +++ b/docker/centos/binary/designate/designate-api/Dockerfile @@ -0,0 +1,10 @@ +FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%designate-base:%%KOLLA_TAG%% +MAINTAINER Kolla Project (https://launchpad.net/kolla) + +RUN yum install -y \ + openstack-designate-api \ + && yum clean all + +COPY start.sh /start.sh + +CMD ["/start.sh"] diff --git a/docker/centos/binary/designate/designate-api/build b/docker/centos/binary/designate/designate-api/build new file mode 120000 index 0000000000..ec19138031 --- /dev/null +++ b/docker/centos/binary/designate/designate-api/build @@ -0,0 +1 @@ +../../../../../tools/build-docker-image \ No newline at end of file diff --git a/docker/centos/binary/designate/designate-api/start.sh b/docker/centos/binary/designate/designate-api/start.sh new file mode 100755 index 0000000000..aae50ea8f1 --- /dev/null +++ b/docker/centos/binary/designate/designate-api/start.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -e + +. /opt/kolla/kolla-common.sh +. /opt/kolla/config-designate.sh + +CONF=/etc/designate/designate.conf + +check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_ADMIN_SERVICE_HOST \ + DESIGNATE_KEYSTONE_USER DESIGNATE_KEYSTONE_PASSWORD \ + KEYSTONE_AUTH_PROTOCOL ADMIN_TENANT_NAME \ + DESIGNATE_API_SERVICE_HOST DESIGNATE_API_SERVICE_PORT \ + KEYSTONE_ADMIN_SERVICE_PORT + +export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}" +export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_ADMIN_SERVICE_HOST}:${KEYSTONE_ADMIN_SERVICE_PORT}/v2.0" + +fail_unless_os_service_running keystone + +crux user-create \ + -n ${DESIGNATE_KEYSTONE_USER} \ + -p ${DESIGNATE_KEYSTONE_PASSWORD} \ + -t ${ADMIN_TENANT_NAME} \ + -r admin + +crux endpoint-create \ + --remove-all \ + -n ${DESIGNATE_KEYSTONE_USER} \ + -t dns \ + -I "${KEYSTONE_AUTH_PROTOCOL}://${DESIGNATE_API_SERVICE_HOST}:${DESIGNATE_API_SERVICE_PORT}/v1" \ + -P "${KEYSTONE_AUTH_PROTOCOL}://${DESIGNATE_API_SERVICE_HOST}:${DESIGNATE_API_SERVICE_PORT}/v1" \ + -A "${KEYSTONE_AUTH_PROTOCOL}://${DESIGNATE_API_SERVICE_HOST}:${DESIGNATE_API_SERVICE_PORT}/v1" + +crudini --set $CONF service:api api_paste_config "/usr/share/designate/api-paste.ini" +crudini --set $CONF service:api api_port "${DESIGNATE_API_SERVICE_PORT}" + +exec /usr/bin/designate-api diff --git a/docker/centos/binary/designate/designate-backend-bind9-data/Dockerfile b/docker/centos/binary/designate/designate-backend-bind9-data/Dockerfile new file mode 100644 index 0000000000..99909c361a --- /dev/null +++ b/docker/centos/binary/designate/designate-backend-bind9-data/Dockerfile @@ -0,0 +1,6 @@ +FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%base:%%KOLLA_TAG%% +MAINTAINER Kolla Project (https://launchpad.net/kolla) + +VOLUME [ "/var/named" ] + +CMD [ "/bin/true" ] diff --git a/docker/centos/binary/designate/designate-backend-bind9-data/build b/docker/centos/binary/designate/designate-backend-bind9-data/build new file mode 120000 index 0000000000..ec19138031 --- /dev/null +++ b/docker/centos/binary/designate/designate-backend-bind9-data/build @@ -0,0 +1 @@ +../../../../../tools/build-docker-image \ No newline at end of file diff --git a/docker/centos/binary/designate/designate-backend-bind9/Dockerfile b/docker/centos/binary/designate/designate-backend-bind9/Dockerfile new file mode 100644 index 0000000000..7f57786c4b --- /dev/null +++ b/docker/centos/binary/designate/designate-backend-bind9/Dockerfile @@ -0,0 +1,10 @@ +FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%designate-base:%%KOLLA_TAG%% +MAINTAINER Kolla Project (https://launchpad.net/kolla) + +RUN yum install -y bind \ + && yum clean all \ + && cp -pr /var/named /opt/kolla/var-named + +COPY start.sh /start.sh + +CMD ["/start.sh"] diff --git a/docker/centos/binary/designate/designate-backend-bind9/build b/docker/centos/binary/designate/designate-backend-bind9/build new file mode 120000 index 0000000000..ec19138031 --- /dev/null +++ b/docker/centos/binary/designate/designate-backend-bind9/build @@ -0,0 +1 @@ +../../../../../tools/build-docker-image \ No newline at end of file diff --git a/docker/centos/binary/designate/designate-backend-bind9/start.sh b/docker/centos/binary/designate/designate-backend-bind9/start.sh new file mode 100755 index 0000000000..90d2de676b --- /dev/null +++ b/docker/centos/binary/designate/designate-backend-bind9/start.sh @@ -0,0 +1,60 @@ +#!/bin/bash +set -e + +. /opt/kolla/kolla-common.sh + +check_required_vars DESIGNATE_MASTERNS DESIGNATE_SLAVENS DESIGNATE_BIND9_RNDC_KEY \ + DESIGNATE_ALLOW_RECURSION + +NAMEDCFG=/etc/named.conf + +# /var/named is coming from a VOLUME definition but at first boot it needs to +# be populated from the original container since else it would be missing some +# Bind9 core files. These files have been saved during the build phase. + +if [ ! -f /var/named/named.ca ]; then + cp -pr /opt/kolla/var-named/* /var/named/ +fi + +# When rndc adds a new domain, bind adds the call in an nzf file in this +# directory. +chmod 770 /var/named +chown root:named /var/named + +# Default Bind9 behavior is to enable recursion, disable if wanted. +if [ "${DESIGNATE_ALLOW_RECURSION}" == "false" ]; then + sed -i -r "s/(recursion) yes/\1 no/" $NAMEDCFG +fi + +sed -i -r "/listen-on port 53/d" $NAMEDCFG +sed -i -r "/listen-on-v6/d" $NAMEDCFG +sed -i -r "s,/\* Path to ISC DLV key \*/,allow-new-zones yes;," $NAMEDCFG +sed -i -r "/allow-query .+;/d" $NAMEDCFG + +if ! grep -q rndc-key /etc/named.conf; then + cat >> /etc/named.conf < /etc/rndc.key < /etc/rndc.conf <> /etc/rndc.conf +chown named /etc/rndc.key + +# Launch and keep in the foreground. +exec /usr/sbin/named -u named -g diff --git a/docker/centos/binary/designate/designate-base/Dockerfile b/docker/centos/binary/designate/designate-base/Dockerfile new file mode 100644 index 0000000000..ae7b060018 --- /dev/null +++ b/docker/centos/binary/designate/designate-base/Dockerfile @@ -0,0 +1,17 @@ +FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%base:%%KOLLA_TAG%% +MAINTAINER Kolla Project (https://launchpad.net/kolla) + +# Install designate-api because of /etc/designate/policy.json, which +# is needed in all services. This is probably a packaging bug. We do +# need the complete policy file because of some of the containers' +# requiring it. Remove the package when the file is moved though. +RUN yum install -y \ + MySQL-python \ + openstack-designate-api \ + openstack-designate-common \ + && yum clean all \ + && cp /etc/designate/policy.json /tmp/ \ + && rpm -e openstack-designate-api \ + && mv /tmp/policy.json /etc/designate/ + +COPY config-designate.sh /opt/kolla/config-designate.sh diff --git a/docker/centos/binary/designate/designate-base/build b/docker/centos/binary/designate/designate-base/build new file mode 120000 index 0000000000..ec19138031 --- /dev/null +++ b/docker/centos/binary/designate/designate-base/build @@ -0,0 +1 @@ +../../../../../tools/build-docker-image \ No newline at end of file diff --git a/docker/centos/binary/designate/designate-base/config-designate.sh b/docker/centos/binary/designate/designate-base/config-designate.sh new file mode 100755 index 0000000000..883d094b45 --- /dev/null +++ b/docker/centos/binary/designate/designate-base/config-designate.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +set -e + +. /opt/kolla/kolla-common.sh + +check_required_vars DESIGNATE_DB_PASSWORD DESIGNATE_KEYSTONE_PASSWORD \ + KEYSTONE_PUBLIC_SERVICE_HOST RABBITMQ_SERVICE_HOST \ + DESIGNATE_BIND9_RNDC_KEY DESIGNATE_BACKEND \ + KEYSTONE_PUBLIC_SERVICE_PORT DESIGNATE_KEYSTONE_USER \ + RABBIT_USERID RABBIT_PASSWORD DESIGNATE_DB_USER \ + DESIGNATE_DB_NAME KEYSTONE_AUTH_PROTOCOL \ + KEYSTONE_ADMIN_SERVICE_HOST KEYSTONE_ADMIN_SERVICE_PORT \ + DEBUG_LOGGING + +fail_unless_db +dump_vars + +cat > /openrc < /etc/rndc.key < - The Magnum keystone password MAGNUM_API_SERVICE_HOST= - The Magnum Host IP address MAGNUM_API_SERVICE_PORT=<9511> - The Magnum port + DESIGNATE_DB_NAME= - The Designate database name + DESIGNATE_DB_PASSWORD= - The Designate database password + DESIGNATE_KEYSTONE_PASSWORD= - The keystone password for the designate user + DESIGNATE_BIND9_RNDC_KEY= - The rndc/bind key to use for communication between pool_manager and bind9 + DESIGNATE_MASTERNS= - The IP Address of the master (primary) DNS server (the backend) + DESIGNATE_BACKEND= - The backend to use in Designate, currently only bind9 is supported + DESIGNATE_SLAVENS= - The IP Address of a slave nameserver under control of pool_manager + DESIGNATE_API_SERVICE_HOST= - The IP Address of the Designate API + DESIGNATE_API_SERVICE_PORT=<9001> - The port of the Designate API + DESIGNATE_MDNS_PORT=<5354> - The port of the Designate MiniDNS server acting as master server + DESIGNATE_DNS_PORT=<53> - The port of the Designate-backed DNS slaves that are used by the world + DESIGNATE_INITDB= - Configures if the database should be created and initialised + DESIGNATE_ALLOW_RECURSION= - Configure a recursive nameserver [Minimum environment variable setup guide.](https://github.com/stackforge/kolla/blob/master/docs/minimal-environment-vars.md) diff --git a/tools/genenv b/tools/genenv index 3b0c4d2b88..69a3b13fca 100755 --- a/tools/genenv +++ b/tools/genenv @@ -125,6 +125,27 @@ MAGNUM_KEYSTONE_PASSWORD=magnum MAGNUM_API_SERVICE_HOST=$HOST_IP MAGNUM_API_SERVICE_PORT=9511 +# Designate +DESIGNATE_DB_NAME=designate +DESIGNATE_DB_USER=designate +DESIGNATE_DB_PASSWORD=designatedns +DESIGNATE_KEYSTONE_USER=designate +DESIGNATE_KEYSTONE_PASSWORD=designate +DESIGNATE_BIND9_RNDC_KEY=$(openssl rand -base64 24) +DESIGNATE_MASTERNS=$HOST_IP +DESIGNATE_BACKEND=bind9 +DESIGNATE_SLAVENS=$HOST_IP +DESIGNATE_API_SERVICE_HOST=$HOST_IP +DESIGNATE_API_SERVICE_PORT=9001 +DESIGNATE_MDNS_PORT=5354 +DESIGNATE_DNS_PORT=53 +# The POOLID is hardcoded, upstream ships pre-configured with this uuid: +DESIGNATE_POOLMAN_POOLID=794ccc2c-d751-44fe-b57f-8894c9f5c842 +DESIGNATE_POOLMAN_TARGETS=$(uuidgen) +DESIGNATE_POOLMAN_NSS=$(uuidgen) +DESIGNATE_INITDB=true +DESIGNATE_ALLOW_RECURSION=true + cat > ./openrc <