tsigoat

by ENIX

Helm chartv0.2.0-rc.3App 0.2.0-rc.3MITVerified publisher

An RFC 2136 to DNS provider API proxy, authenticated with TSIG

About this chart

tsigoat

An RFC 2136 to DNS provider API proxy, authenticated with TSIG: DNS clients send RFC 2136 updates signed with TSIG keys, and tsigoat applies them through the API of the DNS provider, within the names and types that each key may update. Its founding use is the ACME DNS-01 challenge of cert-manager, whose key only reaches the _acme-challenge records and never holds the API key of the provider.

The documentation of tsigoat describes its configuration, its clients and its operations; this page covers the chart.

Installing

The chart needs Kubernetes 1.26 or later, which serves UDP and TCP on one LoadBalancer port, and Helm 3.8 or later, which installs charts from OCI registries.

tsigoat runs under the restricted Pod Security profile. Create its namespace, and the Secret that holds the TSIG secrets and the API key of the provider:

kubectl create namespace tsigoat
kubectl label namespace tsigoat pod-security.kubernetes.io/enforce=restricted
kubectl -n tsigoat create secret generic tsigoat-secrets \
  --from-literal=cert-manager="$(openssl rand -base64 32)" \
  --from-literal=powerdns-api-key=...

Write the configuration of tsigoat under config, which reads the secrets from the files of that Secret, in /run/secrets/tsigoat:

# values.yaml
config:
  keys:
    - name: cert-manager.
      secretFile: /run/secrets/tsigoat/cert-manager
  backends:
    - name: pdns
      type: powerdns
      powerdns:
        url: http://pdns-api.powerdns.svc.cluster.local:8081
        apiKeyFile: /run/secrets/tsigoat/powerdns-api-key
  zones:
    - name: example.com.
      policy:
        - key: cert-manager.
          acme: ["example.com.", "**.example.com."]
secret:
  existingSecret: tsigoat-secrets

Then install the chart, from its OCI registry:

helm -n tsigoat install tsigoat oci://quay.io/enix/charts/tsigoat --values values.yaml

or from the Helm repository of charts.enix.io:

helm repo add enix https://charts.enix.io
helm -n tsigoat install tsigoat enix/tsigoat --values values.yaml

cert-manager reaches tsigoat at tsigoat.tsigoat.svc.cluster.local:53, see the clients. examples/helm holds complete values files.

Configuration

config holds the configuration file of tsigoat, as its reference describes it, without listen and admin: the chart sets the listen addresses. The schema of the values holds the one of the configuration file: a field that tsigoat does not know, or a field of the wrong shape, fails the installation, rather than the pod. The chart refuses a configuration without zones or backends, and one that writes a secret inline, which would land in a ConfigMap: the values of the headers of a webhook too, since the chart cannot tell a secret header from another.

The secrets, the TSIG secrets of the clients and those of the backends, come from one of:

  • secret.existingSecret, a Secret created apart from the chart, which keeps the secrets out of the Helm release;
  • secret.files, the files of a Secret that the chart creates;
  • environment variables of extraEnv, read with secretEnv and apiKeyEnv.

In front of BIND or another name server that implements RFC 2136, an rfc2136 backend relays the updates with a key of tsigoat, see RFC 2136 servers and examples/helm/bind-relay.values.yaml. For a provider that tsigoat does not support, a webhook backend posts the updates to an endpoint of yours, see Webhooks.

tsigoat reads its configuration and its secrets at startup. The chart restarts it when config or secret.files changes; after a change to an existing Secret, restart it yourself:

kubectl -n tsigoat rollout restart deployment tsigoat

A PowerDNS API served over HTTPS with a private certificate authority takes a CA bundle, mounted with extraVolumes and extraVolumeMounts, and named by the caFile of the backend.

Exposing tsigoat

The DNS Service listens on port 53 over UDP and TCP. A ClusterIP Service, the default, serves the clients of the cluster, such as cert-manager. To serve clients outside of it, set service.type to LoadBalancer or NodePort; then restrict the sources with service.loadBalancerSourceRanges or a NetworkPolicy, and set service.externalTrafficPolicy to Local to log the addresses of the clients rather than those of the nodes.

A network that routes addresses to the nodes, such as addresses that it announces through BGP, reaches a ClusterIP Service on its service.externalIPs. Kubernetes deprecates that field, and clusters with the DenyServiceExternalIPs admission plugin refuse it: where the cluster has a load balancer, such as one that announces its addresses through BGP, prefer a LoadBalancer Service. service.extraLabels gives the Service the labels that an announcement or a load balancer selects. The other fields of the Service have their values too: its IP families (service.ipFamilyPolicy, service.ipFamilies), its routing inside the cluster (service.internalTrafficPolicy, service.trafficDistribution), and those of a load balancer (service.loadBalancerIP, service.allocateLoadBalancerNodePorts, service.healthCheckNodePort).

The administration server, which serves the probes and the metrics, has no authentication: it has its own Service, always of type ClusterIP.

Replicas

tsigoat runs two replicas by default, with a rolling update and a PodDisruptionBudget, so that one of them may stop while the other serves. A stopping pod goes on serving for shutdownDelaySeconds, while its readiness probe fails, so that the Services stop sending it requests before it closes its listeners. Each pod serializes the updates of a zone; the records that an update adds and removes apply to the records as they stand, so that the pods keep the records of each other's updates, such as the challenges of a certificate and of its wildcard, on the hosted providers and on PowerDNS since 4.9.12 and 5.0.2. A change of TTL, prerequisites and CNAME transitions are serialized within one pod alone: see Several instances. To keep every guarantee of RFC 2136, or in front of an older PowerDNS, set replicaCount to 1, and strategy.type to Recreate, which stops the old pod before it starts the new one during a rollout alone: a pod deleted by hand or evicted gets its replacement at once, while it serves for its shutdown delay, then finishes its updates in progress, for 26 seconds at most. Avoid deleting the pod while updates run. service.sessionAffinity set to ClientIP sends the requests of a client to one pod, which keeps these guarantees between the updates of that client, not between clients. topologySpreadConstraints spreads the replicas over nodes or zones.

Monitoring

With the Prometheus operator, serviceMonitor.enabled scrapes the metrics of tsigoat, and prometheusRules.enabled adds its alerts:

AlertFires whenSeverity
TsigoatBackendErrorsCalls to a backend fail for 10 minuteswarning
TsigoatUncertainUpdatesAn update may have applied in part, within 15 minuteswarning
TsigoatUpdatesFailingUpdates of a zone fail with SERVFAIL for 10 minuteswarning
TsigoatSignatureFailuresRequests fail TSIG verification more than once every ten seconds, for 15 minutesinfo
TsigoatLegacyAlgorithmA key signed with HMAC-MD5 or HMAC-SHA1 within a dayinfo

The operations guide tells what to do about each. prometheusRules.disabledAlerts leaves alerts out, and prometheusRules.alertLabels labels them, for routing or to change their severity. The alerts select the metrics of the release by namespace and by the job of the ServiceMonitor; with another scrape configuration, set prometheusRules.selector.

Image

The chart of a release pulls its image by digest. The release writes into image.digests the digest of each of its tags: the digest of the image of every platform, so that each node pulls its own, and the same on ghcr.io, quay.io and docker.io, which the release checks. image.registry, or global.imageRegistry, chooses the registry; image.tagSuffix: -busybox, the image with a shell, pinned as well. The signatures of the images cover these digests.

A mirror that copies every platform, such as crane copy or skopeo copy --all, keeps the digests; for one that does not, set image.pinDigest to false. Another tag in image.tag is pulled by tag, and image.digest pins any image.

Verifying the chart

The chart is signed with cosign, keyless, by the release workflow, on the tag of its version:

cosign verify quay.io/enix/charts/tsigoat:<version> \
  --certificate-identity 'https://github.com/enix/tsigoat/.github/workflows/release.yaml@refs/tags/v<version>' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com

SECURITY.md covers the images and the binaries.

Values

KeyTypeDefaultDescription
nameOverridestring""Partially override the name of the resources, which the release name prefixes
fullnameOverridestring""Fully override the name of the resources
namespaceOverridestring""Override the namespace of the resources
enabledbooltrueRead by a parent chart that installs this one under a condition, such as tsigoat.enabled; the chart itself ignores it
extraLabelsobject{}Labels added to every object of the chart; podLabels labels the pod. The labels of the chart win over them, and so do those of each object
image.registrystring"ghcr.io"Image registry; an empty string lets the container runtime choose
image.repositorystring"enix/tsigoat"Image repository
image.tagstring""Image tag; the appVersion of the chart by default
image.tagSuffixstring""Appended to the tag: -busybox selects the image with a shell
image.digeststring""Image digest, which takes precedence over the tag
image.pinDigestbooltruePull the tags of the release by the digests of image.digests; false pulls by tag, for a registry that holds other digests, such as a mirror that copied one platform
image.digestsobjectthe digests of the release; empty in the repositoryDigests of the images of the release, by tag, which the release writes: the digest of each multi-platform image, the same on every registry
image.pullPolicystring"IfNotPresent"Image pull policy
imagePullSecretslist[]Names of the Secrets to pull the image with
replicaCountint2Number of pods. Several pods keep the records of each other's updates, on PowerDNS since 4.9.12 and 5.0.2, but not every guarantee of RFC 2136 across pods. 1, with the Recreate strategy, keeps them all, but while a pod deleted or evicted outside a rollout finishes its updates beside its replacement: see Replicas
strategyobjecta rolling update that starts a new pod before stopping an old oneUpdate strategy of the Deployment. Helm merges the fields given here with these defaults: with maxSurge: 0, set maxUnavailable above 0 too
podDisruptionBudget.enabledbooltrueCreate a PodDisruptionBudget, with more than one replica
podDisruptionBudget.maxUnavailableint1Pods that a voluntary disruption, such as the drain of a node, may stop at once: a number, or a percentage such as 50%
configobjectnone: the chart refuses to install without zones and backendsConfiguration of tsigoat: keys, backends and zones, as docs/configuration.md describes them. The chart sets the listen addresses itself. Secret files are read from /run/secrets/tsigoat, see secret.
secret.existingSecretstring""Name of an existing Secret, mounted in /run/secrets/tsigoat, whose keys the configuration reads with secretFile and apiKeyFile
secret.filesobject{}Files of a Secret that the chart creates and mounts in /run/secrets/tsigoat, by file name; prefer existingSecret, which keeps the secrets out of the release
log.formatstring"json"Log format
log.levelstring"info"Log level
listenHoststring"[::]"Host part of the listen addresses in the pod: [::] serves IPv4 and IPv6, 0.0.0.0 serves IPv4 on nodes without IPv6; the chart puts an IPv6 address in brackets
service.typestring"ClusterIP"Type of the DNS Service: LoadBalancer or NodePort exposes tsigoat out of the cluster
service.portint53DNS port of the Service, for both UDP and TCP
service.nodePortint0Node port for both UDP and TCP, with NodePort and LoadBalancer; 0 lets Kubernetes choose
service.annotationsobject{}Annotations of the DNS Service, such as those of a cloud load balancer
service.extraLabelsobject{}Labels of the DNS Service, such as those that a BGP advertisement or a load balancer selects; they win over extraLabels, and the labels of the chart over both
service.clusterIPstring""Cluster IP of the DNS Service, in the service range of the cluster; Kubernetes assigns one when empty
service.externalIPslist[]Addresses out of the cluster that reach the DNS Service, such as those that the ne

Deploy tsigoat with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has tsigoat on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the charttsigoat is pinned at v0.2.0-rc.3 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply