Skip to content

Prerequisite script explained

Companion to Install on your own server. That doc gets you running quickly; this one has every command laid out step by step with explanations, plus troubleshooting for when something fails.

Current setup: - prerequisite.sh now runs in two phases. install.sh runs Steps 0–6 (PREREQ_PHASE=base), and the setup wizard runs Steps 7–8 (PREREQ_PHASE=site) once the domain is known. - Every pinned version (k3s, Helm, the APISIX chart, cert-manager) lives in versions.env, together with the list of images that must be copied into Nexus. This doc names the current values, but versions.env wins if they differ. - prerequisite.sh takes no options: it is configured with environment variables put in front of the command (PREREQ_PHASE, DNS_ZONE, ANSWER_IP, ACME_EMAIL, ACME_STAGING, ACMEDNS_HOST, ACMEDNS_ACCOUNT_JSON, ALLOW_PLACEHOLDER_DOMAIN, IBC_SITE_ENV, IBC_KUBE_ACCESS). ./prerequisite.sh --help lists them all with their defaults and examples, and does nothing else; any other option is refused. restore.sh and reset.sh behave the same way. - Mentions of application.md and application.sh below refer to the old manual flow, now in archive/docs/ and archive/scripts/.

prerequisite.sh automates all of Sections 0–8 below. Each script step maps to the doc section of the same number:

Script step What it does Matches
Step 0 Checks sudo exists, installs curl/git/python3/openssh, enables SSH Section 0
Step 0b Sets the machine up as an always-on server: sleep/suspend/hibernate masked, lid and idle ignored (logind), clock sync (timesyncd, unless chrony/ntp already runs), persistent journal, security updates without automatic reboot, hardware watchdog if present; checks the clock against a web server's and stops if it's off by 5 minutes or more Section 0
Step 1 Writes /etc/rancher/k3s/registries.yaml (every image pulled through registry.nexus.castis.io), installs k3s at K3S_VERSION from versions.env, disables Traefik, waits for node Ready Section 1
Step 2 Installs Helm at HELM_VERSION from versions.env Section 2
Step 3 Applies nexus-registry-secret to ingress-apisix (the APISIX, etcd and ingress-controller images come from the private Nexus registry), then installs APISIX + ingress-controller via Helm (chart APISIX_CHART_VERSION, currently 2.15.0, with APISIX core pinned DOWN to 3.13.0 and ingress-controller at 2.1.0 — see "Why APISIX is pinned to 3.13.0" below), patches apisix-gateway to LoadBalancer if needed Section 3
Step 4 Auto-detects the admin key, applies GatewayProxy + IngressClass Section 4
Step 5 Deploys httpbin, applies a test ApisixRoute, curls it, then deletes the test resources and prints a final TEST PASSED/TEST FAILED result Section 5
Step 6 Applies cert-manager CRDs, nexus-registry-secret to cert-manager, installs cert-manager via Helm (CERT_MANAGER_VERSION), confirms the webhook's CA bundle is actually injected Section 6
Step 6b Installs Kyverno via Helm (KYVERNO_VERSION, chart and images from Nexus) with nexus-registry-secret in the kyverno namespace, waits for the pods and the ImageValidatingPolicy CRD Section 6b
Step 7 Applies the acme-dns-account Secret (this site's acme-dns account, from the setup wizard), the letsencrypt-prod ClusterIssuer (DNS-01 via acme-dns), a wildcard Certificate for the site's domain, and the ApisixTls wiring the result into APISIX Section 7
Step 8 Auto-detects this node's LAN IP (NODE_IP), applies the committed coredns/coredns-configmap.yaml (rendered via envsubst with the DNS zone name and ANSWER_IP substituted — defaults to NODE_IP unless overridden, piped directly to kubectl apply) and coredns/coredns-deployment.yaml, deploying a standalone LAN-facing CoreDNS via hostNetwork for a custom internal DNS zone (e.g. your-domain.example.com) and a second, standalone internal TLD (playtelly.internal, used by the playtellyinternal/client-conf application service), then verifies resolution of both from this node Section 8

The script is idempotent — every step checks "does this already exist?" first, so it's always safe to fix a problem and re-run the whole thing rather than trying to resume mid-way.

cert-manager IS part of this script (Steps 6–7). An earlier version of this project used a private CA instead (self-signed root, imported manually into every client device's trust store); prerequisite.sh no longer runs that. The current approach gets a Let's Encrypt certificate through a DNS-01 challenge, answered by acme-dns: the site holds only its own acme-dns account, which can update nothing but its own challenge record. Castis creates that account, and the _acme-challenge CNAME in the real castis.io zone, when it approves the site through the edge API (edge-api.md), so no Cloudflare token is ever stored on the site. This has three concrete advantages over the private-CA approach: certificates are trusted automatically by every browser/OS (no per-device CA import needed), it supports wildcard certificates the same way the private CA did, and it works whether or not the hostname is proxied, since DNS-01 never touches HTTP traffic at all. See Sections 6–7 below for how it's wired into this script. This cluster now terminates its own TLS for your-domain.example.com directly — it no longer relies solely on a separate public gateway server for that.

This project uses the classic ApisixRoute CRD throughout, not the Kubernetes Gateway API (HTTPRoute/Gateway/GatewayClass). An HTTPRoute conversion was tested during the investigation that led to the version pin below, and did not resolve the issue either — confirming the root cause is inside APISIX core itself, not specific to which CRD type is used. There's no reason to introduce that added complexity here.

If prerequisite.sh fails at a specific step

Failed at Likely cause What to do
Step 0 Not logged in with sudo access yet Follow the script's printed instructions (Section 0)
Step 0b ERROR: this machine's clock is off by …s NTP can't fix the clock (UDP 123 blocked?). Set it once with the sudo date -s … command the script prints, then re-run (Step 0b)
Step 1 k3s install failed, or slow VM sudo journalctl -u k3s -n 50 (Section 1)
Step 1 (or a pod fails right after with FailedCreatePodSandBox/flannel 'subnet.env'... no such file or directory) Traefik-disable restart raced flannel's own re-init — script now waits for /run/flannel/subnet.env directly, but a pod scheduled just before this fix existed could still hit it Delete the affected pod (kubectl delete pod <name> -n <namespace>) and let it recreate now that flannel has caught up (Section 1)
Step 2 Network issue reaching Helm's install script Retry the curl command directly (Section 2)
Step 3 Script seems stuck at "Still waiting on: ..." for a very long time, or gateway stuck <pending> Normal on a fresh install pulling images for the first time; if it's been many minutes with no progress, check kubectl describe pod <name> -n ingress-apisix for a real error — very often an ImagePullBackOff, since images now pull from the private Nexus mirror and need nexus-registry-secret present (Section 3). If the only pod listed as "still waiting on" is a one-shot Job pod like apisix-etcd-pre-upgrade-*, this is a different, already-fixed issue — see "The apisix-etcd-pre-upgrade false-stuck bug" below.
Step 4 Configmap not ready, or key extraction failed Manual lookup command the script prints (Section 4.1)
Step 5 Final result says TEST FAILED Section 4's "third" or "fourth" failure mode (transient admin API/backend not ready — script already adds buffer sleeps for this) or Section 4/5's "how to tell which fix" check below
Step 6 cert-manager pods not Ready, or webhook CA bundle never appears Section 6's troubleshooting — usually an ImagePullBackOff (same Nexus-secret pattern as Step 3) or the webhook needing a little longer to finish injecting its CA bundle
Step 7 Script exits immediately citing a missing file or "no acme-dns account"; or the Certificate never reaches Ready Section 7's troubleshooting — check the three required cert-manager/ files exist, the site was approved (the wizard passes the acme-dns account in), and kubectl describe challenge -n ingress-apisix for the real error if it's stuck
Step 8 Port 53 conflict reported on this node, or DNS test fails Section 8's "Whether this 'just works'…" and "Manual steps required after Step 8 finishes", and the troubleshooting table below

Why APISIX is pinned to 3.13.0 (not the chart's newer 3.17.0 default)

This is a real, confirmed regression, discovered through direct investigation — not a guess or a cautious downgrade "just in case."

The symptom

Any backend behind APISIX that relies on the standard X-Forwarded-Proto header to determine whether the original client connection was HTTPS (e.g. tusd's -behind-proxy flag, used to generate correct absolute upload URLs) would receive http even when explicitly told, via proxy-rewrite, serverless-pre-function, or any other documented plugin mechanism, to report https. This specifically breaks any architecture where a public-facing gateway terminates real HTTPS, then forwards to this private cluster over plain HTTP (e.g. over a Tailscale tunnel that already provides its own transport encryption, so a second TLS layer felt unnecessary) — a completely standard, reasonable pattern.

What was actually tried, and ruled out, before finding the real cause

  • proxy-rewrite plugin alone — did not work
  • proxy-rewrite + redirect combined — did not work (and separately revealed a real plugin-ordering bug, see the troubleshooting table further down)
  • Converting the route from ApisixRoute to Kubernetes Gateway API's HTTPRoute — did not work, ruling out CRD type as the cause
  • serverless-pre-function at the "rewrite" phase — did not work
  • serverless-pre-function at the "before_proxy" phase (the current name for what was called "balancer" prior to APISIX v2.12.0) — did not work

The actual proof

A disposable echo-server backend (mendhak/http-https-echo), temporarily swapped in as the route's target, revealed the real header APISIX was sending upstream:

"x-forwarded-proto": "http",
"x-forwarded-port": "9080"
9080 is APISIX's own internal plain-HTTP listening port. This is not a plugin bug — it's APISIX's core nginx template deriving X-Forwarded-Proto/X-Forwarded-Port directly from the genuine, physical connection scheme it received, at a level no Lua plugin (regardless of phase) can override. Since the actual Server1→Server2 hop genuinely is plain HTTP, APISIX was — from its own internal logic's perspective — telling the truth. No plugin can make it lie about a connection that is, in physical reality, HTTP.

The fix, confirmed via the same echo-server test

Downgrading APISIX core to 3.13.0 (matching a separate, already-working comparison environment) resolved this immediately — the same echo-server test, re-run after the downgrade, showed the header correctly reflecting https when it should. This points to a genuine regression introduced in APISIX core somewhere between 3.13.0 and 3.17.0.

The ingress controller was not downgraded: it runs the chart's own 2.1.0. (An earlier version of this doc said 2.0.1; the sites have in fact run 2.1.0. The image and resources keys also used to sit at the wrong level in the values file, where the subchart ignored them; they are now under ingress-controller.deployment.)

Open question: the ingress-controller admission webhook

ingress-controller.webhook.enabled is true in apisix/apisix-values.yaml, because that is the combination (APISIX 3.13.0 + controller 2.1.0 + webhook on) every site has run so far. The chart's own values.yaml says this webhook needs APISIX 3.17.0 or later. It runs with failurePolicy: Ignore, so it can't block a route from being applied, but it may not validate anything on 3.13.0 either. Still to decide: keep it, or set enabled: false. The same note sits in the header of apisix/apisix-values.yaml.


Section 0 — Base tools on a fresh Debian VM

Debian's minimal netinst install ships with almost nothing — no sudo, curl, or git. These have to go in first, and manually, since nothing else can be fetched without them.

su -
Switch to root using the password set during install.

apt update
apt install sudo -y
usermod -aG sudo yourusername   # replace with your actual username
exit
Installs sudo itself, then adds your regular user to the sudo group. Only needed if you set a root password during install: then Debian (unlike Ubuntu) does not do this automatically. With an empty root password, Debian installs sudo and gives your user access itself (Prepare a VM).

newgrp sudo
sudo whoami
newgrp refreshes your current session's group membership without a full logout. sudo whoami should print root — that's your confirmation sudo now works.

sudo apt update
sudo apt install curl git python3 openssh-server -y
Installs the tools everything else depends on. python3 is needed by Step 1 (it reads the Nexus login out of registry-secret.yml) and by the setup wizard.

sudo systemctl enable ssh
sudo systemctl start ssh
sudo ss -tlnp | grep :22
enable = start automatically on every future boot. start = start it right now. The ss command confirms something is actually listening on port 22.

ip a
Find the VM's IP address, so you can SSH in from your host machine's terminal instead of typing everything into the VM console — this also gives you normal, working copy/paste.

If you hit sudo: user is not in the sudoers file: this means the usermod -aG sudo step above didn't take effect yet in your current session — log out and back in (or run newgrp sudo), then retry.

Step 0b — Run as an always-on server

A hotel server has to survive power cuts and never idle out. Step 0b sets this machine up for that. Each item is safe to re-run:

What How Why
No sleep systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target The machine must never suspend itself
Lid, suspend/hibernate keys and idle ignored /etc/systemd/logind.conf.d/ibc-server.conf (read at next boot) A laptop lid or a stray key press must not stop the server
Clock sync Installs systemd-timesyncd and runs timedatectl set-ntp true, unless chrony, ntpsec or ntp is already running (then left alone) Certificates and login tokens fail if the clock drifts
Logs kept across reboots /etc/systemd/journald.conf.d/ibc-server.conf (Storage=persistent, SystemMaxUse=500M), then restarts journald To see what happened before a power cut: journalctl -b -1 shows the previous boot
Security updates Installs unattended-upgrades; /etc/apt/apt.conf.d/20auto-upgrades turns it on, 52ibc-no-auto-reboot sets Automatic-Reboot "false" Security fixes install by themselves (Debian's default: security origin only), but a reboot only happens when someone chooses
Clock check Compares the clock with google.com's Date header over plain HTTP. If it's off by 300 s or more, restarts timesyncd and re-checks for 30 s; still off → stops with the sudo date -s … command to fix it A wrong clock makes every HTTPS download fail ("certificate is not yet valid"), and freshly restored or paused VMs often have one
Hardware watchdog Only if /dev/watchdog exists: /etc/systemd/system.conf.d/ibc-watchdog.conf (RuntimeWatchdogSec=60s), then systemctl daemon-reexec Reboots the machine if it hangs. VirtualBox VMs usually have no watchdog; the script says so and moves on

If this machine is a VM, its host must also power on and start the VM by itself after a power cut. For a Mac mini host, run host/macos/setup-host.sh there once (Prepare a VM, Mac host and power-cut tests).


Section 1 — Install k3s (single-node, standalone)

Pull every image through Nexus: /etc/rancher/k3s/registries.yaml

Before installing k3s, the script writes /etc/rancher/k3s/registries.yaml, so containerd pulls public images from their copies in registry.nexus.castis.io (MIRROR_REGISTRY in versions.env) instead of the public registries:

# Written by prerequisite.sh -- see versions.env (MIRROR_REGISTRY).
mirrors:
  docker.io:
    endpoint: ["https://registry.nexus.castis.io"]
    rewrite:
      "^library/(.*)": "$1"
  quay.io:
    endpoint: ["https://registry.nexus.castis.io"]
  ghcr.io:
    endpoint: ["https://registry.nexus.castis.io"]
  public.ecr.aws:
    endpoint: ["https://registry.nexus.castis.io"]
    rewrite:
      "^docker/library/(.*)": "$1"
configs:
  "registry.nexus.castis.io":
    auth:
      username: "<from registry-secret.yml>"
      password: "<from registry-secret.yml>"
  • Same path and tag in Nexus. An image such as quay.io/argoproj/argocd:v3.1.0 is fetched as registry.nexus.castis.io/argoproj/argocd:v3.1.0. The two rewrite rules drop Docker Hub's library/ and public ECR's docker/library/ prefixes, so docker.io/library/busybox:1.28 becomes registry.nexus.castis.io/busybox:1.28. The list of images that must be copied into Nexus, and how to copy them, is in versions.env.
  • The login is read from registry-secret.yml: the .dockerconfigjson entry for registry.nexus.castis.io (the pull-only user regis-read). The script exits if the file or that entry is missing. Because containerd itself has the login, pods need no pull secret for these mirrored pulls.
  • The file holds a password, so it's written with mode 600. It's only rewritten when its content changes; if k3s is already installed, the script then restarts k3s so the new settings take effect.
  • Fallback. If an image under a public name (k3s system images, Argo CD, busybox, the ADC sidecar, go-httpbin) is missing from Nexus, containerd quietly falls back to the public registry. That keeps a site working, but it also hides a gap in Nexus, so keep the versions.env list complete. Images that manifests reference by their Nexus path (registry.nexus.castis.io/...: APISIX, etcd, ingress-controller, cert-manager, CoreDNS, the apps) have no fallback: a missing one stops the pod.

Install k3s at the pinned version

sudo apt update && sudo apt upgrade -y
. versions.env
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION="$K3S_VERSION" sh -
This one command installs k3s (the version in versions.env, currently v1.36.4+k3s1) as a systemd service in server mode — which also runs workloads itself, so no separate agent/worker is needed for a single-node cluster. (The script itself doesn't run apt upgrade.)

If k3s is already installed, the script skips the install. If the installed version differs from K3S_VERSION, it prints a note and leaves it: upgrading an existing k3s is a separate, deliberate step.

Disabling Traefik — required, since APISIX needs ports 80/443

k3s ships with Traefik as its default ingress controller, and by default tries to bind it to host ports 80/443. Since APISIX (installed later, in this same doc's Section 3 / prerequisite.sh) is meant to own those exact ports via its own LoadBalancer service, leaving Traefik enabled causes a real, observed problem: k3s's helm-install-traefik and helm-install-traefik-crd install Jobs get stuck in a permanent CrashLoopBackOff — confirmed directly on a real cluster, showing 68+ restarts over 2 days.

K3S_CONFIG="/etc/rancher/k3s/config.yaml"
sudo mkdir -p /etc/rancher/k3s
printf 'disable:\n  - traefik\n' | sudo tee -a "$K3S_CONFIG" > /dev/null
sudo systemctl restart k3s

Why keep svclb (don't disable that too): svclb is the small helper k3s uses to actually bind a LoadBalancer-type Service to the node's real network interface — it's what makes APISIX's own gateway Service get a real, working EXTERNAL-IP instead of sitting at <pending> forever. Traefik and svclb are separate, independent pieces — disabling Traefik doesn't touch svclb at all.

This check runs on every prerequisite.sh execution, not just fresh installs — deliberately self-healing, so re-running the script against an already-installed cluster (like one that was set up before this fix existed) will detect Traefik is still enabled and fix it retroactively, rather than only helping brand-new installs:

if sudo test -f "$K3S_CONFIG" && sudo grep -qE '^\s*-\s*traefik\s*$' "$K3S_CONFIG"; then
  echo "Traefik already disabled."
else
  # ...add the disable directive, restart k3s...
fi

After disabling, the script also cleans up any leftover crash-looping install-job resources that may already exist from before the fix:

kubectl delete job -n kube-system helm-install-traefik helm-install-traefik-crd --ignore-not-found=true
kubectl delete helmchart -n kube-system traefik traefik-crd --ignore-not-found=true

Waiting for flannel to regenerate after the restart — confirmed real, not theoretical

sudo systemctl restart k3s (right after disabling Traefik) also restarts flannel, k3s's embedded CNI. The node can report kubelet-level Ready before flannel finishes regenerating its own networking state file — if a pod gets scheduled in that window, its sandbox creation fails outright:

Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network
for sandbox "...": plugin type="flannel" failed (add): failed to load flannel 'subnet.env'
file: open /run/flannel/subnet.env: no such file or directory
This was hit live during testing — the APISIX pod (installed in Section 3) got scheduled right after this restart and failed exactly this way. The fix: since this script runs directly on the node itself, it can check for the file directly rather than guessing a fixed delay:
while ! sudo test -f /run/flannel/subnet.env; do
  echo "Still waiting on /run/flannel/subnet.env..."
  sleep 3
done
No timeout — same "wait as long as actually needed" philosophy used throughout this script. If a pod already hit this failure before the wait catches up, deleting it (kubectl delete pod <name> -n <namespace>) lets its ReplicaSet/StatefulSet recreate it once the node's networking has caught up; no need to re-run the whole script.

To verify manually, any time:

kubectl get pods -n kube-system | grep traefik   # should be empty
kubectl get pods -n kube-system | grep svclb      # should show Running

sudo systemctl status k3s
sudo k3s kubectl get nodes
Confirms the service is active (running), and that your node shows status Ready.

Optional — use kubectl without the sudo k3s prefix:

mkdir -p ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown $(id -u):$(id -g) ~/.kube/config
echo 'export KUBECONFIG=~/.kube/config' >> ~/.bashrc
source ~/.bashrc
kubectl get nodes
k3s's config file is only readable by root by default. This copies it to your own ~/.kube/config (the standard location kubectl looks for) and changes its owner to you, so you don't need sudo for every kubectl command afterward.

Quick sanity test:

kubectl create deployment nginx --image=nginx
kubectl get pods

If the node never shows Ready: check sudo journalctl -u k3s -n 50 for the actual error — often a slow VM just needs more time, or a network/firewall issue is blocking k3s's internal components from starting.


Section 2 — Install Helm

. versions.env
curl -fsSL "https://raw.githubusercontent.com/helm/helm/$HELM_VERSION/scripts/get-helm-3" | DESIRED_VERSION="$HELM_VERSION" bash
helm version
Helm is a package manager for Kubernetes — it lets us install APISIX (and its ingress controller, etcd, etc.) as one bundled "chart" instead of hand-writing every YAML manifest ourselves. The script installs HELM_VERSION from versions.env (currently v3.22.0; the scripts use Helm 3), and skips this step if helm is already installed. helm version should print version.BuildInfo{Version:"v3.22.0"....

If the install script fails: usually a network issue — check general internet connectivity first with curl -I https://github.com.


Section 3 — Install Apache APISIX + Ingress Controller

helm repo add my-nexus https://nexus.castis.io/repository/helm-hosted/ \
  --username helm --password <NEXUS_HELM_PASS>
helm repo update

kubectl create ns ingress-apisix

kubectl apply -f registry-secret.yml -n ingress-apisix

helm install apisix my-nexus/apisix \
  --version "$APISIX_CHART_VERSION" \
  --namespace ingress-apisix \
  -f apisix/apisix-values.yaml

APISIX_CHART_VERSION comes from versions.env (currently 2.15.0).

Charts come only from the Nexus Helm repository (https://nexus.castis.io/repository/helm-hosted/). There is no public-repo fallback for charts: every install uses the exact chart copied into Nexus, never "whatever's currently public", so results stay reproducible across machines and over time. The same repo (my-nexus) serves the cert-manager chart in Section 6.

Open follow-up: the Helm login. The script logs in to that repo as helm with a password kept in prerequisite.sh (NEXUS_HELM_PASS), the same account used for both the APISIX and cert-manager charts. It is not a pull-only account (unlike regis-read for images). It should be replaced by a read-only Helm user; prerequisite.sh hasn't been changed yet.

The kubectl apply -f registry-secret.yml -n ingress-apisix step is required. The three main images this chart deploys (apisix, etcd, ingress-controller) are named by their Nexus path (registry.nexus.castis.io/apisix/...) instead of their public defaults, so they have no public fallback. Pulling from a private registry requires credentials, so this secret has to exist in ingress-apisix before the Helm install runs, same reasoning as every namespace Argo CD deploys into (gitops/components/site-base). Skipping this step causes ImagePullBackOff on all three pods.

Two more images come in under their public names and are pulled through the k3s mirror (Section 1), so they fall back to the public registry if Nexus lacks them: the chart's wait-etcd init container (docker.io/library/busybox:1.28) and the ingress controller's ADC sidecar (ghcr.io/api7/adc:0.26.0). Both are on the versions.env copy list.

apisix/apisix-values.yaml holds (its header comment, left out here, repeats the version choice and the webhook open question):

global:
  imagePullSecrets:
    - nexus-registry-secret
  security:
    allowInsecureImages: true

image:
  repository: registry.nexus.castis.io/apisix/apisix
  tag: 3.13.0-ubuntu

service:
  type: LoadBalancer

apisix:
  ssl:
    enabled: true
  pluginAttrs:
    redirect:
      https_port: 443

etcd:
  replicaCount: 1
  persistence:
    size: 2Gi
  image:
    registry: ""
    repository: registry.nexus.castis.io/apisix/etcd
    tag: 3.6.4-debian-12-r4
  resources:
    requests:
      cpu: 200m
      memory: 256Mi
    limits:
      cpu: 500m
      memory: 512Mi

resources:
  requests:
    cpu: 200m
    memory: 256Mi
  limits:
    cpu: 1000m
    memory: 512Mi

ingress-controller:
  enabled: true
  webhook:
    enabled: true
  config:
    apisix:
      serviceNamespace: ingress-apisix
  # The subchart reads image and resources under deployment:, not at the
  # top level.
  deployment:
    image:
      repository: registry.nexus.castis.io/apisix/ingress-controller
      tag: "2.1.0"
    resources:
      requests:
        cpu: 100m
        memory: 128Mi
      limits:
        cpu: 300m
        memory: 256Mi

This doc explains why each setting is there; the file keeps only short comments.

image.tag: 3.13.0-ubuntu — deliberately older than the chart's own default (3.17.0-ubuntu). See "Why APISIX is pinned to 3.13.0" at the top of this doc for the full investigation and proof behind this decision — this is not an oversight or a stale value, it's a confirmed-necessary downgrade. ingress-controller.deployment.image.tag: "2.1.0" is the chart's own default, pinned here so it points at the Nexus copy.

ingress-controller.deployment, not ingress-controller.image. The ingress-controller subchart reads its image and resources under deployment:. At the top level of ingress-controller: they are silently ignored.

ingress-controller.webhook.enabled: true — open question. This admission webhook validates ApisixRoute/CRD YAML before Kubernetes accepts it. The chart's own values.yaml documents it as requiring APISIX 3.17.0+, and this project runs 3.13.0. It runs with failurePolicy: Ignore, so it can't block a route, but it may not validate anything either. It stays on for now because that's what every site has run; see "Open question: the ingress-controller admission webhook" at the top of this doc.

global.imagePullSecrets — confirmed structure, not guessed. Verified directly against the chart's actual defaults:

helm show values my-nexus/apisix --version 2.15.0 | grep -n -i pullSecret
This returned a single match, under global:, expecting a flat array of secret name strings (Bitnami-style: - nexus-registry-secret), not the native Kubernetes {name: ...} object format used directly in a pod spec's imagePullSecrets: field. Placed under global specifically because this is an umbrella chart — Helm automatically propagates global values down into every subchart, so this single entry covers image pulls for the main apisix pod, the etcd subchart, and the ingress-controller subchart all at once, without needing three separate settings.

global.security.allowInsecureImages: true. Bitnami-based subcharts (used for etcd) validate the final image reference against their own known-approved list; since this project intentionally uses a private Nexus mirror instead of Bitnami's official image, this flag explicitly acknowledges that choice — without it, the Helm install fails outright with a security warning treated as an error.

apisix.pluginAttrs.redirect.https_port: 443. By default, when the redirect plugin's http_to_https option fires, it redirects to APISIX's own internal HTTPS port (9443), not the real externally-facing port your clients actually connect to. This value explicitly tells APISIX which port to put in the redirect URL instead. Note: this chart key is pluginAttrs (camelCase) — a different naming convention than APISIX's own internal config format, which uses plugin_attr (snake_case); the Helm chart's templating converts one to the other.

etcd.image.registry: "". Bitnami-based charts split their image reference into three separate fields (registry, repository, tag), not just two — the default registry value is docker.io, which would otherwise get silently prepended in front of the already-complete Nexus path, producing a broken double-prefixed image reference. Setting this to an empty string avoids that.

service.type: LoadBalancer, not gateway.type. Several official APISIX docs and tutorials instruct --set gateway.type=LoadBalancer — but checking the chart's actual values.yaml directly shows there is no top-level gateway key at all. Helm doesn't error on an unknown path — it just silently creates an unused value that nothing reads, so gateway.type=LoadBalancer looked correct but did nothing. Using the correct path, service.type, sets it right the first time — no patch needed afterward.

apisix.ssl.enabled: true opens port 9443 for HTTPS traffic — it doesn't give you a working HTTPS route by itself, just makes the port available.

etcd.replicaCount: 1 and etcd.persistence.size: 2Gi. The chart defaults to a 3-replica etcd cluster with an 8Gi PVC each — that's meant for high-availability across multiple physical nodes. On this single-node VM, all 3 replicas would just get scheduled onto the same node anyway, so you'd pay for 3× the memory/CPU/disk (24Gi total) with none of the actual redundancy benefit. One replica with a smaller 2Gi volume is plenty for a route config store at this scale, and saves real resources on the VM.

Does the data survive a pod restart? Yes — Bitnami's etcd subchart enables PVC-backed persistence by default, and Kubernetes doesn't auto-delete that PVC just because the pod or StatefulSet gets removed (you'd have to kubectl delete pvc explicitly to lose it). So this is already safe without extra configuration.

etcd.image.tag: 3.6.4-debian-12-r4. The chart's default etcd image tag is latest, which floats — a fresh install months from now could silently pull a different build than what this guide was tested against. Checking the bitnamilegacy/etcd registry directly shows real versioned tags do exist (despite the chart's own comment suggesting otherwise) — 3.6.4-debian-12-r4 was the most recent one at the time of writing. Note that bitnamilegacy is an explicitly frozen/archived image repository — it will not receive future security patches regardless of which tag you pin to, and mirroring it to Nexus doesn't change that; it only removes the runtime dependency on the public internet for this specific pull.

Resource requests/limits — three separate settings, one per component. This is worth being precise about, since it's easy to assume one resources: block covers everything. The apisix chart is really three independent components (main gateway pod, etcd subchart, ingress-controller subchart), each with its own resources key — setting the top-level one only caps the gateway pod, not the other two:

Component Values path Requests Limits
APISIX gateway (main pod) resources.* 200m CPU / 256Mi mem 1000m CPU / 512Mi mem
etcd etcd.resources.* 200m CPU / 256Mi mem 500m CPU / 512Mi mem
ingress-controller ingress-controller.deployment.resources.* 100m CPU / 128Mi mem 300m CPU / 256Mi mem

None of these are set by the chart by default at all — on a single VM running k3s + all three of these + whatever else you deploy later, any one component with no cap could starve the others under load. These values are deliberately generous (roughly double the chart's own minimal example) to give real headroom as you add routes/traffic, rather than the tightest possible values.

Important — these are still starting values, not measured ones. Check real usage once you have actual routes/traffic running:

kubectl top pods -n ingress-apisix
(k3s includes metrics-server by default, so this works out of the box.) Compare current usage against the limits above. If usage sits consistently close to a limit, or you see restarts, that's the signal to raise it — not something to preemptively guess right.

How to spot a resource-limit problem after the fact:

kubectl get pods -n ingress-apisix
kubectl describe pod <pod-name> -n ingress-apisix
Check the RESTARTS column, and in the describe output, the Last State section — OOMKilled there means the memory limit was too low and Kubernetes killed the pod.

Chart version 2.15.0, fixed (APISIX_CHART_VERSION in versions.env). The apisix chart is an "umbrella chart" — its own version number doesn't match the APISIX app version bundled inside it. Chart 2.15.0's own defaults deploy APISIX core 3.17.0 + ingress-controller 2.1.0; this project overrides APISIX core down to 3.13.0 via the values file (see "Why APISIX is pinned to 3.13.0" above) and keeps ingress-controller at 2.1.0. The chart version itself stays at 2.15.0 regardless, since chart version and app image versions are independently settable here.

Note: --version stays as a CLI flag rather than moving into the values file — chart version selection isn't itself a chart value, it's a Helm CLI-level argument, so this is the correct/only place for it.

Verify:

kubectl get pods -n ingress-apisix
kubectl get svc -n ingress-apisix
You should see apisix, apisix-etcd, and apisix-ingress-controller pods running, and an apisix-gateway service of type LoadBalancer with an external IP — this is your entry point for all traffic going forward.

If a pod shows ImagePullBackOff here: almost certainly the registry secret step above was skipped, or nexus-registry-secret doesn't exist/isn't correct in the ingress-apisix namespace specifically. Check:

kubectl describe pod <pod-name> -n ingress-apisix
kubectl get secret nexus-registry-secret -n ingress-apisix

If apisix-gateway still isn't type LoadBalancer, patch it directly as a fallback:

kubectl patch svc -n ingress-apisix apisix-gateway \
  -p '{"spec": {"type": "LoadBalancer"}}'
On bare-metal/local clusters like this single-node VM, there's normally no cloud provider to hand out a real external IP for LoadBalancer type services — but k3s ships with a built-in load balancer called Klipper LB, which usually assigns one automatically anyway (typically the node's own IP). If EXTERNAL-IP still shows <pending> after a minute, use the NodePort shown in the service's PORT(S) column against your VM's IP instead — that always works regardless.

The apisix-etcd-pre-upgrade false-stuck bug (fixed)

Symptom: prerequisite.sh appears to hang forever in Step 3's pod-ready wait loop, printing something like:

Still waiting on: apisix-etcd-pre-upgrade-5z7kc
Still waiting on: apisix-etcd-pre-upgrade-5z7kc
Still waiting on: apisix-etcd-pre-upgrade-5z7kc
on repeat, even though kubectl get pods -n ingress-apisix shows that pod's STATUS as Completed, not Running or crashing.

Root cause: apisix-etcd-pre-upgrade-* is a one-shot Job pod (part of the Bitnami etcd subchart, used to run pre-upgrade checks/migrations), not a long-running app pod. Once it finishes successfully, Kubernetes correctly reports it as STATUS: Completed — but its READY column stays at 0/1 forever, since a finished Job pod is never going to become "ready" in the same sense a Deployment pod would. A wait loop that only checks the READY column:

awk '{split($2,a,"/"); if (a[1] != a[2]) print $1}'
flags 0/1 as "not ready" unconditionally — with no exception for a pod that's actually done, not stuck — so it would spin forever waiting for a READY state a completed Job pod will never reach.

The fix, in prerequisite.sh: the same awk check also inspects the STATUS column ($3) and excludes anything already Completed from the not-ready list, exactly mirroring the pattern wait_for_label_ready() uses in the archived archive/scripts/application.sh:

awk '{split($2,a,"/"); status=$3; if (status != "Completed" && a[1] != a[2]) print $1}'
A short reminder comment now sits directly above this loop in the script itself, so the reasoning isn't lost the next time someone edits it:
echo "NOTE: one-shot Job pods (e.g. apisix-etcd-pre-upgrade-*) legitimately report"
echo "READY 0/1 forever once they finish -- that's normal for a Job, not a stuck"
echo "pod, so STATUS=Completed is excluded from the not-ready check below."

If you still see this hang after pulling the latest prerequisite.sh: first confirm the pod really is Completed and not genuinely stuck for a different reason:

kubectl get pods -n ingress-apisix
kubectl describe pod <pod-name> -n ingress-apisix | tail -30
If it shows CrashLoopBackOff or Error instead of Completed, that's a real, separate failure worth investigating via kubectl logs <pod-name> -n ingress-apisix — most often caused by re-running the Helm install/upgrade against an etcd volume that already has data from a previous install.


Section 4 — Wire up GatewayProxy + IngressClass (critical fix)

Without this section, ApisixRoute CRDs will be created successfully in Kubernetes but silently never sync to the actual APISIX data plane. This was the single biggest issue we hit building this setup — worth reading carefully.

What goes wrong without it

The ingress controller has no idea how to reach APISIX's Admin API. Its logs repeat, once per sync cycle:

INFO  provider.client  client/client.go:219  no GatewayProxy configs provided
Every route gets created fine in Kubernetes, but never actually pushed into APISIX's routing engine — the controller has nowhere to push it to. curl against any route returns:
{"error_msg":"404 Route Not Found"}
even though kubectl get apisixroute shows the resource exists with no errors.

A third, different failure mode: transient ECONNREFUSED on port 9180

Even with GatewayProxy correctly applied, you may see errors like this in the ingress-controller logs, especially right after a fresh install:

ERROR provider.executor  failed to run http sync for server
{"server": "http://apisix-admin.ingress-apisix.svc.cluster.local:9180",
 "error": "...connect ECONNREFUSED 10.43.x.x:9180"}
This is not a missing GatewayProxy or ingressClassName — both can be completely correct while this still happens. It means the APISIX pod itself shows Running, but its admin API listener (port 9180) hasn't actually finished starting yet — Kubernetes' readiness probe can pass slightly before the internal Nginx/Admin API is fully ready to accept connections. This is transient: the errors stop appearing on their own once APISIX finishes starting, typically within 30 seconds to a couple of minutes.

The fix (log-based check): prerequisite.sh waits, with no timeout, right after applying GatewayProxy — it tails the ingress-controller's own logs every 20 seconds and looks for the exact signal that things have settled: no ECONNREFUSED in the recent lines, and a "syncing resources for config" line present, confirming a clean sync cycle actually completed. This checks the real evidence of success (the controller's own log output) rather than guessing a fixed wait time.

If it still fails despite the clean-sync check passing: the script is idempotent — just re-run it. It'll skip everything already installed and go straight back to re-checking/re-testing.

A fourth failure mode: the test backend (httpbin) itself wasn't ready yet

The route reaching APISIX correctly doesn't guarantee its backend is ready to answer. kubectl create deployment httpbin starts pulling that image, which can take longer than the test's retry window — if it does, APISIX correctly routes the request but gets no healthy backend, returning a 502/503. curl -sf treats any non-2xx response the same as a connection failure, so this can look identical to the admin-API-not-ready problem despite being a completely different cause.

The fix: prerequisite.sh waits, with no timeout, for the httpbin pod specifically to show Ready (same polling loop pattern as the main pod-ready check, checking every 10 seconds), then adds a short 10-second buffer sleep before creating the route or testing — so by the time the route test begins, both the admin API and the backend have had time to settle, and only the ingress-controller's own sync cycle remains as a variable.

4.1 Find your admin key

kubectl get configmap -n ingress-apisix apisix -o yaml | grep -A3 admin_key
Look for the key: value under name: "admin". Note: this chart's default admin key is a well-known, publicly documented value (<REDACTED>; see the APISIX chart's documentation) — fine for a local/experimental VM, but worth changing via --set admin.credentials.admin=... at install time if this ever gets exposed beyond your local network.

4.2 Create GatewayProxy + IngressClass

cat > gateway-setup.yaml << 'EOF'
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: apisix
spec:
  controller: "apisix.apache.org/apisix-ingress-controller"
  parameters:
    apiGroup: "apisix.apache.org"
    kind: "GatewayProxy"
    name: "apisix-proxy"
    namespace: "ingress-apisix"
    scope: "Namespace"
---
apiVersion: apisix.apache.org/v1alpha1
kind: GatewayProxy
metadata:
  name: apisix-proxy
  namespace: ingress-apisix
spec:
  provider:
    type: ControlPlane
    controlPlane:
      endpoints:
      - http://apisix-admin.ingress-apisix.svc.cluster.local:9180
      auth:
        type: AdminKey
        adminKey:
          value: "PASTE_YOUR_ADMIN_KEY_HERE"
EOF

kubectl apply -f gateway-setup.yaml
IngressClass tells Kubernetes "this is a valid class of ingress controller, and here's where to find its connection details (GatewayProxy)." GatewayProxy holds the actual Admin API endpoint and credentials.

4.3 Confirm the fix took effect

INGRESS_POD=$(kubectl get pods -n ingress-apisix -o name | grep ingress-controller | head -1)
kubectl logs -n ingress-apisix "$INGRESS_POD" -c manager --tail=20
(the label app.kubernetes.io/name=apisix-ingress-controller doesn't match this chart's actual pod labels — grepping the pod name directly is the reliable way to find it) "no GatewayProxy configs provided" should stop appearing, replaced by "syncing resources for config" with a non-zero service_number once routes exist.


Section 5 — Writing a working ApisixRoute

The second easy-to-miss requirement, same symptom as Section 4's problem: every ApisixRoute needs an explicit ingressClassName: apisix field in its spec. Without it, the route exists in Kubernetes but has no link telling the controller which IngressClass/GatewayProxy to sync through — same 404 Route Not Found result, different root cause.

Template for any future route

apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
  name: my-route
spec:
  ingressClassName: apisix          # REQUIRED — do not omit
  http:
  - name: rule1
    match:
      paths:
      - /my-path
    backends:
    - serviceName: my-service
      servicePort: 80

End-to-end test

kubectl create deployment httpbin --image=mccutchen/go-httpbin:2.25.0
kubectl expose deployment httpbin --port=80 --target-port=8080

cat > httpbin-route.yaml << 'EOF'
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
  name: httpbin-route
spec:
  ingressClassName: apisix
  http:
  - name: rule1
    match:
      paths:
      - /get
    backends:
    - serviceName: httpbin
      servicePort: 80
EOF

kubectl apply -f httpbin-route.yaml
curl http://<apisix-gateway-external-ip>/get
A real JSON response back (not 404 Route Not Found) confirms the full chain — CRD → IngressClass → GatewayProxy → Admin API → data plane — is genuinely working end to end.

Cleanup after testing (manual path only — prerequisite.sh does this automatically):

kubectl delete apisixroute httpbin-route
kubectl delete deployment httpbin
kubectl delete service httpbin
Keep IngressClass and GatewayProxy — those are permanent infrastructure, not test scaffolding.

How to tell which fix (Section 4 or 5) you're missing, if a route ever fails again

INGRESS_POD=$(kubectl get pods -n ingress-apisix -o name | grep ingress-controller | head -1)
kubectl logs -n ingress-apisix "$INGRESS_POD" -c manager --tail=20
- Still seeing "no GatewayProxy configs provided" → Section 4's fix isn't applied or isn't found - Logs show "syncing resources for config" with service_number: 0 even though services clearly exist → check the specific route's ingressClassName field (Section 5)

A real, confirmed plugin-ordering bug worth knowing, if you ever combine redirect with proxy-rewrite on the same route

Discovered directly during the X-Forwarded-Proto investigation above: when both redirect (with http_to_https: true) and proxy-rewrite (setting X-Forwarded-Proto/X-Forwarded-Host) are configured on the same route, proxy-rewrite's default priority (1008) runs before redirect's — meaning proxy-rewrite unconditionally sets the header to https first, and by the time redirect checks it to decide whether to fire, it already sees https and concludes no redirect is needed — even on a genuinely plain-HTTP request. This silently breaks the redirect entirely.

The safe pattern going forward: don't combine these two plugins on the same route unless you specifically need both and have confirmed the priority ordering works for your case. If you only need one behavior, use only that one plugin.


Section 6 — Install cert-manager

Same pattern already used for APISIX in Section 3 — the Helm chart comes only from the Nexus Helm repo (same my-nexus repo and helm login, see the open follow-up in Section 3), and every image cert-manager deploys is named by its Nexus path (registry.nexus.castis.io/cert-manager/...), so none of them fall back to a public registry. This keeps installs reproducible over time and doesn't depend on the public internet being reachable at install time.

kubectl apply -f cert-manager/cert-manager-crds.yaml

kubectl create ns cert-manager
kubectl apply -f registry-secret.yml -n cert-manager

helm install cert-manager my-nexus/cert-manager \
  --version "$CERT_MANAGER_VERSION" \
  --namespace cert-manager \
  -f cert-manager/cert-manager-values.yaml

CERT_MANAGER_VERSION comes from versions.env (currently v1.21.0). cert-manager/cert-manager-values.yaml only sets the pull secret and the Nexus repository for the controller, webhook, cainjector and startupapicheck images. It sets no image tags: the chart uses its own appVersion, so bumping CERT_MANAGER_VERSION moves every image with it.

Bumping cert-manager means three things together: copy the new images into Nexus, change CERT_MANAGER_VERSION, and re-vendor cert-manager/cert-manager-crds.yaml from the same release (its labels carry the version, e.g. app.kubernetes.io/version: "v1.21.0"). An old CRDs file with a new chart is a mismatch.

CRDs are applied separately, before the Helm install, not bundled into the chart's own install. This is cert-manager's own documented pattern (unlike APISIX, whose CRDs come in via the ingress-controller subchart automatically) — the CRDs file has to exist and be applied first, or the subsequent Certificate/ClusterIssuer/Challenge resources used in Section 7 have nowhere to register.

nexus-registry-secret needs to exist in cert-manager namespace specifically — same reasoning as every other namespace in this project: namespaces don't share secrets with each other, so Step 3's secret in ingress-apisix does nothing for pulls happening in cert-manager.

Version pinned (v1.21.0 in versions.env) — same reasoning as every other pinned version in this project: reproducible installs regardless of what's currently the newest public release.

Confirming cert-manager is genuinely ready, not just "pod shows Running"

A pod reporting Running doesn't guarantee cert-manager's webhook (which validates every Certificate/Issuer/ClusterIssuer resource on creation) has actually finished initializing. The real evidence it's ready is whether its CA bundle has been injected into the ValidatingWebhookConfiguration:

kubectl get validatingwebhookconfigurations cert-manager-webhook \
  -o jsonpath='{.webhooks[0].clientConfig.caBundle}'

If this returns a non-empty (long, base64-looking) string, the webhook is genuinely ready. prerequisite.sh polls this directly for up to 60 seconds after all cert-manager pods show Running, rather than assuming pod status alone means it's safe to apply ClusterIssuer/Certificate resources in Section 7 — applying those too early can otherwise intermittently fail with a webhook-connection error, even though the pods all look healthy.

Verify manually:

kubectl get pods -n cert-manager
You should see three pods: cert-manager, cert-manager-cainjector, cert-manager-webhook, all Running.

If a pod shows ImagePullBackOff here: same troubleshooting as Section 3 — check nexus-registry-secret exists in cert-manager specifically (not just ingress-apisix), and that the cert-manager images were actually mirrored to Nexus.


Fail-safe: running the script by hand

When the site phase can run (PREREQ_PHASE=site or the default all), prerequisite.sh reads this machine's saved values from /etc/ibc/site.env (the file the setup wizard writes): domain, email, IP, acme-dns host and account. So a hand run follows the site's real values.

  • Values passed in the environment (the wizard and restore.sh do this) still win.
  • If DNS_ZONE names a different domain than the saved one, the script stops: a site's domain is locked after install.
  • If there is no saved domain and DNS_ZONE is still your-domain.example.com, the script stops before changing anything, so it can't overwrite a working certificate with the placeholder. For a lab test only, set ALLOW_PLACEHOLDER_DOMAIN=1; IBC_SITE_ENV=none skips reading the saved file.
  • PREREQ_PHASE=base is unaffected: it never reads site values.

Section 6b — Install Kyverno (image signature check)

Kyverno checks the cosign signature of every registry.nexus.castis.io/playtelly/* image when a pod is created, so an unsigned image is reported (later: refused). It does not depend on the site's domain, so it installs in the base phase, before the setup wizard.

kubectl create ns kyverno
kubectl apply -f registry-secret.yml -n kyverno
helm install kyverno my-nexus/kyverno --version "$KYVERNO_VERSION" -n kyverno -f kyverno/kyverno-values.yaml
  • Chart and images come only from Nexus (list in versions.env). Copy them first with docker buildx imagetools create, as for cert-manager; the chart goes to the helm-hosted repo as kyverno-3.9.1.tgz.
  • kyverno/kyverno-values.yaml runs 1 admission replica and turns off the controllers that image verification doesn't need.
  • The policy is not installed here. Argo CD applies gitops/components/kyverno-policies (sync wave -6), in Deny mode: a Pod with an unsigned playtelly/* image is refused, and violations appear in PolicyReports.
  • Scope: only registry.nexus.castis.io/playtelly/* is checked. cdn/*, postgres, zitadel and the other infrastructure images never match, so they need no exemption.
  • Read the report: kubectl get policyreport -A and filter for verify-playtelly-image-signature with result fail.
  • Fail open: the policy keeps failurePolicy: Ignore, so Pods still start if Kyverno is down. Do not set Fail with 1 replica: a Kyverno restart would block every new pod.
  • Roll back: set validationActions: [Audit] (report only), or helm uninstall kyverno -n kyverno.

Section 7 — acme-dns DNS-01 ClusterIssuer + wildcard certificate for the site's domain

Replaces the private-CA approach used in an earlier version of this project (a self-signed root CA issuer, certificate and ApisixTls, no longer in this repo and not run by the current script). See the intro section of this doc for the full reasoning behind the switch.

How acme-dns fits in. Let's Encrypt proves a site owns its domain by looking up a TXT record at _acme-challenge.<domain>. The site should not hold a token that can edit Castis's DNS, so the record is delegated instead. When Castis approves a site through the edge API (edge-api.md), coreapi:

  1. registers an acme-dns account for that site (on the acme-dns server: API acme.castis.io, zone acme-dns.castis.io),
  2. creates _acme-challenge.<domain> CNAME <account subdomain>.acme-dns.castis.io in Castis's DNS, with its own Cloudflare token,
  3. returns only the acme-dns account to the site.

cert-manager on the site then writes the challenge TXT record through the acme-dns /update API, Let's Encrypt follows the CNAME to it, and the certificate is issued. The account can update exactly one TXT record, and no Cloudflare token is ever stored on the site.

Inputs. Step 7 runs in the site phase (PREREQ_PHASE=site), started by the setup wizard (setup-agent/agent.py, step_site) once the domain is known and the site is approved. The wizard passes these environment variables:

Variable What it is Default if empty
DNS_ZONE The site's domain (IBC_DOMAIN) your-domain.example.com
ACME_EMAIL Let's Encrypt account email the email: in 02-clusterissuer.yaml
ACMEDNS_HOST acme-dns API URL the host: in 02-clusterissuer.yaml (https://acme.castis.io)
ACMEDNS_ACCOUNT_JSON This site's acme-dns account, in cert-manager's acmedns.json format an existing acme-dns-account Secret, else Step 7 fails
ACME_STAGING true = Let's Encrypt's staging server (lab VMs only: much higher limits, but browsers don't trust its certificates). From IBC_ACME_STAGING false (production)

Rendering. The three committed files use the placeholder domain your-domain.example.com. The script's render_site_file pipes each one through sed before kubectl apply -f -: the placeholder becomes $DNS_ZONE, and when set, ACME_EMAIL replaces the value of the email: line and ACMEDNS_HOST the value of the host: line. Nothing is written to disk and the committed files are never edited.

This section applies, in order (all idempotent):

7.1 acme-dns account Secret

kubectl create secret generic acme-dns-account -n cert-manager \
  --from-literal="acmedns.json=$ACMEDNS_ACCOUNT_JSON" \
  --dry-run=client -o yaml | kubectl apply -f -
  • If ACMEDNS_ACCOUNT_JSON is set, the Secret is created or updated from it.
  • If it's empty but cert-manager/acme-dns-account already exists, that one is kept.
  • If neither, the script exits with ERROR: no acme-dns account for <domain>: the site hasn't been approved yet, or approval sent no account.

The wizard builds the JSON from the edge API's acmeDnsAccount (username, password, fulldomain, subdomain, allowfrom). cert-manager looks the account up by the name it is validating, so the JSON has two keys, the domain and *.<domain>, both holding the same account:

{"your-domain.example.com": {"username": "…", "password": "…", "fulldomain": "….acme-dns.castis.io", "subdomain": "…", "allowfrom": []},
 "*.your-domain.example.com": { same account }}

When the edge API later sends a replaced account (a check-in with a newer acmeDnsVersion), ibc-agent updates this same Secret (edge-api.md).

7.2 ClusterIssuer (DNS-01 via acme-dns)

cert-manager/02-clusterissuer.yaml:

apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt-prod
spec:
  acme:
    server: https://acme-v02.api.letsencrypt.org/directory
    email: <ACME_ACCOUNT_EMAIL>   # <-- change this
    privateKeySecretRef:
      name: letsencrypt-prod-account-key
    solvers:
      - dns01:
          acmeDNS:
            host: https://acme.castis.io   # acme-dns API; ACMEDNS_HOST overrides it
            accountSecretRef:
              name: acme-dns-account
              key: acmedns.json
        selector:
          dnsZones:
            - "your-domain.example.com"   # <-- change to your domain
(The file's header comment, left out here, repeats the acme-dns explanation above.) The # <-- change comments predate the wizard: render_site_file fills these in from ACME_EMAIL and DNS_ZONE, so nobody edits the file by hand.

render_site_file cert-manager/02-clusterissuer.yaml | kubectl apply -f -
The script then waits up to 60s for the ClusterIssuer to report Ready and prints a warning (not an error) if it doesn't.

Why the Secret must live in the cert-manager namespace: ClusterIssuer is a cluster-scoped resource (no namespace of its own), so cert-manager looks for any Secret it references in one fixed, default location — the cert-manager namespace. This is different from the namespaced Issuer resource, where the referenced Secret must sit in the same namespace as the Issuer itself.

selector.dnsZones: ["<domain>"] scopes this solver to certificate requests for the site's domain and anything under it (e.g. *.<domain>). It's purely a routing filter inside cert-manager.

7.3 Certificate (wildcard)

cert-manager/03-certificate.yaml:

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: hotel-castis-io-tls
  namespace: ingress-apisix
spec:
  secretName: hotel-castis-io-tls-secret
  issuerRef:
    name: letsencrypt-prod
    kind: ClusterIssuer
  commonName: your-domain.example.com
  dnsNames:
    - your-domain.example.com
    - "*.your-domain.example.com"
  duration: 2160h
  renewBefore: 720h

render_site_file cert-manager/03-certificate.yaml | kubectl apply -f -
(The placeholder domain becomes $DNS_ZONE. The name hotel-castis-io-tls stays the same on every site.)

A wildcard does not automatically include the bare domain — both your-domain.example.com and *.your-domain.example.com must be listed explicitly in dnsNames, which this file already does correctly.

What happens behind the scenes while this is Ready: False: cert-manager creates two independent Challenge resources (one for the wildcard name, one for the bare domain — Let's Encrypt requires separate proof for each), each of which writes its token through the acme-dns /update API with the account from Section 7.1. Let's Encrypt looks up _acme-challenge.<domain>, follows the CNAME Castis created to the account's record in acme-dns.castis.io, and validates. Both challenges use the same record; acme-dns keeps the two most recent TXT values, so both proofs are there at once. (acme-dns has no delete, so nothing is removed afterwards; the next update overwrites it.) This normally takes 30 seconds to a few minutes. prerequisite.sh polls kubectl get certificate ... -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}' with no fixed timeout until this reports True.

If it's taking longer than a few minutes:

kubectl describe challenge -n ingress-apisix
Look at the Status.Reason field on each challenge — "Waiting for DNS-01 challenge propagation" this early on is completely normal; an auth error against the acme-dns API (401/403 from /update) means the account in acme-dns-account is wrong or was removed; a validation error saying the TXT record wasn't found usually means the _acme-challenge CNAME is missing from Castis's DNS or points at a different account's fulldomain. Both are fixed on the Castis side (edge-api.md).

A note on dig checks against the TXT record while this is in progress: running dig from inside a network that uses split-DNS/Tailscale MagicDNS (100.100.100.100 as the resolver) can return a false NXDOMAIN even when the record genuinely exists in public DNS — that internal resolver may not proxy the query to the real public DNS. Query a public resolver directly instead to get an accurate read: dig TXT _acme-challenge.your-domain.example.com @1.1.1.1 (it should show the CNAME to ….acme-dns.castis.io and then the TXT value). Even a genuine, momentary NXDOMAIN from a public resolver right as the record is created/propagating isn't itself a failure — check kubectl get certificate a little after, rather than treating one dig snapshot as final.

7.4 ApisixTls (wires the certificate into APISIX)

cert-manager/04-apisixtls.yaml:

apiVersion: apisix.apache.org/v2
kind: ApisixTls
metadata:
  name: hotel-castis-io-tls
  namespace: ingress-apisix
spec:
  ingressClassName: apisix
  hosts:
    - your-domain.example.com
    - "*.your-domain.example.com"
  secret:
    name: hotel-castis-io-tls-secret
    namespace: ingress-apisix

render_site_file cert-manager/04-apisixtls.yaml | kubectl apply -f -

cert-manager writes a standard tls.crt + tls.key Kubernetes Secret — ApisixTls is what actually tells APISIX's data plane to serve HTTPS using it for these hostnames. Without this step, the certificate exists and is valid, but APISIX itself has no instruction to use it. ingressClassName: apisix is required here for the same reason as on every ApisixRoute (Section 5).

Verifying the whole chain worked

kubectl get certificate -n ingress-apisix
READY: True confirms success. To inspect the real certificate being served:
echo | openssl s_client -connect <apisix-gateway-ip>:443 -servername your-domain.example.com 2>/dev/null \
  | openssl x509 -noout -subject -issuer -dates
Expect subject= to include your-domain.example.com and issuer= to show Let's Encrypt — confirming this is a real, browser-trusted certificate, not the old self-signed private CA.

Renewal — fully automatic

cert-manager watches this Certificate's expiry and automatically re-runs the same DNS-01 flow roughly 30 days before the fixed 90-day Let's Encrypt expiry (per renewBefore: 720h above). No cron job, no manual re-run of this script needed — this repeats indefinitely as long as this site's acme-dns account (Section 7.1) stays valid, the _acme-challenge CNAME stays in Castis's DNS, and this cluster keeps outbound HTTPS access to the acme-dns API (ACMEDNS_HOST, default https://acme.castis.io) and Let's Encrypt.

Why this cluster terminates its own TLS

This cluster independently issues and terminates its own trusted certificate for your-domain.example.com (Sections 6–7), since DNS-01 works identically regardless of which cluster or server requests it, and Let's Encrypt has no issue issuing multiple independent certificates for the same hostname to different servers/clusters. This is useful specifically for internal/private-network users who reach this cluster directly (via internal routing, not through any public gateway) and still need a properly encrypted, browser-trusted connection.


Section 8 — Internal CoreDNS for custom subdomains (e.g. your-domain.example.com) and a second internal TLD (playtelly.internal)

Companion to Step 8 of prerequisite.sh, which automates everything in this section that happens on the k3s node itself. Read "Whether this 'just works'…" and "Manual steps required after Step 8 finishes" below first — they explain exactly where the automation boundary sits and why.

This step now serves two separate zones from the same CoreDNS instance and Corefile, both answering with the same ANSWER_IP:

Variable Value (default) Purpose
DNS_ZONE your-domain.example.com The public-facing application domain — subdomains like api.your-domain.example.com, cproxy.your-domain.example.com route through APISIX to the application services (see application.md)
INTERNAL_ZONE playtelly.internal A standalone internal-only TLD used by the playtellyinternal/client-conf service to hand out internal service URLs to other internal clients — not a subdomain of DNS_ZONE, its own separate zone block in the Corefile

Both are written into the same committed coredns/coredns-configmap.yaml template, on the same server-block line (e.g. ${DNS_ZONE} playtelly.internal {) — see "The two committed CoreDNS files" below for the exact Corefile contents. INTERNAL_ZONE is a plain bash variable in prerequisite.sh, used for the script's own dig-based verification and its printed summaries; it is not itself an envsubst placeholder in the ConfigMap (unlike DNS_ZONE/ANSWER_IP), since playtelly.internal is written literally in the committed Corefile and doesn't need to vary between environments the way the real domain does.

Whether this "just works" depends entirely on how this node is networked

The IP that Step 8 auto-detects (NODE_IP) is only useful to other LAN devices if that IP is actually reachable from the LAN. Whether it is depends on how this machine is networked — there are three distinct cases:

Scenario Is NODE_IP reachable from other LAN devices? What to do
This machine IS the server — no VM involved, k3s runs directly on real hardware Yes, directly Nothing extra needed. Point client devices' DNS at NODE_IP and you're done.
VM with a Bridged network adapter Yes, directly A bridged adapter makes the VM appear as its own independent device on the LAN — it gets a real DHCP-assigned IP from your router, exactly like a physical machine would. NODE_IP (detected from inside the VM) is the LAN-reachable address. Point client devices' DNS at it and you're done — same as the bare-metal case above.
VM with a NAT network adapter No — this is the case that needs extra work NAT isolates the VM behind a private, virtual network that only the hypervisor's host machine can see. NODE_IP detected from inside the VM (e.g. <VM_NAT_IP>-style addresses) is only reachable from the host itself — no other device on your physical LAN can reach it directly, no matter how correctly CoreDNS is configured. See "The NAT case, step by step" below.

How to tell which one you're in: if ip addr show inside the VM shows an address like 192.168.x.x or 10.x.x.x that matches the same range as your router/other LAN devices, you're bridged (or bare-metal) — you're done, no extra steps. If it shows something in a different, isolated-looking range (commonly 10.0.2.x for VirtualBox NAT, or similar), you're in the NAT case below.

The NAT case, step by step

If the VM is behind NAT, client devices need to talk to the hypervisor's host machine, not the VM directly — the host then forwards that traffic inward to the VM. This means:

  1. Find the host machine's own LAN IP — not the VM's IP. Run this on the host itself (outside the VM):
  2. Windows: ipconfig, look for the IPv4 Address under your active adapter
  3. macOS/Linux: ifconfig or ip addr show

This host IP — not NODE_IP from inside the VM — is what you'll eventually put into every client device's DNS setting.

  1. Set up port forwarding on the hypervisor so that traffic arriving on the host's ports gets forwarded inward to the VM's internal NAT IP. In VirtualBox, this is Settings → Network → Adapter → Advanced → Port Forwarding. DNS needs two rules (UDP and TCP); the site itself needs 80 and 443; the setup wizard needs 8800 during setup (the same table as the VM-behind-NAT part of Install on your own server):
Name Protocol Host IP Host Port Guest IP Guest Port
DNS-UDP UDP (blank = all host interfaces) 53 <VM's internal NAT IP> 53
DNS-TCP TCP (blank) 53 <VM's internal NAT IP> 53
HTTP TCP (blank) 80 <VM's internal NAT IP> 80
HTTPS TCP (blank) 443 <VM's internal NAT IP> 443
Wizard TCP (blank) 8800 <VM's internal NAT IP> 8800
  1. Check the host's own port 53 isn't already taken by something else on the host OS before relying on this forwarding — a surprisingly common issue on Windows hosts specifically, where background services can independently bind port 53 and block the forwarding rule from working. If port 53 forwarding doesn't seem to work even though CoreDNS itself is confirmed healthy inside the VM, this is the first thing to check on the host.

  2. Test from the host itself (not from inside the VM):

    nslookup your-domain.example.com 127.0.0.1
    
    If this returns the right IP, the whole chain — host port 53 → forwarded → VM → CoreDNS → answer — is working.

  3. Point client devices at the host's LAN IP (from step 1), not the VM's IP — that's the address other devices on your network actually need to use.

Which variable actually needs editing for the NAT case

There are two IP-shaped values involved in Step 8, and it's important not to conflate them:

Variable What it actually is Who sets it
NODE_IP Auto-detected inside the VM — the address CoreDNS's hostNetwork bind uses, and (in the NAT case) the VM's own internal, hypervisor-only address Always auto-detected — never edit this directly
ANSWER_IP The IP CoreDNS actually tells clients to connect to for $DNS_ZONE — i.e. what ends up in the DNS response This is the one to edit manually for NAT

By default ANSWER_IP is auto (the setup wizard's "How devices reach this server" box left empty), which makes the script fall back to using the detected NODE_IP as the answer too. This default is only correct for bare metal or a Bridged adapter — in those cases NODE_IP genuinely is reachable from the LAN, so it's fine to also be the answer.

For the NAT case, this default is wrong and must be overridden. If CoreDNS answers with the VM's internal NAT IP (e.g. <VM_NAT_IP>), a client's browser will successfully resolve your-domain.example.com — since the host's port-53 forwarding gets the DNS query through — but will then fail to actually connect, since it has no route to that internal address for the resulting HTTP/HTTPS request. The DNS answer itself has to be an IP the client can actually reach.

The fix: set ANSWER_IP to the host machine's real LAN IP (the same one found in step 1 of "The NAT case, step by step" above). ANSWER_IP is an environment variable, not something edited in the script. Normally you enter it in the setup wizard's "How devices reach this server" box; the wizard saves it as IBC_ANSWER_IP and passes it to Step 8 (setup-agent/agent.py, step_site). When running the site phase by hand:

PREREQ_PHASE=site DNS_ZONE=<domain> ANSWER_IP="<HOST_LAN_IP>" ./prerequisite.sh   # the HOST machine's LAN IP, not the VM's
(Step 7 runs in the same phase, so a manual run also needs the acme-dns variables from Section 7, or an existing acme-dns-account Secret.)

Everything else in Step 8 — the port-53 conflict check, the hostNetwork bind, the pod-ready wait — still uses NODE_IP internally exactly as before; only the answer CoreDNS gives out changes. The script prints a clear reminder of this distinction (and what to do about it) both in the config comment above ANSWER_IP and again in the final summary after Step 8 finishes.

One more consequence worth knowing: if you set ANSWER_IP to the host's LAN IP, that only fixes DNS resolution. For the resulting HTTP/HTTPS connection to actually work end to end, ports 80/443 (not just 53) must also be forwarded from the host to this VM, as in step 2 above.

What Step 8 of prerequisite.sh actually does

Mirrors the same idempotent, self-checking pattern as every other step in the script — and, like Step 3's apisix/apisix-values.yaml, uses real committed files (coredns/coredns-configmap.yaml, coredns/coredns-deployment.yaml) rather than generating everything from scratch on every run:

  1. Detects the node's own LAN IP automatically — the only genuinely dynamic value in this step:

    NODE_IP=$(ip route get 1.1.1.1 2>/dev/null | awk '{for(i=1;i<=NF;i++) if ($i=="src") print $(i+1)}')
    
    This asks the kernel's own routing table "what source IP would you use to reach the internet?" — a reliable way to get the real outbound-facing IP without guessing which interface is the right one (eth0 vs a Docker/CNI/other virtual interface). See "prerequisite.sh internals" below for a full line-by-line breakdown of how this works.

  2. Checks for a port 53 conflict on the node itself, same reasoning as the Windows-host check, but here it's checking Debian's own systemd-resolved:

    sudo ss -tulpn | grep :53
    
    On most Debian installs, systemd-resolved's stub listener binds only to 127.0.0.53:53, not the node's real IP — so this normally doesn't conflict with CoreDNS's hostNetwork bind on the real interface IP. The script checks anyway and prints a clear warning if something unexpected is bound to the real IP, rather than assuming it's always clear.

  3. Ensures nexus-registry-secret exists in the kube-system namespace. CoreDNS's image now pulls from the private Nexus mirror (registry.nexus.castis.io/coredns:1.11.1), named by its Nexus path, so it has no public fallback — see "Why CoreDNS also pulls from Nexus" below. Step 3 already applies this same secret to ingress-apisix, and Section 6 applies it again to cert-manager — but namespaces don't share secrets with each other, so it needs a separate, idempotent check-and-apply here for kube-system specifically, since that's where the CoreDNS Deployment actually lives.

  4. Applies coredns/coredns-configmap.yaml and coredns/coredns-deployment.yaml directly — both files are committed to the repo, same as apisix/apisix-values.yaml. The ConfigMap file is a template: it contains two substitutable placeholders, ${DNS_ZONE} and ${ANSWER_IP}, both rendered at apply time with envsubst and piped straight into kubectl apply -f - via a pipe — no intermediate file is ever written to disk, so there's nothing left over in /tmp to clean up afterward:

    export ANSWER_IP DNS_ZONE
    envsubst < coredns/coredns-configmap.yaml | kubectl apply -f -
    kubectl apply -f coredns/coredns-deployment.yaml
    
    The Deployment file has no dynamic values, so it's applied as-is. See "Which variable actually needs editing for the NAT case" below for why ANSWER_IP is a separate value from the auto-detected NODE_IP, not just an alias for it.

  5. Waits for the pod to be Ready using the same no-fixed-timeout polling loop pattern already established in the rest of the script.

  6. Verifies resolution directly against the node's own IP using dig, for: the bare $DNS_ZONE domain, a subdomain of it (www.$DNS_ZONE, proving the wildcard template plugin behavior works), the standalone $INTERNAL_ZONE (playtelly.internal, proving the second zone block resolves correctly and independently of $DNS_ZONE), and a public domain (google.com, proving upstream forwarding still works). All four must resolve correctly for Step 8 to report TEST PASSED — a failure on $INTERNAL_ZONE specifically means the second zone block isn't answering, even if $DNS_ZONE itself is fine, so it's checked independently rather than assumed to work just because the primary zone does.

Why CoreDNS also pulls from Nexus

Same reasoning already established for apisix/etcd/ingress-controller in Section 3 (and cert-manager in Section 6): pulling directly from Docker Hub (coredns/coredns) means results depend on whatever's currently public and reachable at install time — this project consistently avoids that in favor of a pinned, Nexus-mirrored copy instead, so every install reproduces exactly the same image regardless of when or where it runs.

coredns-deployment.yaml therefore specifies:

image: registry.nexus.castis.io/coredns:1.11.1
and the pod spec includes:
imagePullSecrets:
- name: nexus-registry-secret

Copy this image into Nexus before running Step 8 for the first time — versions.env lists it (under "Images the manifests reference by their Nexus path") and gives the copy command used for every image in this project: docker buildx imagetools create -t registry.nexus.castis.io/coredns:1.11.1 docker.io/coredns/coredns:1.11.1.

If the CoreDNS pod shows ImagePullBackOff in Step 8's wait loop: almost certainly either the image hasn't been mirrored to Nexus yet, or nexus-registry-secret is missing/wrong specifically in kube-system (check kubectl get secret nexus-registry-secret -n kube-system — remember this is a different namespace than the ones Sections 3 and 6 already handle).

The two committed CoreDNS files

coredns/coredns-configmap.yaml — a template committed to the repo, with ${DNS_ZONE} and ${ANSWER_IP} as the two substitutable placeholders:

apiVersion: v1
kind: ConfigMap
metadata:
  name: lan-coredns-corefile
  namespace: kube-system
data:
  Corefile: |
    ${DNS_ZONE} playtelly.internal {
        template IN A {
            answer "{{ .Name }} 300 IN A ${ANSWER_IP}"
        }
        log
    }

    .:53 {
        forward . 1.1.1.1 8.8.8.8
        cache 30
        log
        errors
        health
    }

template IN A answers every A-record query inside the zone block with the same IP — this is what gives you the wildcard-style behavior (your-domain.example.com, www.your-domain.example.com, anything.your-domain.example.com all resolve identically) without needing a separate static record per subdomain.

${DNS_ZONE} playtelly.internal { — CoreDNS server blocks can match multiple zones on the same line, space-separated; both zones share the same template/log config here. playtelly.internal is written literally (not ${INTERNAL_ZONE}) since, unlike the real domain in $DNS_ZONE, this internal-only TLD isn't expected to vary between environments — see the INTERNAL_ZONE table at the top of this section for why prerequisite.sh still tracks it as its own bash variable for verification purposes even though it isn't templated in the YAML itself. If playtelly.internal (or any future additional internal zone) does need to vary later, the same ${...} placeholder pattern used for DNS_ZONE can be applied to it too — nothing about the current approach prevents that, it's just not necessary yet.

coredns/coredns-deployment.yaml — fully static, no placeholders, applied as-is every run. Pulls from the private Nexus mirror (registry.nexus.castis.io/coredns:1.11.1) via imagePullSecrets: nexus-registry-secret, same pattern as every other image in this project — see "Why CoreDNS also pulls from Nexus" above. Otherwise the same shape as any other Deployment in this repo, using hostNetwork: true to bind directly to the node's real interface rather than getting an isolated pod IP.

Changing the target domain

DNS_ZONE is the single source of truth for the public-facing domain. It is an environment variable, not a line edited in the script: the setup wizard passes it (together with ANSWER_IP and ACME_EMAIL) when it runs the site phase (setup-agent/agent.py, step_site, from IBC_DOMAIN); the default in the script, your-domain.example.com, is only a placeholder. The CoreDNS ConfigMap uses ${DNS_ZONE} as a placeholder, and Step 7's render_site_file substitutes it into cert-manager/02-clusterissuer.yaml, 03-certificate.yaml and 04-apisixtls.yaml too, so none of the committed YAML needs editing when the domain changes. Changing the domain of an installed site means re-running the site phase with the new DNS_ZONE, and the new domain also needs its own acme-dns account and _acme-challenge CNAME from Castis (Section 7).

INTERNAL_ZONE (playtelly.internal) is a separate, independent value — changing DNS_ZONE has no effect on it, and vice versa. If playtelly.internal itself ever needs to change, it must be edited in two places: the INTERNAL_ZONE variable at the top of prerequisite.sh (used for the script's own verification and summary output) and the literal playtelly.internal text in the committed coredns/coredns-configmap.yaml Corefile (used for the actual zone match). This is a deliberate asymmetry with DNS_ZONE — see "The two committed CoreDNS files" above for why INTERNAL_ZONE isn't also templated via envsubst.

Manual steps required after Step 8 finishes (only if this VM is behind NAT)

Once Step 8 completes successfully, prerequisite.sh prints the node's detected IP and the IP CoreDNS answers with. What comes next depends on which of the two it is:

  • ANSWER_IP = the detected node IP (the wizard box was left empty): the script says this is right for bare metal or a Bridged adapter, and that on a NAT VM it's wrong. In that case, find the host machine's real LAN IP (ipconfig on Windows, ifconfig/ip addr show on macOS/Linux), set ANSWER_IP to it (in the wizard, or as an environment variable for a manual site-phase run — see "Which variable actually needs editing for the NAT case" above), and re-run the site phase.
  • ANSWER_IP was overridden (the expected setup for a NAT VM): the script prints the remaining steps, all on the hypervisor's host machine, not the VM:
  • Forward TCP and UDP host port 53 to the VM's internal NAT IP (a different IP than the host's LAN IP)
  • Forward ports 80/443 the same way, so the connection works and not just the lookup
  • Confirm port 53 isn't already taken by something else on the host OS — check before assuming the forwarding rule alone will work
  • Test from the host: nslookup ${DNS_ZONE} 127.0.0.1
  • Also test the internal TLD from the host: nslookup ${INTERNAL_ZONE} 127.0.0.1 (i.e. nslookup playtelly.internal 127.0.0.1) — since it's a separate zone block, a working DNS_ZONE lookup does not guarantee this one also resolves
  • Point client devices' DNS at the host machine's LAN IP — best in the router's DHCP settings; per device only as a fallback. This is not something this script can do, since it has no access to those devices

If instead this VM uses a Bridged adapter (or this machine isn't a VM at all), none of the above applies — leave ANSWER_IP as auto (the wizard's "How devices reach this server" box empty), and NODE_IP from Step 8 is already the address client devices should use directly.

8.7 — Pointing this node's own DNS resolver at the new CoreDNS

Everything above (the LAN-facing CoreDNS deployment, ANSWER_IP, NAT port-forwarding) is about other devices on the network being able to resolve $DNS_ZONE/$INTERNAL_ZONE. None of it makes the node running this script able to resolve its own domain — a plain curl https://your-domain.example.com run directly on this VM would still fail, since the node's own DNS resolver still points wherever DHCP originally configured it, not at the CoreDNS just deployed.

Step 8.7 fixes this by pointing the node's own resolver at $NODE_IP (not $ANSWER_IP) — the address CoreDNS actually binds to (hostNetwork: true), and one this node can always reach locally regardless of whether it's bare metal, Bridged, or behind NAT. This is why the same logic applies to every networking scenario with no special-casing: NAT only affects whether external clients can reach $ANSWER_IP, which is irrelevant here since the node is talking to itself.

Only runs if Step 8.6's dig checks all passed (no point wiring the resolver to a CoreDNS that isn't actually answering correctly yet). Which mechanism it uses depends on how this node's networking is actually managed — confirmed to matter in practice, since not every Debian install uses the same one:

If systemd-resolved is active:

resolvectl dns <interface> $NODE_IP
resolvectl domain <interface> "~."
resolvectl dns sets the per-link DNS server; resolvectl domain <interface> "~." marks it as the default/catch-all resolver for that link (without this, systemd-resolved's split-DNS routing might only send specific-domain queries to it, leaving general internet lookups on the original DHCP-provided server). Undo with sudo resolvectl revert <interface>.

If systemd-resolved isn't active but dhcpcd is (the classic Debian ifupdown + dhcpcd combo — confirmed to be what a real target VM actually uses, not just a hypothetical fallback): /etc/resolv.conf on this setup is a plain file with a # Generated by dhcpcd from <interface>.dhcp header — dhcpcd rewrites it from scratch on every DHCP lease renewal or reboot, so a direct edit to /etc/resolv.conf would just get silently reverted later. The persistent equivalent is dhcpcd.conf's own static domain_name_servers option, which dhcpcd respects when it regenerates resolv.conf:

# appended to /etc/dhcpcd.conf, between idempotency markers so a re-run
# updates it in place instead of duplicating:
interface <interface>
static domain_name_servers=$NODE_IP 8.8.8.8 9.9.9.9
The script then runs sudo dhcpcd -n <interface> — a rebind of just that one interface, not a full dhcpcd/networking service restart, specifically to avoid dropping an existing SSH session on the same interface. Undoing is different from applying, though: a rebind (-n) reuses the cached lease and can leave the old, now-removed static nameserver sitting in resolv.conf — confirmed live. Undo by removing the marked block from /etc/dhcpcd.conf, then forcing a full release-and-renew instead: sudo dhcpcd -k <interface> followed by sudo dhcpcd <interface> (reset.sh automates exactly this).

If neither is detected, the script skips automatic setup entirely and just prints nameserver $NODE_IP as a manual reference — it deliberately does not guess at editing /etc/resolv.conf directly on an unrecognized system, since something else may well be managing/overwriting it.

Either way, this is safe for general browsing too, since CoreDNS already forwards anything outside $DNS_ZONE/$INTERNAL_ZONE upstream (confirmed by the google.com check in 8.6).

dhcpcd's own binary isn't always on PATH — confirmed on a real target VM (Debian 13/trixie): dhcpcd lives at /usr/sbin/dhcpcd or /sbin/dhcpcd, neither of which is on a normal (non-root) user's PATH. A plain command -v dhcpcd check would miss it there and fall straight through to "no supported DNS resolver manager detected," even though dhcpcd is actively managing resolv.conf on that exact machine. The script checks both paths directly ([ -x /usr/sbin/dhcpcd ] || [ -x /sbin/dhcpcd ]) in addition to PATH, so this doesn't happen.

A confirmed race between 8.7 and 8.8, and the fix for it: both resolvectl and dhcpcd's rebind apply asynchronously — the command returns before /etc/resolv.conf is actually rewritten. Immediately restarting k3s's coredns deployment in 8.8 right after can land in the split second where resolv.conf still holds its old content (which still looks perfectly valid — it has real nameserver lines, just not the new one yet). If the coredns pod is (re)created in that exact window, it copies the stale file at startup, and since coredns only reads it once, it's stuck permanently crash-looping with plugin/forward: no valid upstream addresses found even after resolv.conf settles correctly a moment later — this happened live, not just in theory, and a plain kubectl -n kube-system rollout restart deployment coredns afterward (once resolv.conf was confirmed correct) fixed it immediately, confirming it really was just a startup-timing race, not a config error.

The fix: between 8.7 and 8.8, the script polls /etc/resolv.conf (every 2s, up to 30s) waiting specifically for $NODE_IP itself to appear in it — not just "does a nameserver line exist," which the stale old content would already satisfy and defeat the whole point of waiting. This check only runs when 8.7 actually touched the resolver (systemd-resolved or dhcpcd detected); if neither was detected, $NODE_IP was never going to appear in resolv.conf in the first place, so the wait is skipped rather than spinning uselessly for the full 30s.

8.8 — Wiring k3s's own cluster-internal CoreDNS to resolve the same zones

8.7 fixes DNS resolution for the node's own OS — but pods running inside the cluster don't use the node's resolver at all; they query k3s's built-in cluster CoreDNS (kube-dns, reachable at its ClusterIP, e.g. <CLUSTER_DNS_IP>) instead. That cluster CoreDNS's own Corefile includes forward . /etc/resolv.conf, which reads the same /etc/resolv.conf 8.7 just updated (confirmed directly — pods use dnsPolicy: Default, which bind-mounts the node's actual resolv.conf into the pod) — so it might seem like 8.7 alone should be enough.

It isn't, and this was confirmed live, not theoretical: CoreDNS's forward plugin defaults to policy random — when multiple nameservers are listed (as 8.7 leaves them: $NODE_IP, then 8.8.8.8, 9.9.9.9), it picks one at random per query, not "prefer the first one, fall back only on failure." A pod's lookup for $DNS_ZONE can land on lan-coredns (correct) or a public resolver (wrong — the real, publicly-registered IP for $DNS_ZONE if it's a real domain) on any given query, with no way to predict which.

The fix is k3s's own officially-documented customization mechanism (referenced directly in its managed Corefile: import /etc/coredns/custom/*.server — see https://docs.k3s.io/advanced#coredns-custom-configuration-imports), rather than editing the Corefile itself (which is marked # File managed by k3s. DO NOT EDIT. and would just get reverted). A coredns-custom ConfigMap in kube-system with a .server-suffixed key becomes its own dedicated server block:

apiVersion: v1
kind: ConfigMap
metadata:
  name: coredns-custom
  namespace: kube-system
data:
  hotel.server: |
    your-domain.example.com:53 playtelly.internal:53 {
        forward . <NODE_LAN_IP>
    }

This is a more specific zone match than the generic . catch-all forward, so CoreDNS always prefers it for these two zones specifically — no randomness, no dependency on /etc/resolv.conf ordering at all. Applied via kubectl create configmap ... --dry-run=client -o yaml | kubectl apply -f - (idempotent — re-running with identical content is a no-op) rather than a committed static YAML file, since the content is templated with $DNS_ZONE/$INTERNAL_ZONE/$NODE_IP. The script only restarts the coredns deployment to pick up the change when the ConfigMap's content actually differs from what's already applied, to avoid an unnecessary restart on every re-run.

Only runs if Step 8.6's dig checks passed — same reasoning as 8.7, no point wiring anything to a lan-coredns that isn't confirmed working yet.

To verify this actually took effect from inside the cluster:

kubectl run dns-check-tmp --rm -i --restart=Never --image=busybox:1.28 -- nslookup $DNS_ZONE
Should consistently return $ANSWER_IP every time now, not intermittently.


prerequisite.sh internals — selected non-obvious bash

  • set -euo pipefail — -e exits on any failed command; -u errors on undefined variables (typo protection); pipefail makes a piped command fail if any stage of the pipe fails, not just the last one.
  • command -v sudo &> /dev/null — checks if a program exists without printing anything; /dev/null discards all output, we only care about the success/failure exit code.
  • ... || true — swallows a non-zero exit code so set -e doesn't kill the script over a non-critical check.
  • for i in $(seq 1 30); do ... sleep 2; done — a polling loop, checking every 2 seconds for up to ~60 seconds, instead of assuming something is instantly ready.
  • grep -A2 'name: "admin"' | grep 'key:' | awk '{print $2}' | tr -d '"' — finds the admin key: locate the anchor line + 2 lines after, narrow to the line with the value, grab the 2nd whitespace-separated field, strip stray quotes.
  • cat > file << EOF vs cat > file << 'EOF' — unquoted EOF lets bash substitute variables (like $ADMIN_KEY) inside the heredoc; quoted 'EOF' treats everything literally (used for the static test route YAML, which has nothing to substitute).
  • The pod-ready wait loop (while true; do ... kubectl get pods ... awk ... sleep 20; done) — checks real pod readiness with no time limit, so it waits exactly as long as actually needed rather than guessing a fixed duration (useful since a fresh install, e.g. right after a k3s uninstall/reinstall, needs to pull images from scratch and can take a while). The check also excludes any pod already reporting STATUS=Completed from the not-ready list — necessary because one-shot Job pods like apisix-etcd-pre-upgrade-* correctly finish with READY 0/1 forever, which the check would otherwise treat as permanently stuck; see "The apisix-etcd-pre-upgrade false-stuck bug" in Section 3 above for the full story. It also explicitly checks that at least one pod was actually returned before declaring success — confirmed as a real, separate bug: right after a fresh helm install/kubectl create, kubectl get pods can briefly return zero pods (the controller hasn't created the Pod object yet), and with nothing to check, the old loop would declare "Ready" having never actually seen a pod. Steps 3, 5, and 6 now all print "No pods found yet..." and keep looping in that case instead. A similar loop (with the pod-count guard, but without the Completed exclusion, which only Step 3 needs) is reused for the httpbin test backend in Step 5, checking every 10 seconds there instead of 20, for cert-manager's pods in Step 6, and again for the CoreDNS pod in Step 8.
  • The clean-sync log check (after applying GatewayProxy) — tails the ingress-controller's last 10 log lines every 20 seconds, looking for the absence of ECONNREFUSED plus the presence of "syncing resources for config" — the actual evidence that APISIX's admin API finished starting and a sync succeeded, rather than guessing a fixed wait duration.
  • The httpbin buffer sleep (sleep 10 after the httpbin pod shows Ready) — a short flat pause giving the freshly-ready backend a moment to fully settle before the route test hits it.
  • Temp file cleanup (rm -f /tmp/gateway-setup.yaml /tmp/httpbin-route.yaml /tmp/curl-test-output.json) — runs alongside the Kubernetes resource cleanup at the end of Step 5, removing the working files the script creates in /tmp during the run. Note this only removes the local files used to kubectl apply — it has no effect on the GatewayProxy/IngressClass resources themselves, which stay applied in the cluster regardless.
  • The webhook CA bundle poll (Step 6, kubectl get validatingwebhookconfigurations cert-manager-webhook -o jsonpath='{.webhooks[0].clientConfig.caBundle}') — checked every 5 seconds for up to 60 seconds. Unlike a simple pod-ready check, this confirms cert-manager's webhook has actually finished self-signing and injecting its own CA certificate into the ValidatingWebhookConfiguration Kubernetes object — the real signal that it can validate incoming Certificate/Issuer resources, not just that its process has started.
  • Extracting name/namespace from a committed YAML file with awk (Step 7, e.g. awk '/^metadata:/{f=1} f && /name:/{print $2; exit}' "$CERTIFICATE_FILE") — rather than hardcoding the Certificate's name/namespace as separate bash variables (which could silently drift out of sync if the committed YAML file is ever edited directly), the script reads them straight out of the file it just applied. The awk sets a flag f once it sees the metadata: line, then on the first subsequent line containing name: (or namespace:), prints the second whitespace-separated field and exits — a lightweight substitute for a real YAML parser, adequate here since these files have a simple, known structure.
  • ip route get 1.1.1.1 2>/dev/null | awk '{for(i=1;i<=NF;i++) if ($i=="src") print $(i+1)}' (Step 8) — how the node's LAN IP is auto-detected, without hardcoding an interface name:
  • ip route get 1.1.1.1 doesn't send any real traffic — it just asks the kernel's routing table "if I sent a packet to this address, which route and which local IP would you use?" 1.1.1.1 is just a well-known public IP used as a trick to force the kernel to reveal the real internet-facing interface/IP; it doesn't need to be reachable. Output looks like:
    1.1.1.1 via <LAN_GATEWAY_IP> dev eth0 src <NODE_LAN_IP> uid 1000
    
    The src <NODE_LAN_IP> portion is the actual answer we want — the local IP the kernel would stamp on outgoing packets.
  • 2>/dev/null discards any error output (e.g. if no route exists), keeping the piped output clean.
  • The awk script splits the line into space-separated fields ($1, $2, ... $NF) and loops through all of them (for(i=1;i<=NF;i++)), checking each one against the literal word "src". When found, it prints the next field over ($(i+1)) — the IP itself.
  • Why search for src instead of hardcoding a field position (e.g. $7): the exact position of src shifts depending on the route (a directly-connected network has no via segment, some lines have extra flags at the end) — searching for the literal marker word and printing whatever follows it is robust to those differences, where a fixed field number would silently break on a slightly different route output.
  • This is more reliable than assuming a fixed interface name like eth0, since interface naming varies across VMs/hardware (ens18, enp0s3, etc.) and a machine may have several interfaces (Docker bridges, CNI, VPN) — this approach always resolves to whichever one is actually used for real outbound traffic.
  • envsubst < coredns/coredns-configmap.yaml | kubectl apply -f - (Step 8) — renders the committed ConfigMap template with both ANSWER_IP and DNS_ZONE substituted in, and pipes the result directly into kubectl apply without ever writing an intermediate file to disk. The trailing -f - tells kubectl to read the manifest from stdin instead of a file path. This is deliberately different from Steps 4/5 (which do write short-lived files to /tmp and clean them up afterward) — since Step 8's rendered output has nowhere useful to persist to anyway (it's derived from a real committed file, not hand-authored), skipping the temp file entirely means there's nothing to remember to clean up. Note INTERNAL_ZONE (playtelly.internal) is not part of this envsubst substitution — it's written literally in the committed Corefile itself, so this line only ever substitutes ANSWER_IP/DNS_ZONE, same as before this second zone was added.
  • The $INTERNAL_ZONE dig check (Step 8.6, dig "@$NODE_IP" "$INTERNAL_ZONE" +noall +answer, parsed with awk for the A record) — added alongside the existing $DNS_ZONE/www.$DNS_ZONE/google.com checks, using the exact same pattern (query CoreDNS directly at the node's own IP, compare the answer against $ANSWER_IP). It's a genuinely separate check, not implied by the $DNS_ZONE checks passing, since playtelly.internal is matched by its own independent zone entry in the Corefile's server-block line — a typo or accidental removal of playtelly.internal from that line would leave $DNS_ZONE resolving fine while this one silently fails, which is exactly the scenario this dedicated check exists to catch.
  • dig_answer_retry() (Step 8.6) — a small helper all four dig checks call through, retrying up to 6 times, 5 seconds apart (30s max), instead of a single one-shot query. Confirmed necessary in practice, not just a defensive guess: the CoreDNS pod reporting Ready (8.5) only means the container started, not that its DNS listener has fully settled yet — querying it too soon after that can genuinely return no answer even though it works fine a few seconds later. Retries only as long as the answer is empty; returns immediately once a real answer comes back.

General troubleshooting reference

Symptom Cause Fix
sudo: user is not in the sudoers file Debian doesn't auto-add users to sudo group su - → usermod -aG sudo yourusername → new session
curl: command not found Minimal Debian install lacks it sudo apt install curl -y
bash: $'\302\226curl': command not found Invisible/smart-dash character from copy-paste Retype the command manually instead of pasting
ERROR: registry-secret.yml not found (Step 1, or Step 3) Script run from the wrong directory, or file missing from the clone Confirm registry-secret.yml sits at the repo root, alongside prerequisite.sh
ImagePullBackOff on apisix/apisix-etcd/apisix-ingress-controller pods nexus-registry-secret missing or wrong in ingress-apisix namespace kubectl describe pod <name> -n ingress-apisix for the exact pull error; confirm kubectl get secret nexus-registry-secret -n ingress-apisix
Step 3's wait loop hangs forever on apisix-etcd-pre-upgrade-*, even though it shows STATUS: Completed The etcd pre-upgrade Job pod legitimately stays at READY 0/1 after finishing — an older version of the wait loop treated that as permanently stuck Fixed in the current prerequisite.sh (excludes Completed pods from the not-ready check) — see "The apisix-etcd-pre-upgrade false-stuck bug" above; if you still see it, confirm you're on the latest script version
Helm install/upgrade fails with a Bitnami "unrecognized image" security error global.security.allowInsecureImages not set to true Add this setting — required whenever using a non-Bitnami-approved image for the etcd subchart, which this project always does (Nexus mirror)
kubectl get apisixroute shows resource, but curl returns 404 Route Not Found Missing GatewayProxy (Section 4), or route missing ingressClassName (Section 5) See those sections above
Ingress-controller logs show connect ECONNREFUSED ...9180 APISIX admin API not fully started yet (transient, even though pod shows Running) prerequisite.sh waits for a clean sync in the controller's own logs before proceeding (Section 4); if it still fails, just re-run the script
TEST FAILED but controller logs show clean sync (service_number: 1, no errors at all) The httpbin test backend pod itself wasn't ready yet (image still pulling) — route reached APISIX fine, but had no healthy backend to answer prerequisite.sh now waits for the httpbin pod specifically before testing; if hand-running manually, check kubectl get pods -l app=httpbin first
Ingress controller logs repeat "no GatewayProxy configs provided" No GatewayProxy resource exists yet Create it — Section 4.2
ssh: command not found (Windows PowerShell) OpenSSH client not installed on Windows Settings → Optional Features → add OpenSSH Client, or use PuTTY
sudo prompts for a password every single command Normal — cached for ~15 minutes after first entry, then silent Not an error; just type it once near the start
helm-install-traefik/helm-install-traefik-crd stuck in CrashLoopBackOff in kube-system, potentially for days Traefik never got disabled — see Section 1's "Disabling Traefik" Re-run prerequisite.sh (self-healing check runs every time), or apply the fix manually per Section 1
A backend behind APISIX (e.g. tusd) generates http:// URLs despite the original client connection being genuinely https://, and no proxy-rewrite/serverless-pre-function fix helps The confirmed APISIX 3.17.0 regression — see "Why APISIX is pinned to 3.13.0" at the top of this doc Confirm you're actually running the pinned 3.13.0 image (kubectl describe pod <apisix-pod> -n ingress-apisix \| grep Image:); if a chart upgrade silently reset this, re-apply apisix-values.yaml
Configuration validation failed error when applying a route with serverless-pre-function, mentioning an invalid phase Used the old phase name "balancer" — renamed to "before_proxy" as of APISIX v2.12.0 Use "before_proxy" instead
A route with both redirect and proxy-rewrite plugins never actually redirects plain HTTP requests The confirmed plugin-ordering bug — see Section 5's note on this Remove one of the two plugins if you don't genuinely need both together on the same route
ImagePullBackOff on cert-manager/cert-manager-cainjector/cert-manager-webhook pods (Step 6) nexus-registry-secret missing or wrong in cert-manager namespace specifically (a different namespace than Step 3 already handles) kubectl describe pod <name> -n cert-manager for the exact pull error; confirm kubectl get secret nexus-registry-secret -n cert-manager; confirm the cert-manager images for CERT_MANAGER_VERSION were actually copied into Nexus (list in versions.env)
Step 6 pods all show Running, but applying a ClusterIssuer/Certificate in Step 7 fails with a webhook-connection error The webhook's CA bundle hadn't finished injecting yet, even though pods already reported Running prerequisite.sh now polls the actual CA bundle presence, not just pod status, before proceeding to Step 7 — see Section 6's "Confirming cert-manager is genuinely ready"
Step 7 exits immediately with an error naming a missing file One of the three required cert-manager/ files isn't present alongside prerequisite.sh Confirm all three exist: 02-clusterissuer.yaml, 03-certificate.yaml, 04-apisixtls.yaml
Step 7 exits with "no acme-dns account for " The site wasn't approved yet, or approval sent no account Enter the approval token from Castis in the wizard (devops-handover.md 2.4); the wizard passes the account to Step 7 as ACMEDNS_ACCOUNT_JSON (Section 7.1, edge-api.md)
Step 7's Certificate never reaches Ready, stuck on "Waiting for DNS-01 challenge propagation" for more than a few minutes Usually the _acme-challenge.<domain> CNAME missing or pointing at another account's fulldomain, an acme-dns auth error (wrong or removed account), or the dnsZones selector not matching the requested hostname kubectl describe challenge -n ingress-apisix for the exact error; dig CNAME _acme-challenge.<domain> @1.1.1.1 should point at the fulldomain in acme-dns-account; CNAME or account problems are fixed on the Castis side (edge-api.md)
dig TXT _acme-challenge.your-domain.example.com returns NXDOMAIN even though the Certificate later succeeds Query went through a local split-DNS/Tailscale resolver (100.100.100.100) instead of the real public DNS, or was checked in the brief window before/after the record's short-lived existence Query a public resolver directly: dig TXT _acme-challenge.your-domain.example.com @1.1.1.1; treat kubectl get certificate as the source of truth over a single dig snapshot
CoreDNS pod shows ImagePullBackOff in Step 8 Image not yet mirrored to Nexus, or nexus-registry-secret missing/wrong in kube-system specifically (a different namespace than Steps 3 and 6 already handle) kubectl describe pod -n kube-system -l app=lan-coredns for the exact pull error; confirm kubectl get secret nexus-registry-secret -n kube-system; confirm the image was actually copied into Nexus (list in versions.env)
Step 8 reports a port 53 conflict on the k3s node Something other than systemd-resolved's stub (127.0.0.53) is bound to the node's real IP on port 53 sudo ss -tulpn \| grep :53 to identify the process, then stop/disable it if it's not something you rely on
dig @<node-ip> <zone> fails from the node itself after Step 8 CoreDNS pod not actually Running, or hostNetwork: true didn't bind correctly kubectl get pods -n kube-system -l app=lan-coredns, then kubectl logs -n kube-system -l app=lan-coredns
Resolution works from the k3s node (Step 8 passes), but not from other LAN devices Expected if this VM uses a NAT adapter — NODE_IP as detected inside the VM is only reachable from the hypervisor's host, not the wider LAN See "The NAT case, step by step" in Section 8 — this is the manual, host-side half of the setup
$DNS_ZONE resolves correctly in Step 8, but the $INTERNAL_ZONE (playtelly.internal) check specifically fails The Corefile's zone-match line doesn't actually include playtelly.internal alongside ${DNS_ZONE} — e.g. a manual edit to coredns/coredns-configmap.yaml dropped it, or it was never added kubectl get configmap lan-coredns-corefile -n kube-system -o yaml and confirm the server-block line reads ${DNS_ZONE} playtelly.internal { (rendered as the real domain + playtelly.internal), not just ${DNS_ZONE} { alone
envsubst: command not found (Step 8) Not installed on a minimal Debian image sudo apt install gettext-base -y (provides envsubst)
Step 8.7 says "No supported DNS resolver manager... detected" and skips the automatic resolver setup This node has neither systemd-resolved nor dhcpcd active (e.g. NetworkManager-only, or a static /etc/resolv.conf with no manager at all) Not an error — just means the node won't auto-resolve its own domain. Add nameserver $NODE_IP through whatever mechanism this system actually uses to manage DNS
resolvectl: command not found when checking Step 8.7 manually This node doesn't have systemd-resolved — confirmed to happen on classic Debian ifupdown+dhcpcd setups, which don't ship resolvectl at all Not a bug — Step 8.7 already detects this and uses the dhcpcd.conf path instead (see Section 8.7 above). Check /etc/dhcpcd.conf for the iac CoreDNS resolver marked block instead of looking for a resolvectl command
dig $DNS_ZONE (no @IP) resolves to a different IP than $ANSWER_IP, even after Step 8.7 Expected if $DNS_ZONE is a real, publicly-registered domain (like your-domain.example.com) — without @IP, dig uses the node's default resolver, which only changes if Step 8.7 actually applied. If it did apply but this still happens, the wrong interface may have been configured (multiple NICs), or dhcpcd's rebind didn't take effect yet Confirm which resolver actually answered: the last few lines of plain dig $DNS_ZONE output show SERVER: <ip>#53 — if that's not $NODE_IP, re-check /etc/dhcpcd.conf's static domain_name_servers line matches the intended interface, then sudo dhcpcd -n <interface> again
Node still can't resolve $DNS_ZONE itself even after Step 8.7 reports success resolvectl reported success but the interface name it detected doesn't match the one actually carrying traffic (e.g. multiple NICs) resolvectl status to see which interface(s) actually show the new DNS server under "DNS Servers"; re-run sudo resolvectl dns <correct-interface> $NODE_IP manually if it targeted the wrong one
A pod inside the cluster resolves $DNS_ZONE correctly sometimes but not others, even though the node itself (Step 8.7) resolves it fine every time Confirmed real behavior: k3s's built-in CoreDNS forward plugin defaults to policy random among every nameserver in /etc/resolv.conf — it does not prefer $NODE_IP just because 8.7 lists it first This is exactly what Step 8.8 fixes — confirm the coredns-custom ConfigMap exists (kubectl get configmap coredns-custom -n kube-system -o yaml) and that kube-system's coredns deployment has been restarted since it was applied
A pod's nslookup $DNS_ZONE still resolves to the real public IP after Step 8.8 ran The coredns-custom ConfigMap was applied but kube-system's coredns deployment was never restarted to pick it up (it doesn't hot-reload coredns-custom changes) kubectl -n kube-system rollout restart deployment coredns, then re-test with a throwaway pod (kubectl run dns-check-tmp --rm -i --restart=Never --image=busybox:1.28 -- nslookup $DNS_ZONE)
kube-system's coredns pod is stuck in CrashLoopBackOff right after Step 8, logging plugin/forward: no valid upstream addresses found Confirmed real, not theoretical: a startup-timing race between 8.7 and 8.8 — resolv.conf still held stale content when the coredns pod was (re)created, and it only reads that file once at startup. The current script already waits for $NODE_IP to appear in resolv.conf before 8.8 restarts coredns specifically to prevent this — this entry is for a run predating that fix, or an interrupted run Confirm cat /etc/resolv.conf looks correct now, then kubectl -n kube-system rollout restart deployment coredns — this always fixes it immediately once resolv.conf is actually correct, since the underlying config was never wrong, just read at the wrong moment

Version reference (at time of this setup)

Component Version
Debian 13.6.0 "trixie"
k3s K3S_VERSION in versions.env (currently v1.36.4+k3s1), installed with INSTALL_K3S_VERSION; images pulled through registry.nexus.castis.io (/etc/rancher/k3s/registries.yaml)
Helm HELM_VERSION in versions.env (currently v3.22.0)
APISIX Helm chart (umbrella) 2.15.0 (fixed, APISIX_CHART_VERSION in versions.env)
APISIX core 3.13.0-ubuntu — deliberately pinned below the chart's own 3.17.0-ubuntu default; see "Why APISIX is pinned to 3.13.0" at the top of this doc
apisix-ingress-controller 2.1.0 (the chart's default, pinned in apisix-values.yaml under ingress-controller.deployment.image)
ADC (sync tool, ingress-controller sidecar) ghcr.io/api7/adc:0.26.0 — a separate sidecar image set by the chart, pulled under its public name through the mirror
wait-etcd init container docker.io/library/busybox:1.28 (set by the chart, pulled through the mirror)
Step 5 test backend mccutchen/go-httpbin:2.25.0 (pulled through the mirror, deleted after the test)
etcd (bundled) 3.6.4-debian-12-r4 (pinned), replicaCount 1, 2Gi persistent volume
APISIX gateway pod resources requests: 200m CPU / 256Mi mem, limits: 1000m CPU / 512Mi mem
etcd resources requests: 200m CPU / 256Mi mem, limits: 500m CPU / 512Mi mem
ingress-controller resources requests: 100m CPU / 128Mi mem, limits: 300m CPU / 256Mi mem
Ingress-controller webhook enabled (failurePolicy: Ignore) — open question: the chart says it needs APISIX 3.17.0+; keep it or disable it (see top of this doc)
cert-manager v1.21.0 (CERT_MANAGER_VERSION in versions.env; Nexus chart + images, image tags from the chart's appVersion), namespace cert-manager
Certificate issuance method DNS-01 through acme-dns (letsencrypt-prod ClusterIssuer, per-site account in Secret cert-manager/acme-dns-account) — replaces the earlier private-CA approach
Certificate wildcard, your-domain.example.com + *.your-domain.example.com, 90-day Let's Encrypt lifetime, auto-renewed ~30 days before expiry
CoreDNS (LAN-facing, Section 8) registry.nexus.castis.io/coredns:1.11.1 (Nexus-mirrored, pulled via nexus-registry-secret), 1 replica, hostNetwork: true
CoreDNS zones served (Section 8) your-domain.example.com ($DNS_ZONE, templated) + playtelly.internal ($INTERNAL_ZONE, literal in the Corefile) — same server block, same $ANSWER_IP

ApisixRoute CRD supports API versions v2beta3 and v2 — use v2 (current stable) for new routes. Older tutorials referencing backend: (singular) instead of backends: (array) are outdated — the field was renamed in the v2beta3 upgrade.