Skip to content

About

cert-manager webhook to use ACME DNS01 solver with desec.io

Topics

Resources

Stars

20 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

cert-manager project logo

ACME webhook for desec.io DNS API

This solver can be used with desec.io DNS API. The documentation of the API can be found here

Requirements

Installation

Using the public helm chart (OCI)

helm install desec-webhook -n cert-manager \
  oci://ghcr.io/su541/helm/cert-manager-desec-webhook --version <version>

Available versions are listed on the releases page. The image tag defaults to the chart's appVersion, so chart and image always match.

Using helm from local checkout

helm install desec-webhook -n cert-manager deploy/desec-webhook

Uninstallation

helm uninstall desec-webhook -n cert-manager

Creating an issuer

Create a secret containing the credentials

apiVersion: v1
kind: Secret
metadata:
  name: desec-io-token
  namespace: cert-manager
type: Opaque
data:
  token: your-key-base64-encoded
kubectl create secret generic desec-io-token --from-literal "token=<your token>" --namespace cert-manager

The webhook may only read the secrets listed in secretName (values.yaml) in the namespace it is installed in. With a ClusterIssuer, put the secret into that namespace (usually cert-manager).

Create a 'ClusterIssuer' or 'Issuer' resource as the following:

apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt-staging
spec:
  acme:
    server: https://acme-staging-v02.api.letsencrypt.org/directory
    email: [email protected]

    privateKeySecretRef:
      name: letsencrypt-staging

    solvers:
      - dns01:
          webhook:
            config:
              apiKeySecretRef:
                key: token
                name: desec-io-token
            groupName: de.su541.acme
            solverName: desec

Using a namespaced Issuer

A ClusterIssuer reads the token secret from cert-manager's cluster resource namespace (usually cert-manager), so one secret serves the whole cluster.

A namespaced Issuer reads the token secret from its own namespace. This is intentional: whoever can create an Issuer in a namespace must not be able to use a token stored somewhere else. The chart only grants the webhook access to secrets in its own namespace, so for each additional namespace allow the webhook to read that one secret:

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: desec-webhook:secret-reader
  namespace: my-app
rules:
  - apiGroups: [""]
    resources: ["secrets"]
    resourceNames: ["desec-io-token"]
    verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: desec-webhook:secret-reader
  namespace: my-app
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: desec-webhook:secret-reader
subjects:
  - kind: ServiceAccount
    # kubectl -n cert-manager get serviceaccounts
    name: desec-webhook-cert-manager-desec-webhook
    namespace: cert-manager

Create a manual certificate

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: example-cert
  namespace: cert-manager
spec:
  commonName: example.com
  dnsNames:
    - example.com
  issuerRef:
    name: letsencrypt-staging
    kind: ClusterIssuer
  secretName: example-cert

Using cert-manager with traefik ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: bitwarden
  namespace: utils
  labels:
    app: bitwarden
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-staging
    kubernetes.io/ingress.class: traefik
    traefik.ingress.kubernetes.io/rewrite-target: /$1
    traefik.ingress.kubernetes.io/router.entrypoints: websecure
    traefik.ingress.kubernetes.io/router.tls: 'true'
spec:
  tls:
    - hosts:
        - bitwarden.acme.example.com
      secretName: bitwarden-crt
  rules:
    - host: bitwarden.acme.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: bitwarden
                port:
                  number: 80

Development

Unit tests

make test

The unit tests run against an in-memory fake of the deSEC API and a fake Kubernetes client. They need no credentials.

Conformance tests

All DNS providers must pass the cert-manager DNS01 conformance suite. It runs against the real deSEC API and needs a deSEC domain and an API token:

export DESEC_TOKEN=<your token>
TEST_ZONE_NAME=example.com. make test-conformance

The token is only written to a temporary directory during the test.

Releases

Versioning follows Semantic Versioning and is derived from Conventional Commits by release-please:

Commit / PR title Version bump
fix: ... patch
feat: ... minor
feat!: ... or footer BREAKING CHANGE: ... major
docs:, chore:, ci:, test:, refactor: none

PRs are squash-merged, so the PR title must be a Conventional Commit (checked by CI). release-please keeps a release PR open that collects the changes. Merging it creates the tag vX.Y.Z, the GitHub release and CHANGELOG.md, and publishes

  • the image ghcr.io/su541/cert-manager-desec-webhook with the tags X.Y.Z, X.Y, X and latest (cosign-signed)
  • the chart oci://ghcr.io/su541/helm/cert-manager-desec-webhook with version X.Y.Z

Every push to master additionally publishes the image tags master and sha-<commit>.

About

cert-manager webhook to use ACME DNS01 solver with desec.io

Topics

Resources

Stars

20 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages