Skip to content
Mementropy
RecipesHomelab recipesReference

Resolving home.arpa names inside K3s pods with coredns-custom

One authoritative zone for internal names, served by K3s CoreDNS.

By Ryan Hammang

Status: Supersedes the hostAliases steps in the Kaneo and Argo CD recipes.

Letting every pod resolve internal names, without per-pod hostAliases.

  • K3s with its bundled CoreDNS (it reads the coredns-custom ConfigMap)
  1. Create coredns-custom in kube-system with a .server block and a zone file:
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns-custom
namespace: kube-system
data:
homelab.server: |
home.arpa:53 {
file /etc/coredns/custom/home.arpa.db home.arpa
}
home.arpa.db: |
$ORIGIN home.arpa.
@ IN SOA ns.home.arpa. admin.home.arpa. 1 3600 600 86400 60
@ IN NS ns.home.arpa.
ns IN A <traefik-address-a>
*.x1 IN A <traefik-address-a>
*.dell IN A <traefik-address-b>
  1. Apply it and restart CoreDNS:
Terminal window
kubectl apply -f coredns-custom.yaml
kubectl -n kube-system rollout restart deploy/coredns
  1. Remove the old hostAliases from your workloads.

From a test pod:

  • dig gitea.example.home.arpa returns NOERROR with the address.
  • dig AAAA gitea.example.home.arpa returns NOERROR with no answers.
  • dig dl-cdn.alpinelinux.org.home.arpa returns NXDOMAIN.
  • apk add works in an Alpine pod.
  • A hosts block in an .override file crash-loops CoreDNS: this plugin can only be used once per Server Block.
  • A hosts block with nothing after it answers SERVFAIL for unknown names. musl (Alpine) stops on SERVFAIL while walking search domains.
  • template runs before hosts in CoreDNS’s plugin order, so an NXDOMAIN template hides every hosts entry.
  • The file plugin avoids all three.