<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>external-dns on </title>
    <link>/tags/external-dns/</link>
    <description>Recent content in external-dns on </description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Sat, 22 Aug 2026 17:09:00 +0800</lastBuildDate><atom:link href="/tags/external-dns/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>用 external-dns 接管 homelab 的子域名 DNS</title>
      <link>/posts/external-dns-httproute-cloudflare-homelab/</link>
      <pubDate>Sat, 22 Aug 2026 17:09:00 +0800</pubDate>
      
      <guid>/posts/external-dns-httproute-cloudflare-homelab/</guid>
      <description>背景 这套 homelab 有两个 K3s 集群，对外服务都挂在 meirong.dev 的子域名下，从 Cloudflare Tunnel 进来。2026 年 7 月之前，加一个新子域名固定是两步手改：
改 cloudflare/terraform/terraform.tfvars 里的 ingress_rules，terraform apply 建一条指向 tunnel 的 CNAME； 改集群里的 gateway.yaml，加一条 HTTPRoute 把 hostname 指到 Service。 两处分属不同工具、不同目录，必须同步改。漏一处就是半通：只改 tfvars，流量能转发进来但集群不知道往哪路由；只改 gateway，集群能路由但公网查不到这个名字。当时也没有任何告警会告诉我漏了，我每次都得翻以前的 commit 照抄。
DNS 那一半本来就是冗余的：HTTPRoute 里已经写了 hostname，再去 tfvars 抄一遍不产生任何新信息。既然能从集群状态推出来，就不该让人抄。external-dns 就是干这个的。
external-dns 在做什么 它是一个 controller，把集群里某些资源当作 DNS 的期望状态，按固定周期算出差异，写进 DNS provider。配置上绕不开 source、provider、registry 这三项。
source 是从哪读期望状态，可以是 Service、Ingress，也可以是 Gateway API 的那几种 route（gateway-httproute、gateway-grpcroute、gateway-tlsroute 等）。provider 是往哪写，Cloudflare、Route 53、Google Cloud DNS 之类。
registry 容易被当成可选项跳过。它管的是「这条记录是我建的」这个登记：默认值 txt 会给每条它管的记录额外写一条 TXT，内容形如 heritage=external-dns,external-dns/owner=&amp;lt;owner-id&amp;gt;,external-dns/resource=&amp;lt;source&amp;gt;。没有这层登记，它分不清 zone 里哪些记录归自己管，后面共存和迁移都谈不上。</description>
    </item>
    
  </channel>
</rss>
