As part of some work to resolve a kubernetes application deployment.
The particular application i\u2019m working with has hard dependencies on DNS, particularity, A, TXT and SRV records.
For each kubernetes pod that spins up, i need it to register itself into DNS.
Then the other services can discover themselves.

Here is a basic excerpt of enabling DDNs updates on example.com

Install the basics

apt-get install bind bind9utils dnsutils

Forward Lookup Zone

cat > /etc/named/db.example.com.conf <<EOF
$ORIGIN .
$TTL 86400      ; 1 day
example.com             IN SOA  example.com. root.example.com. (
                                3          ; serial
                                604800     ; refresh (1 week)
                                86400      ; retry (1 day)
                                2419200    ; expire (4 weeks)
                                86400      ; minimum (1 day)
                                )
                        NS      ns1.example.com.
$ORIGIN example.com.
ns1                     A       10.1.1.6 ; replace with your server IP address.
EOF

Reverse Lookup Zone

cat > /etc/named/db.10.1.1.conf <<EOF
$TTL    86400
@       IN      SOA     example.com. root.example.com. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                          86400 )       ; Negative Cache TTL
;
@       IN      NS      ns1.example.com.
6       IN      PTR     ns1.example.com. ; replace 6 with your server ip last octet
EOF

Named local config (should be included from named.conf)

cat > /etc/named/named.conf.local <<EOF
zone "example.com" IN 
{
  type master;
  file "/etc/bind/db.example.com.conf";
  notify no;
  allow-query {any;};
  allow-update { key "rndc-key"; };
};

zone "1.1.10.in-addr.arpa" {
  type master;
  notify no;
  file "/etc/bind/db.10.1.1.conf";
  allow-update { key "rndc-key"; };
};

key "rndc-key" {
  algorithm hmac-md5;
  secret "VBJev6+xzhFVXXYY7tAq4A=="; // this came from the rndc-key file /etc/bind
};
EOF

Key file

cat > /etc/named/rndc-key <<EOF
key "rndc-key" {
  algorithm hmac-md5;
  secret "VBJev6+xzhFVXXYY7tAq4A==";
};
EOF

Fix any permissions issues and restart the server

chown root:bind /etc/bind/*
chmod g+w /etc/bind
systemctl restart bind9.service

Test the DDNS updates works

(
  echo "server 127.0.0.1"
  echo "zone example.com"

  echo "update delete xyz.example.com A"
  echo "update add xyz.example.com 120 A 192.0.2.1"
  echo "send"
) | /usr/bin/nsupdate -k "/etc/bind/rndc.key"

Nslookup for good measure

nslookup xyz.example.com 127.0.0.1