File: ubuntu-dev.rst

package info (click to toggle)
designate 1%3A21.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,860 kB
  • sloc: python: 49,608; sh: 1,914; sql: 155; makefile: 83; javascript: 3
file content (364 lines) | stat: -rw-r--r-- 7,649 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
..
    Copyright 2013 Rackspace Hosting

    Licensed under the Apache License, Version 2.0 (the "License"); you may
    not use this file except in compliance with the License. You may obtain
    a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    License for the specific language governing permissions and limitations
    under the License.

*********************************
Development Environment on Ubuntu
*********************************

Designate is comprised of four main components :ref:`designate-api`,
:ref:`designate-central`, designate-mdns, and designate-pool-manager,
supported by a few standard open source components.
For more information see :ref:`architecture`.

There are many different options for customizing Designate, and two of
these options have a major impact on the installation process:

* The storage backend used (SQLite or MySQL)
* The DNS backend used (PowerDNS or BIND9)

This guide will walk you through setting up a typical development environment
for Designate, using BIND9 as the DNS backend and MySQL as the storage
backend. For a more complete discussion on installation & configuration
options, please see :ref:`architecture`.

For this guide you will need access to an Ubuntu Server (16.04).

.. _Development Environment:

Development Environment
+++++++++++++++++++++++

Installing Designate
====================

.. index::
   double: install; designate

1. Install system package dependencies (Ubuntu)

::

   $ sudo apt update
   $ sudo apt install python-pip python-virtualenv libssl-dev libffi-dev git
   $ sudo apt build-dep python-lxml

2. Clone the Designate repo

::

   $ mkdir openstack
   $ cd openstack
   $ git clone https://opendev.org/openstack/designate.git
   $ cd designate


3. Setup a virtualenv

.. note::
   This step is necessary to allow the installation of an up-to-date
   pip, independent of the version packaged for Ubuntu. it is
   also useful in isolating the remainder of Designate's dependencies
   from the rest of the system.

::

   $ virtualenv .venv
   $ . .venv/bin/activate

4. Install an up-to-date pip

::

   $ pip install -U pip


5. Install Designate and its dependencies

::

   $ pip install -e .


6. Change directories to the etc/designate folder.

.. note::
    Everything from here on out should take place in or below your
    etc/designate folder

::

   $ cd etc/designate


7. Create Designate's config files by copying the sample config files

::

   $ cp -a rootwrap.conf.sample rootwrap.conf


8. Make the directory for Designate's state files

::

   $ mkdir -p ../../state


Configuring Designate
======================

Refer to :ref:`configuration` for a sample configuration options.


Installing RabbitMQ
===================

Install the RabbitMQ package

::

    $ sudo apt install rabbitmq-server

Create a user:

::

    $ sudo rabbitmqctl add_user designate designate

Give the user access to the / vhost:

::

    $ sudo rabbitmqctl set_permissions -p "/" designate ".*" ".*" ".*"


Installing MySQL
================

.. index::
    double: install; mysql

Install the MySQL server package

::

    $ sudo apt install mysql-server


If you do not have MySQL previously installed, you will be prompted to change
the root password. By default, the MySQL root password for Designate
is "password". You can:

* Change the root password to "password"
* If you want your own password, edit the designate.conf file and change
  any instance of
  "mysql+pymysql://root:password@127.0.0.1/designate?charset=utf8"
  to "mysql+pymysql://root:YOUR_PASSWORD@127.0.0.1/designate?charset=utf8"

You can change your MySQL password anytime with the following command::

    $ mysqladmin -u root -p password NEW_PASSWORD
    Enter password <enter your old password>

Create the Designate tables

::

    $ mysql -u root -p
    Enter password: <enter your password here>

    mysql> CREATE DATABASE `designate` CHARACTER SET utf8 COLLATE utf8_general_ci;
    mysql> exit;


Install additional packages

::

    $ sudo apt install libmysqlclient-dev
    $ pip install pymysql


Installing BIND9
================

.. index::
    double: install; bind9

Install the DNS server, BIND9

::

    $ sudo apt install bind9

Update the BIND9 Configuration

::

    $ sudo editor /etc/bind/named.conf.options

Change the corresponding lines in the config file:

::

    options {
      directory "/var/cache/bind";
      dnssec-validation auto;
      auth-nxdomain no; # conform to RFC1035
      listen-on-v6 { any; };
      allow-new-zones yes;
      request-ixfr no;
      recursion no;
    };

Disable AppArmor for BIND9

::

    $ sudo touch /etc/apparmor.d/disable/usr.sbin.named
    $ sudo systemctl reload apparmor

Restart BIND9:

::

    $ sudo systemctl restart bind9

Create and Import pools.yaml File
=================================

.. index::
   double: install; pools

Create the pools.yaml file

::

  $ editor pools.yaml

Copy or mirror the configuration from this sample file here:

.. literalinclude:: ../examples/basic-pools-sample.yaml
    :language: yaml

Initialize the Database
=======================

.. index::
   double: install; database

Sync the Designate database.

::

   $ designate-manage database sync

Start the Central Service
=========================

.. index::
   double: install; central


Start the central service.

::

   $ designate-central


You'll now be seeing the log from the central service.


Initialize Pools Information
============================

Import the pools.yaml file into Designate. It is important that
``designate-central`` is started before invoking this command

::

   $ designate-manage pool update --file pools.yaml


Start the other Services
========================

.. index::
   double: install; services

Open up some new ssh windows and log in to your server
(or open some new screen/tmux sessions).

::

   $ cd openstack/designate
   $ . .venv/bin/activate

Start the other services

::

   $ designate-api
   $ designate-mdns
   $ designate-worker
   $ designate-producer

You'll now be seeing the logs from the other services.

Exercising the API
==================

.. note:: If you have a firewall enabled, make sure to open port 53,
          as well as Designate's default port (9001).

Using a web browser, curl statement, or a REST client, calls can be made to the
Designate API. You can find the various API calls on the api-ref_ document.

For example:

::

   $ curl 127.0.0.1:9001/v2/zones -H 'Content-Type: application/json' --data '
     {
       "name": "example.com.",
       "email": "example@example.com"
     }'

   {"status": "PENDING",.....
   $ curl 127.0.0.1:9001/v2/zones
   {"zones": [{"status": "ACTIVE",.....

The ``ACTIVE`` status shows that the zone propagated. So you should be able to
perform a DNS query and see it:

::

    $ dig @127.0.0.1 example.com SOA +short
    ns1-1.example.org. example.example.com. 1487884120 3531 600 86400 3600

You can find the IP Address of your server by running

::

   ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1

If you have Keystone set up, you can use it by configuring
the ``[keystone_authtoken]`` section and changing
the ``auth_strategy = keystone`` in the ``service:api`` section.
This will make it easier to use clients like the ``openstack``
CLI that expect Keystone.

.. _api-ref: https://docs.openstack.org/api-ref/dns/