5.5 KiB
Plan: Adding PowerDNS as a DNS Provider to Cloudron
This document outlines the detailed steps required to add support for PowerDNS via the PowerDNS Authoritative Server REST API to Cloudron. It covers frontend UI updates, backend DNS provider implementation, unit testing, and live testing instructions.
1. Frontend Modifications
The Cloudron dashboard is a Vue application that needs to know about the new provider and how to prompt the user for credentials.
dashboard/src/models/DomainsModel.js
- Add Provider: Append
{ name: 'PowerDNS', value: 'powerdns' }to theprovidersarray. - Define Required Properties: In the
getProviderConfigProps(provider)switch statement, add a case for PowerDNS to define the fields it needs:case 'powerdns': props = ['apiUrl', 'apiKey']; break;
dashboard/src/components/DomainProviderForm.vue
- Reset Logic: In the
dnsConfigreset block (around line 57), adddnsConfig.value.apiUrl = '';to ensure the form clears properly. - UI Template: Add the HTML form groups for PowerDNS within the template section:
<!-- powerdns --> <FormGroup v-if="provider === 'powerdns'"> <label for="powerdnsApiUrlInput">{{ $t('domains.domainDialog.powerdnsApiUrl') }}</label> <TextInput id="powerdnsApiUrlInput" type="url" v-model="dnsConfig.apiUrl" placeholder="https://ns1.example.com:8081" required /> </FormGroup> <FormGroup v-if="provider === 'powerdns'"> <label for="powerdnsApiKeyInput">{{ $t('domains.domainDialog.powerdnsApiKey') }}</label> <MaskedInput id="powerdnsApiKeyInput" v-model="dnsConfig.apiKey" required /> </FormGroup>
dashboard/public/translation/en.json
- Add Translations: Add the English translation strings for the new fields under the
domains.domainDialogobject:"powerdnsApiUrl": "PowerDNS API URL (e.g., https://ns1.example.com:8081)", "powerdnsApiKey": "API Key",
2. Backend Modifications
The backend needs a new driver file that implements the standard Cloudron DNS provider interface.
src/dns.js
- Import the Driver: Add
import dnsPowerdns from './dns/powerdns.js';at the top with the other imports. - Register the Provider: Add
powerdns: dnsPowerdnsto theDNS_PROVIDERSmapping object.
src/dns/powerdns.js (New File)
Create a new file that implements the standard DNS interface (src/dns/interface.js).
- Required Methods: Export
removePrivateFields,injectPrivateFields,upsert,get,del,wait, andverifyDomainConfig. - API Interactions:
- Construct the base URL:
const baseUrl = domainConfig.apiUrl.replace(/\/$/, ''); - Ensure queries and zone names have a trailing dot, as PowerDNS strictly requires absolute FQDNs (e.g.,
example.com.). - Set the
X-API-Keyheader usingdomainConfig.apiKeyfor all requests.
- Construct the base URL:
- Operations:
get: UseGET ${baseUrl}/api/v1/servers/localhost/zones/${zoneName}.and extract records from therrsetsarray matching the exactfqdnandtype.upsert: UsePATCH ${baseUrl}/api/v1/servers/localhost/zones/${zoneName}.. Send anrrsetspayload withchangetype: 'REPLACE'. EnsureTXTvalues are quoted.del: UsePATCHwithchangetype: 'DELETE'.
- verifyDomainConfig: Perform a test
upsertanddelof anArecord on the subdomaincloudrontestdnsto ensure the API is reachable and the key has edit permissions.
3. Automated Testing (Local)
The new provider needs to be verified against the existing test suite using mock HTTP requests.
src/test/dns-providers-test.js
- Add a new
describe('powerdns', ...)block. - Setup mock domain configuration with a dummy
apiUrlandapiKey. - Use
nockto intercept requests to the dummyapiUrl. - Write tests for:
upsertnon-existing and existing records.getrecords.delrecords.
- Ensure the nock endpoints expect the exact JSON structure and
rrsetspayload required by PowerDNS.
Running the Tests
Run the specific test suite for DNS providers locally:
./run-tests src/test/dns-providers-test.js
(This uses the fast-path to run mocha directly, skipping the full Cloudron test environment setup).
4. Live Testing (Remote Cloudron Server)
To test the integration end-to-end, deploy the changes to a temporary Cloudron instance using the provided hotfix script.
Important Considerations for Hotfixing:
The scripts/hotfix tool builds a release tarball by executing git archive HEAD. You must commit your changes locally before running the hotfix, otherwise the script will fail or push the old codebase.
-
Commit Changes:
git add . git commit -m "Implement PowerDNS provider" -
Run Hotfix Script: Execute the hotfix script from the repository root, pointing it to your test server.
./scripts/hotfix --cloudron <IP_OR_DOMAIN_OF_TEST_SERVER> --ssh-user root --ssh-key ~/.ssh/id_rsa --release 1.0.0-test -
Verify Deployment:
- The script will install dependencies, compile the Vue dashboard, bundle the backend code, push it to the server, and restart the
boxservice. - Log into the Cloudron dashboard via your browser.
- Navigate to Domains -> Add Domain, select "PowerDNS".
- Enter a test domain, a valid PowerDNS API URL, and an API Key.
- Verify that Cloudron successfully configures the domain and creates the necessary initial DNS records.
- The script will install dependencies, compile the Vue dashboard, bundle the backend code, push it to the server, and restart the