Skip to content

Commit e40bbaf

Browse files
Add Kubernetes manifests and update files
1 parent 06142d7 commit e40bbaf

14 files changed

+349
-22
lines changed

README.md

Lines changed: 110 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,112 @@
1-
# owerDNS Authoritative Server
1+
# PowerDNS Authoritative Server
22

3-
- Powerdns v 4.9.9
3+
This is an all-in-one Docker image that includes PHP-FPM, Nginx, PowerAdmin (web interface), and PowerDNS Authoritative Server.
4+
5+
- PowerDNS v 4.9.9
46
- PowerAdmin v 4.0.4
7+
8+
Note: The image tag corresponds to the PowerAdmin version. Choose the tag based on the desired PowerAdmin version.
9+
10+
## Prerequisites
11+
12+
- Docker installed on your system.
13+
- Docker Compose installed (usually comes with Docker Desktop).
14+
- Basic knowledge of running Docker containers.
15+
16+
Note: The database (MariaDB/MySQL) must be set up separately as it is not included in this image.
17+
18+
## Supported Databases
19+
20+
PowerDNS supports MySQL, MariaDB, PostgreSQL, and SQLite. Configure the backend in the `PDNS_CONF` environment variable (e.g., `launch=gmysql` for MySQL/MariaDB).
21+
22+
## Quick Start
23+
24+
1. Create a `docker-compose.yml` file with the example below.
25+
2. Run `docker-compose up -d` to start the services in the background.
26+
3. Access PowerAdmin at `http://localhost/poweradmin` to complete the setup.
27+
28+
## Docker Compose Example
29+
30+
Here is a basic `docker-compose.yml` to get started:
31+
32+
```yaml
33+
version: '3.8'
34+
35+
services:
36+
mariadb:
37+
image: mariadb
38+
environment:
39+
MYSQL_ROOT_PASSWORD: root_pass
40+
MYSQL_DATABASE: pdns_db
41+
MYSQL_USER: pdns_user
42+
MYSQL_PASSWORD: pdns_pass
43+
44+
powerdns:
45+
image: ghcr.io/rootshell-coder/powerdns:4.0.4
46+
environment:
47+
PDNS_CONF: |
48+
launch=gmysql
49+
gmysql-host=mariadb
50+
gmysql-port=3306
51+
gmysql-dbname=pdns_db
52+
gmysql-user=pdns_user
53+
gmysql-password=pdns_pass
54+
gmysql-dnssec=yes
55+
allow-axfr-ips=127.0.0.1,::1
56+
local-address=0.0.0.0
57+
primary=no
58+
secondary=no
59+
cache-ttl=20
60+
distributor-threads=3
61+
allow-dnsupdate-from=127.0.0.1,::1
62+
ports:
63+
- "53:53/tcp"
64+
- "53:53/udp"
65+
- "80:80/tcp"
66+
depends_on:
67+
- mariadb
68+
```
69+
70+
## Database Setup
71+
72+
After starting the containers, initialize the PowerDNS database:
73+
74+
1. Copy the schema file from the container:
75+
76+
```bash
77+
docker cp powerdns-powerdns-1:/usr/share/doc/pdns/schema.mysql.sql ./
78+
```
79+
80+
2. Import the schema into MariaDB:
81+
82+
```bash
83+
docker exec -it powerdns-mariadb-1 mariadb -u pdns_user -p pdns_db < schema.mysql.sql
84+
```
85+
86+
Enter password: `pdns_pass`
87+
88+
This sets up the necessary tables.
89+
90+
## PowerAdmin Configuration
91+
92+
- Access PowerAdmin at `http://localhost/poweradmin` and follow the installation wizard.
93+
- For custom settings, mount `settings.php` as a volume:
94+
95+
```yaml
96+
volumes:
97+
- ./settings.php:/var/www/html/poweradmin/config/settings.php:ro
98+
```
99+
100+
## Post-Installation
101+
102+
To complete the PowerAdmin installation, remove the install directory as required by the installer:
103+
104+
```bash
105+
docker exec powerdns-powerdns-1 rm -rf /var/www/html/poweradmin/install
106+
```
107+
108+
## Usage
109+
110+
- PowerDNS listens on port 53 for DNS queries.
111+
- PowerAdmin web interface on port 80 at `/poweradmin`.
112+
- Manage DNS zones and records via the web interface.

docker-compose.yml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
---
22
networks:
3-
mariadb:
4-
name: mariadb
3+
mariadb-net:
4+
name: mariadb-net
55
attachable: true
6-
powerdns:
7-
name: powerdns
6+
powerdns-net:
7+
name: powerdns-net
88

99
volumes:
1010
mysqldb:
1111
name: mysqldb
12-
nginx:
13-
name: nginx
14-
powerdns:
15-
name: powerdns
1612
poweradmin:
1713
name: poweradmin
1814

@@ -32,12 +28,24 @@ services:
3228
powerdns:
3329
image: ghcr.io/rootshell-coder/powerdns:4.0.4
3430
volumes:
35-
- nginx:/etc/nginx/
36-
- powerdns:/etc/powerdns/
3731
- poweradmin:/var/www/html/poweradmin/
32+
environment:
33+
PDNS_CONF: |
34+
launch=gmysql
35+
gmysql-host=mariadb
36+
gmysql-port=3306
37+
gmysql-dbname=pdns_db
38+
gmysql-user=pdns_user
39+
gmysql-password=pdns_pass
40+
gmysql-dnssec=yes
41+
allow-axfr-ips=127.0.0.1,::1
42+
local-address=0.0.0.0
43+
primary=no
44+
secondary=no
45+
allow-dnsupdate-from=127.0.0.1,::1
3846
networks:
39-
- mariadb
40-
- powerdns
47+
- mariadb-net
48+
- powerdns-net
4149
ports:
4250
- 80:80/TCP
4351
- 53:53/TCP

docker/Dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PDNS ----------------------------------------------------------------------------------
1+
# ---------------------------------------------------------------------------------------
22
FROM alpine:3.22 AS pdns_authoritive
33

44
ENV POWERDNS_VER=4.9.9
@@ -81,7 +81,6 @@ RUN set -eux; \
8181
wget https://github.com/poweradmin/poweradmin/archive/refs/tags/v${POWERADMIN_VER}.tar.gz; \
8282
tar -xf v${POWERADMIN_VER}.tar.gz && rm -f v${POWERADMIN_VER}.tar.gz; \
8383
mv poweradmin-${POWERADMIN_VER} poweradmin;
84-
# rm -rf /var/www/html/poweradmin/install
8584

8685
# ---------------------------------------------------------------------------------------
8786
FROM alpine:3.22
@@ -102,6 +101,11 @@ ADD https://github.com/just-containers/s6-overlay/releases/download/v3.1.6.2/s6-
102101
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz
103102
RUN rm -rf /tmp/*
104103

104+
COPY --from=pdns_authoritive /build/powerdns-root /
105+
COPY --from=poweradmin /var/www/html /var/www/html
106+
COPY ./nginx /etc/nginx
107+
COPY ./entrypoint /usr/bin
108+
105109
RUN mkdir -p /etc/services.d/pdns /etc/services.d/nginx /etc/services.d/php-fpm && \
106110
printf '%s\n' \
107111
'#!/bin/sh' \
@@ -118,7 +122,8 @@ RUN mkdir -p /etc/services.d/pdns /etc/services.d/nginx /etc/services.d/php-fpm
118122

119123
RUN ln -sf /usr/bin/php83 /usr/bin/php && \
120124
ln -sf /usr/sbin/php-fpm83 /usr/sbin/php-fpm && \
121-
ln -sf /etc/php83 /etc/php
125+
ln -sf /etc/php83 /etc/php && \
126+
chmod +x /usr/bin/entrypoint
122127

123128
RUN mkdir -p /var/log/php83 /run/php
124129

@@ -161,10 +166,6 @@ RUN printf '%s\n' \
161166
'opcache.revalidate_freq=60' \
162167
> /etc/php/conf.d/99-custom.ini
163168

164-
COPY --from=pdns_authoritive /build/powerdns-root /
165-
COPY --from=poweradmin /var/www/html /var/www/html
166-
COPY ./nginx /etc/nginx
167-
168169
RUN printf '%s\n' \
169170
'launch=gmysql' \
170171
'gmysql-host=mariadb' \
@@ -177,4 +178,4 @@ VOLUME ["/etc/nginx/", "/etc/powerdns/", "/var/www/html/poweradmin/"]
177178

178179
WORKDIR /var/www/html
179180
EXPOSE 53 80
180-
CMD ["/init"]
181+
ENTRYPOINT ["entrypoint"]

docker/entrypoint

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
if [ -n "$PDNS_CONF" ]; then
4+
echo "$PDNS_CONF" > /etc/powerdns/pdns.conf
5+
fi
6+
7+
exec /init

k8s/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Kubernetes Manifests for PowerDNS
2+
3+
This directory contains Kubernetes manifests to deploy PowerDNS with MariaDB.
4+
5+
## Components
6+
7+
- `configmap.yaml`: Configuration for PowerDNS
8+
- `secret.yaml`: Secrets for MariaDB
9+
- `mariadb-pvc.yaml`: Persistent volume claim for MariaDB data
10+
- `poweradmin-pv.yaml`: Persistent volume for PowerAdmin data (hostPath for local testing, 200Mi)
11+
- `poweradmin-pvc.yaml`: Persistent volume claim for PowerAdmin data (200Mi)
12+
- `mariadb-deployment.yaml`: Deployment for MariaDB
13+
- `mariadb-service.yaml`: Service for MariaDB
14+
- `powerdns-deployment.yaml`: Deployment for PowerDNS
15+
- `powerdns-service.yaml`: ClusterIP service for PowerDNS (no exposed ports, use port-forwarding)
16+
17+
## Deployment
18+
19+
1. Apply all manifests:
20+
21+
```bash
22+
kubectl apply -f k8s/
23+
```
24+
25+
2. Initialize the database:
26+
- Get the MariaDB pod: `kubectl get pods`
27+
- Copy schema: `kubectl cp schema.mysql.sql <mariadb-pod>:/tmp/`
28+
- Import: `kubectl exec <mariadb-pod> -- mariadb -u pdns_user -p pdns_db < /tmp/schema.mysql.sql`
29+
30+
3. Access PowerAdmin using port-forwarding: `kubectl port-forward svc/powerdns-service 8080:80` then visit localhost:8080/poweradmin
31+
32+
4. DNS is available directly on node IP:53
33+
34+
## Notes
35+
36+
- Adjust storage sizes as needed.
37+
- For production, use proper secrets management.
38+
- DNS uses hostPort, so the pod will run on a single node and port 53 is exposed directly on the host.
39+
- HTTP access via port-forwarding or reverse proxy (e.g., Ingress).
40+
- DNS service may need additional configuration for external access.

k8s/configmap.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: powerdns-config
5+
data:
6+
pdns.conf: |
7+
launch=gmysql
8+
gmysql-host=mariadb-service
9+
gmysql-port=3306
10+
gmysql-dbname=pdns_db
11+
gmysql-user=pdns_user
12+
gmysql-password=pdns_pass
13+
gmysql-dnssec=yes
14+
allow-axfr-ips=127.0.0.1,::1
15+
local-address=0.0.0.0
16+
primary=no
17+
secondary=no
18+
allow-dnsupdate-from=127.0.0.1,::1

k8s/mariadb-deployment.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: mariadb
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: mariadb
10+
template:
11+
metadata:
12+
labels:
13+
app: mariadb
14+
spec:
15+
containers:
16+
- name: mariadb
17+
image: mariadb
18+
env:
19+
- name: MYSQL_ROOT_PASSWORD
20+
valueFrom:
21+
secretKeyRef:
22+
name: mariadb-secret
23+
key: mysql-root-password
24+
- name: MYSQL_DATABASE
25+
valueFrom:
26+
secretKeyRef:
27+
name: mariadb-secret
28+
key: mysql-database
29+
- name: MYSQL_USER
30+
valueFrom:
31+
secretKeyRef:
32+
name: mariadb-secret
33+
key: mysql-user
34+
- name: MYSQL_PASSWORD
35+
valueFrom:
36+
secretKeyRef:
37+
name: mariadb-secret
38+
key: mysql-password
39+
volumeMounts:
40+
- name: mariadb-storage
41+
mountPath: /var/lib/mysql
42+
volumes:
43+
- name: mariadb-storage
44+
persistentVolumeClaim:
45+
claimName: mariadb-pvc

k8s/mariadb-pvc.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: mariadb-pvc
5+
spec:
6+
accessModes:
7+
- ReadWriteOnce
8+
resources:
9+
requests:
10+
storage: 10Gi

k8s/mariadb-service.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: mariadb-service
5+
spec:
6+
selector:
7+
app: mariadb
8+
ports:
9+
- port: 3306
10+
targetPort: 3306

k8s/poweradmin-pv.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: PersistentVolume
3+
metadata:
4+
name: poweradmin-pv
5+
spec:
6+
capacity:
7+
storage: 200Mi
8+
accessModes:
9+
- ReadWriteOnce
10+
hostPath:
11+
path: /data/poweradmin

0 commit comments

Comments
 (0)