A cert-manager DNS01 webhook for the Domeneshop DNS provider
Find a file
Tommy 637971bafb
Some checks failed
Validate and Release Chart / Lint (push) Successful in 4s
Validate and Release Chart / Audit (push) Successful in 4s
Validate and Release Chart / Outdated APIs (push) Successful in 3s
Validate and Release Chart / Publish Helm Chart (push) Failing after 3s
Merge pull request 'chore(deps): update code.252.no/pub/cert-manager-webhook-domeneshop docker tag to v2' (#3) from renovate/code.252.no-pub-cert-manager-webhook-domeneshop-2.x into main
Reviewed-on: #3
2025-03-19 15:43:31 +00:00
.forgejo fix: Removed spaces around the assignment operator in the build.yaml file to ensure proper variable assignment. 2025-03-15 22:43:28 +01:00
chart chore(deps): update code.252.no/pub/cert-manager-webhook-domeneshop docker tag to v2 2025-03-17 01:00:19 +00:00
ci feat: Refactor Dockerfile and project structure for cert-manager-webhook-domeneshop 2025-03-15 22:29:27 +01:00
src feat: Enhance Dockerfile, add permissions and add tests 2025-03-16 09:48:18 +01:00
.dockerignore Ignore .idea directory, and add .dockerignore 2024-10-02 20:24:50 +02:00
.gitignore Ignore .idea directory, and add .dockerignore 2024-10-02 20:24:50 +02:00
Dockerfile chore(deps): update alpine docker tag to v20250108 2025-03-17 01:00:17 +00:00
LICENSE Initial commit 2021-02-08 11:50:55 +01:00
README.md feat: Refactor Dockerfile and project structure for cert-manager-webhook-domeneshop 2025-03-15 22:29:27 +01:00
renovate.json Add renovate.json 2025-03-16 01:00:25 +00:00

cert-manager-webhook-domeneshop

This is a DNS01 webhook implementation for cert-manager, allowing usage of the Domeneshop API to issue certificates for wildcard domains or other names that are not publicly accessible.

This repository is based on cert-manager-webhook-domeneshop, which is based on the cert-manager-webhook-example repository provided by Jetstack.

Usage

Requirements

  • Working cert-manager deployed in your Kubernetes cluster
  • An API key for the Domeneshop API
  • A domain configured to use DNS service with Domeneshop

Installing

  1. Create a Kubernetes namespace for the webhook to live in

    kubectl create ns webhook-domeneshop
    
  2. Install the Helm chart

    helm install webhook --set groupName='api.domeneshop.no' --namespace=webhook-domeneshop deploy/domeneshop-webhook
    
  3. Ensure the pod is running

    % kubectl get pods -n webhook-domeneshop
    NAME                                                       READY   STATUS    RESTARTS   AGE
    webhook-cert-manager-webhook-domeneshop-7745d84f75-qrlsk   1/1     Running   0          108s
    

Issuer and secrets

In order to issue certificates using the webhook, create a new Issuer resource with cert-manager.

Ensure the email address is set to a valid address, and that the groupName matches the name passed in step #2 above.

apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: domeneshop-dns01
spec:
  acme:
    email: example@example.com
    server: https://acme-v02.api.letsencrypt.org/directory
    privateKeySecretRef:
      name: letsencrypt-account-key
    solvers:
    - dns01:
        webhook:
          groupName: api.domeneshop.no
          solverName: domeneshop
          config:
            APITokenSecretRef:
              key: APIToken
              name: domeneshop-credentials
            APISecretSecretRef:
              key: APISecret
              name: domeneshop-credentials

Finally, create the corresponding secret containing your Domeneshop API credentials:

kubectl create secret generic domeneshop-credentials \
    --namespace webhook-domeneshop \
    --from-literal=APIToken=<token> \
    --from-literal=APISecret=<secret>

NOTE: If your cluster is RBAC-enabled and you want to use a ClusterIssuer instead, you may have to uncomment the bottom two resources in deploy/domeneshop-webhook/templates/rbac.yaml before installing the Helm chart, in order for the webhook to read the credentials secrets in the cert-manager namespace.

Issue a certificate

You should now be ready to issue certificate using DNS01 challenges through the Domeneshop API!

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: test-certificate
spec:
  dnsNames:
  - www.example.com
  issuerRef:
    name: domeneshop-dns01
    kind: Issuer
  secretName: test-certificate-tls

Eventually, the certificate should be issued using the webhook:

% kubectl get certificate
NAME                                                  READY   SECRET                                                AGE
test-certificate                                      True    test-certificate-tls                                  3m36s

For troubleshooting, try using kubectl describe on the resources related to the issuance (e.g. certificates.acme.cert-manager.io, challenges.acme.cert-manager.io, orders.acme.cert-manager.io). Refer to the cert-manager documentation for more information.

Running tests

  1. Download required testing binaries:

    make test/kubebuilder
    
  2. Edit testdata/domeneshop-webhook/secret.yml with a valid API token and secret.

  3. Run the tests (replace example.com. with the FQDN for a domain on your account):

    TEST_ZONE_NAME=example.com. go test -v .
    

    NOTE: The tests will create and validate TXT records on your domain.