Lab DNS and TLS

CoreDNS + etcd on the storage node, ExternalDNS, and one TLS certificate per Gateway

Every lab hostname (<name>.lab.internal) is resolved by a DNS server on the storage node, outside the cluster like Vault, so it survives cluster rebuilds.

Istio Gateway (hosts: grafana.lab.internal)
        │  watched by
        ▼
ExternalDNS (in-cluster) ──mTLS──► etcd :2379 (storage) ──► CoreDNS :53 (storage)
                                    /skydns/internal/lab/...        │
                                                                    ▼
                          host (/etc/resolver) · nodes (resolv.conf) · pods (CoreDNS stub zone)
  • CoreDNS (/etc/coredns/Corefile) serves lab.internal: static records for the nodes (storage, controlplane, node01, …, plus vault) and every record ExternalDNS writes to etcd; everything else is forwarded to public resolvers.
  • etcd only accepts clients with a certificate from its own CA (/etc/etcd/tls, created by vagrant/scripts/storage-dns.sh); the provisioner copies the ExternalDNS client certificate into the external-dns-etcd Secret over SSH.
  • ExternalDNS (components.external_dns) watches Istio Gateways and LoadBalancer Services and publishes their hosts with policy=sync: deleting a Gateway removes its record.
  • Nodes use the storage node as their first nameserver, so the API server reaches the Keycloak issuer by name. Pods resolve the domain through a stub zone in the cluster CoreDNS that forwards to the storage node.
  • Your machine sends lab.internal to the storage node: see Host Setup.

Certificates

cert-manager runs a self-signed lab CA (lab-ca-issuer ClusterIssuer, valid for 10 years) and issues one certificate per Gateway. The per-host certificates keep cert-manager’s 90 days and renew silently under the CA, so the CA your machine trusts does not change while the lab lives. Vault has its own CA because it starts before the cluster exists (see Vault).

Publishing your own app

Put the hostname in the Gateway and give the Gateway its own certificate from the lab CA:

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: myapp-tls
  namespace: istio-system        # where the ingress gateway reads TLS secrets
spec:
  secretName: myapp-tls
  issuerRef: {name: lab-ca-issuer, kind: ClusterIssuer}
  dnsNames: ["myapp.lab.internal"]
---
apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
  name: myapp
spec:
  selector:
    istio: ingressgateway
  servers:
  - port: {number: 443, name: https, protocol: HTTPS}
    tls: {mode: SIMPLE, credentialName: myapp-tls}
    hosts: ["myapp.lab.internal"]

One certificate per Gateway, never a shared/wildcard one. Browsers reuse an HTTP/2 connection for every host its certificate covers, but Istio routes by the SNI the connection was opened with. With a shared certificate, opening Keycloak and then Grafana sends the Grafana request to Keycloak’s Gateway and returns 404. Separate Gateways also keep maintenance on one app from affecting the others.

Within ~30s https://myapp.lab.internal resolves everywhere. For a LoadBalancer Service, annotate it with external-dns.kubernetes.io/hostname: myapp.lab.internal.

Changing the domain

Set dns.domain in config.yaml before vagrant up. It ends up in the TLS certificates, the Keycloak issuer and the Vault certificate, so an existing lab must be recreated. Use the new name in the host resolver rule.

Monitoring

The DNS — lab row of the k8s-lab dashboard shows records requested vs published, the last sync, errors and CoreDNS failures and latency. The DNS SLOs alert when the lab DNS fails or ExternalDNS falls behind.

Troubleshooting

dig @192.168.56.20 grafana.lab.internal +short           # ask the lab DNS directly
kubectl -n external-dns logs deploy/external-dns          # "Add/set key /skydns/..." per record
vagrant ssh storage -c 'systemctl status etcd coredns --no-pager'
vagrant ssh storage -c 'sudo journalctl -u coredns -n 20 --no-pager'
vagrant ssh storage -c 'sudo etcdctl --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/etcd/tls/ca.crt --cert=/etc/etcd/tls/external-dns.crt \
  --key=/etc/etcd/tls/external-dns.key get /skydns --prefix --keys-only'

See also Troubleshooting → Browser can’t open a lab URL.