summaryrefslogtreecommitdiffstats
path: root/README.md
blob: b0e8712c8854ee6f03afa79b330bd4abd4680e76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<p align="center">
  <img src="https://raw.githubusercontent.com/cert-manager/cert-manager/d53c0b9270f8cd90d908460d69502694e1838f5f/logo/logo-small.png" height="256" width="256" alt="cert-manager project logo" />
</p>

# ACME webhook example

The ACME issuer type supports an optional 'webhook' solver, which can be used
to implement custom DNS01 challenge solving logic.

This is useful if you need to use cert-manager with a DNS provider that is not
officially supported in cert-manager core.

## Why not in core?

As the project & adoption has grown, there has been an influx of DNS provider
pull requests to our core codebase. As this number has grown, the test matrix
has become un-maintainable and so, it's not possible for us to certify that
providers work to a sufficient level.

By creating this 'interface' between cert-manager and DNS providers, we allow
users to quickly iterate and test out new integrations, and then packaging
those up themselves as 'extensions' to cert-manager.

We can also then provide a standardised 'testing framework', or set of
conformance tests, which allow us to validate that a DNS provider works as
expected.

## Creating your own webhook

### Using Hostinger DNS

The webhook implements the [Hostinger DNS zone API](https://docs.hostinger.com/api-reference/endpoints/dns/zone).
Build and publish the image, then install the chart with a group name under a
domain you own:

```sh
make build IMAGE_NAME=your-registry/webhook IMAGE_TAG=latest
docker push your-registry/webhook:latest
helm upgrade --install hostinger-webhook ./deploy/example-webhook \
  --namespace cert-manager \
  --set image.repository=your-registry/webhook \
  --set image.tag=latest \
  --set groupName=acme.example.com
```

Create a Hostinger API token in hPanel and store it in a Secret in cert-manager's
cluster resource namespace (normally `cert-manager` for a ClusterIssuer):

```sh
kubectl -n cert-manager create secret generic hostinger-api-token \
  --from-literal=api-token=YOUR_HOSTINGER_API_TOKEN
```

Use this solver in your Issuer or ClusterIssuer's `spec.acme.solvers`:

```yaml
- dns01:
    webhook:
      groupName: acme.example.com # Must match the Helm groupName.
      solverName: hostinger
      config:
        apiKeySecretRef:
          name: hostinger-api-token
          key: api-token
```

The Secret is read from the challenge's resource namespace. For a namespaced
Issuer, put the Secret in the Issuer's namespace and grant the webhook's service
account `get` access there. The chart grants access to `apiKeySecretName` (default
`hostinger-api-token`) in `certManager.namespace`; adjust these values if needed.
Run a single webhook replica so record cleanup and presentation are serialized.
Presentation appends the TXT value; cleanup preserves other values at that name.

Webhook's themselves are deployed as Kubernetes API services, in order to allow
administrators to restrict access to webhooks with Kubernetes RBAC.

This is important, as otherwise it'd be possible for anyone with access to your
webhook to complete ACME challenge validations and obtain certificates.

To make the set up of these webhook's easier, we provide a template repository
that can be used to get started quickly.

When implementing your webhook, you should set the `groupName` in the
[values.yml](deploy/example-webhook/values.yaml) of your chart to a domain name that 
you - as the webhook-author - own. It should not need to be adjusted by the users of
your chart.

### Creating your own repository

### Running the test suite

All DNS providers **must** run the DNS01 provider conformance testing suite,
else they will have undetermined behaviour when used with cert-manager.

**It is essential that you configure and run the test suite when creating a
DNS01 webhook.**

```sh
export TEST_ZONE_NAME=example.com.
export HOSTINGER_API_TOKEN # Populate this variable from your secret store.
make test
```

`make test` runs the unit tests and cert-manager's actual `RunConformance` suite
against `customDNSProviderSolver`, with strict mode enabled. This includes checking that
deleting one TXT value preserves another at the same name. Missing configuration
fails the command; conformance tests are never silently skipped. Test results
are not cached.

The suite creates and removes real TXT records under a unique
`_acme-challenge.cert-manager-conformance-<random>.<zone>` name and checks public
authoritative DNS. It downloads local Kubernetes test binaries and starts a
temporary API server; no existing cluster is needed. The token is written to a
temporary Secret fixture, applied in each test namespace, and removed afterward.

Run only the mock API and credential tests without live credentials or local
Kubernetes binaries using:

```sh
make test-unit
```

The conformance test is selected with the `conformance` build tag. If running Go
directly, use `go test -tags=conformance -count=1 -timeout=30m ./...` and provide
`TEST_ASSET_ETCD`, `TEST_ASSET_KUBE_APISERVER`, and `TEST_ASSET_KUBECTL` paths as
well as the zone and token. Plain `go test ./...` runs only the unit tests.