Skip to content

Commit 78463d5

Browse files
committed
standard documentation
Signed-off-by: Khash Sajadi <[email protected]>
1 parent dc8a6d0 commit 78463d5

File tree

1 file changed

+37
-20
lines changed

1 file changed

+37
-20
lines changed

README.md

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
1-
# mysql
1+
# MySQL
2+
23
MySQL backend for CoreDNS
34

4-
## Supported Record Types
5+
## Name
6+
MySQL - MySQL backend for CoreDNS
7+
8+
## Description
9+
10+
This plugin uses MySQL as a backend to store DNS records. These will then can served by CoreDNS. The backend uses a simple, single table data structure that can be shared by other systems to add and remove records from the DNS server. As there is no state stored in the plugin, the service can be scaled out by spinning multiple instances of CoreDNS backed by the same database.
11+
12+
## Syntax
13+
```
14+
mysql {
15+
dsn DSN
16+
[table_prefix TABLE_PREFIX]
17+
[max_lifetime MAX_LIFETIME]
18+
[max_open_connections MAX_OPEN_CONNECTIONS]
19+
[max_idle_connections MAX_IDLE_CONNECTIONS]
20+
[ttl DEFAULT_TTL]
21+
[zone_update_interval ZONE_UPDATE_INTERVAL]
22+
}
23+
```
24+
25+
`dsn` DSN for MySQL as per https://github.com/go-sql-driver/mysql examples. You can use `$ENV_NAME` format in the DSN, and it will be replaced with the environment variable value.
26+
`table_prefix` Prefix for the MySQL tables. Defaults to `coredns_`.
27+
`max_lifetime` Duration (in Golang format) for a SQL connection. Default is 1 minute.
28+
`max_open_connections` Maximum number of open connections to the database server. Default is 10.
29+
`max_idle_connections` Maximum number of idle connections in the database connection pool. Default is 10.
30+
`ttl` Default TTL for records without a specified TTL in seconds. Default is 360 (seconds)
31+
`zone_update_interval` Maximum time interval between loading all the zones from the database. Default is 10 minutes.
32+
33+
##3 Supported Record Types
534

635
A, AAAA, CNAME, SOA, TXT, NS, MX, CAA and SRV. This backend doesn't support AXFR requests. It also doesn't support wildcard records yet.
736

8-
## Setup
37+
## Setup (as an external plugin)
938

1039
Add this as an external plugin in `plugin.cfg` file:
1140

@@ -22,18 +51,6 @@ $ go build
2251

2352
Add any required modules to CoreDNS code as prompted.
2453

25-
## Configuration
26-
27-
In the Corefile, `mysql` can be configured with the following parameters:
28-
29-
`dsn` DSN for MySQL as per https://github.com/go-sql-driver/mysql examples. You can use `$ENV_NAME` format in the DSN, and it will be replaced with the environment variable value.
30-
`table_prefix` Prefix for the MySQL tables. Defaults to `coredns_`.
31-
`max_lifetime` Duration (in Golang format) for a SQL connection. Default is 1 minute.
32-
`max_open_connections` Maximum number of open connections to the database server. Default is 10.
33-
`max_idle_connections` Maximum number of idle connections in the database connection pool. Default is 10.
34-
`ttl` Default TTL for records without a specified TTL in seconds. Default is 360 (seconds)
35-
`zone_update_interval` Maximum time interval between loading all the zones from the database. Default is 10 minutes.
36-
3754
## Database Setup
3855
This plugin doesn't create or migrate database schema for its use yet. To create the database and tables, use the following table structure (note the table name prefix):
3956

@@ -55,16 +72,16 @@ Each record served by this plugin, should belong to the zone it is allowed to se
5572
```sql
5673
-- Insert batch #1
5774
INSERT INTO coredns_records (zone, name, ttl, content, record_type) VALUES
58-
('test.', 'foo', 30, '{"ip": "1.1.1.1"}', 'A'),
59-
('test.', 'foo', '60', '{"ip": "1.1.1.0"}', 'A'),
60-
('test.', 'foo', 30, '{"text": "hello"}', 'TXT'),
61-
('test.', 'foo', 30, '{"host" : "foo.test.","priority" : 10}', 'MX');
75+
('example.org.', 'foo', 30, '{"ip": "1.1.1.1"}', 'A'),
76+
('example.org.', 'foo', '60', '{"ip": "1.1.1.0"}', 'A'),
77+
('example.org.', 'foo', 30, '{"text": "hello"}', 'TXT'),
78+
('example.org.', 'foo', 30, '{"host" : "foo.example.org.","priority" : 10}', 'MX');
6279
```
6380

6481
These can be queries using `dig` like this:
6582

6683
```shell script
67-
$ dig A MX foo.test
84+
$ dig A MX foo.example.org
6885
```
6986

7087
### Acknowledgements and Credits

0 commit comments

Comments
 (0)