cert-manager-webhook-nameocean logo

cert-manager-webhook-nameocean

NameOcean/cert-manager-webhook-nameocean by us

cert-manager DNS-01 solver for NameOcean DNS

0stars Go Apache-2.0 last commit 1 day, 2 hours ago
README.md

cert-manager-webhook-nameocean

A cert-manager DNS-01 solver for NameOcean DNS. It adds the _acme-challenge TXT record through the NameOcean API and removes it once the certificate is issued, so cert-manager can get wildcard and internal-only certificates for domains hosted on NameOcean DNS.

Install

cert-manager must be installed first.

helm install cert-manager-webhook-nameocean \
  oci://ghcr.io/nameocean/charts/cert-manager-webhook-nameocean \
  --namespace cert-manager

API key

Create an API key at https://nameocean.net/dashboard/api-keys/ with the dns:read and dns:write scopes only (you can also limit it to your cluster's egress IPs), and store it in a Secret in cert-manager's namespace:

kubectl -n cert-manager create secret generic nameocean-api-key \
  --from-literal=api-key=no_live_...

ClusterIssuer

apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt
spec:
  acme:
    server: https://acme-v02.api.letsencrypt.org/directory
    privateKeySecretRef:
      name: letsencrypt-account
    solvers:
      - dns01:
          webhook:
            groupName: acme.nameocean.net
            solverName: nameocean
            config:
              apiKeySecretRef:
                name: nameocean-api-key
                key: api-key
              # ttl: 5m   # TTL of the TXT record (default 5m)

Then request a certificate as usual:

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: example-com
spec:
  secretName: example-com-tls
  issuerRef:
    name: letsencrypt
    kind: ClusterIssuer
  dnsNames:
    - example.com
    - "*.example.com"

Try it with Let's Encrypt's staging directory (https://acme-staging-v02.api.letsencrypt.org/directory) first.

A namespaced Issuer

The Secret must be in the Issuer's namespace, and the solver may only read Secrets in the namespaces listed in the chart's secretNamespaces (default: cert-manager). Add yours:

helm upgrade cert-manager-webhook-nameocean ... --reuse-values \
  --set 'secretNamespaces={cert-manager,my-app}'

Chart values

Value Default
groupName acme.nameocean.net The webhook.groupName Issuers use
secretNamespaces [cert-manager] Namespaces the solver may read API key Secrets from
certManager.namespace cert-manager Where cert-manager runs
certManager.serviceAccountName cert-manager cert-manager's service account
image.repository ghcr.io/nameocean/cert-manager-webhook-nameocean
image.tag chart appVersion

How it works

For a challenge on _acme-challenge.www.example.com in the zone example.com, the solver POSTs a TXT record with hostname _acme-challenge.www to /api/v1/dns/example.com/records. Calling it again with the same value does nothing. Cleanup deletes only the TXT record holding that challenge's value, so example.com and *.example.com can be validated at the same time. Delegated subzones you host on NameOcean work too: cert-manager finds the zone, the solver uses it.

Development

make test          # unit tests against an in-memory fake API
make conformance   # cert-manager's DNS-01 conformance suite (envtest), against the fake API
NAMEOCEAN_API_KEY=no_live_... TEST_ZONE_NAME=example.com. make conformance   # against the real API
make build         # container image

Based on cert-manager/webhook-example. Apache-2.0.