Skip to content

Commit 572c495

Browse files
authored
docs: fix user/tls-cert-manager Issuer/ClusterIssuer (#1473)
* docs: fix user/tls-cert-manager Issuer/ClusterIssuer Based on feedback from @irbekrm of cert-manager. Signed-off-by: Tommie Gannert <[email protected]> * docs: only use ClusterIssuer in docs/tls-cert-manager. Incorporate additional feedback from @irbekrm. Signed-off-by: Tommie Gannert <[email protected]>
1 parent 35e6166 commit 572c495

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

docs/latest/user/tls-cert-manager.md

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $ helm repo add jetstack https://charts.jetstack.io
3030
$ helm upgrade --install --create-namespace --namespace cert-manager --set installCRDs=true --set featureGates=ExperimentalGatewayAPISupport=true cert-manager jetstack/cert-manager
3131
```
3232

33-
You should now have `cert-manager` running and having nothing to do:
33+
You should now have `cert-manager` running with nothing to do:
3434

3535
```console
3636
$ kubectl wait --for=condition=Available deployment -n cert-manager --all
@@ -51,33 +51,33 @@ cert-manager can have any number of *issuer* configurations.
5151
The simplest issuer type is [SelfSigned](https://cert-manager.io/docs/configuration/selfsigned/).
5252
It simply takes the certificate request and signs it with the private key it generates for the TLS Secret.
5353

54+
```{note}
55+
Self-signed certificates don't provide any help in establishing trust between certificates.
56+
However, they are great for initial testing, due to their simplicity.
57+
```
58+
5459
To install self-signing, run
5560

5661
```console
5762
$ kubectl apply -f - <<EOF
5863
apiVersion: cert-manager.io/v1
59-
kind: Issuer
64+
kind: ClusterIssuer
6065
metadata:
6166
name: selfsigned
62-
namespace: default
6367
spec:
6468
selfSigned: {}
6569
EOF
6670
```
6771

68-
The `selfSigned` issuer type is namespaced, which means it will use the Issuer resource kind.
69-
It can only issue certificates for Secrets in the same namespace, here "default."
70-
We will later see ClusterIssuer used, which can deal with Secrets (and hence Gateways) in any namespace.
71-
7272
## Creating a TLS Gateway Listener
7373

74-
We now have to create (or patch) a Gateway to reference cert-manager:
74+
We now have to patch the example Gateway to reference cert-manager:
7575

7676
```console
7777
$ kubectl patch gateway/eg --patch-file - <<EOF
7878
metadata:
7979
annotations:
80-
cert-manager.io/issuer: selfsigned
80+
cert-manager.io/clusterissuer: selfsigned
8181
cert-manager.io/common-name: "Hello World!"
8282
spec:
8383
listeners:
@@ -99,7 +99,7 @@ cert-manager doesn't care, but we'll keep it all together in this guide.
9999
Nowadays, X.509 certificates don't use the subject Common Name for hostname matching, so you can set it to whatever you want, or leave it empty.
100100
The important parts here are
101101

102-
* the annotation referencing the "selfsigned" Issuer we created above,
102+
* the annotation referencing the "selfsigned" ClusterIssuer we created above,
103103
* the `hostname`, which is required (but see [#6051](https://github.com/cert-manager/cert-manager/issues/6051) for computing it based on attached HTTPRoutes), and
104104
* the named Secret, which is what cert-manager will create for us.
105105

@@ -143,8 +143,8 @@ If the `certificatRef` points to a valid certificate, given the hostnames found
143143

144144
If there is no valid certificate, or it is about to expire, cert-manager's `gateway-shim` creates a Certificate resource, or updates the existing one.
145145
cert-manager then follows the [Certificate Lifecycle](https://cert-manager.io/docs/concepts/certificate/#certificate-lifecycle).
146-
To know how to issue the certificate, an Issuer is configured, and referenced through annotations on the Gateway resource, which you did above.
147-
Once a matching Issuer is found, that plugin does what needs to be done to acquire a signed certificate.
146+
To know how to issue the certificate, an ClusterIssuer is configured, and referenced through annotations on the Gateway resource, which you did above.
147+
Once a matching ClusterIssuer is found, that plugin does what needs to be done to acquire a signed certificate.
148148

149149
In the case of the ACME protocol (used by Let's Encrypt,) cert-manager can also use an HTTP Gateway to solve the HTTP-01 challenge type.
150150
This is the other side of cert-manager's Gateway API support:
@@ -160,8 +160,6 @@ As you can imagine, cert-manager requires quite broad permissions to update Secr
160160
We will start using the Let's Encrypt staging environment, to spare their production environment.
161161
Our Gateway already contains an HTTP listener, so we will use that for the HTTP-01 challenges.
162162

163-
In the case of ACME, the plugin is a cluster-wide issuer type, so we have to use ClusterIssuer:
164-
165163
```console
166164
$ CERT_MANAGER_CONTACT_EMAIL=$(git config user.email) # Or whatever...
167165
$ kubectl apply -f - <<EOF
@@ -209,10 +207,9 @@ Status:
209207
Now we're ready to update the Gateway annotation to use this issuer instead:
210208

211209
```console
212-
$ kubectl annotate gateway/eg cert-manager.io/issuer- cert-manager.io/clusterissuer=letsencrypt-staging
210+
$ kubectl annotate --overwrite gateway/eg cert-manager.io/clusterissuer=letsencrypt-staging
213211
```
214212

215-
Since the ClusterIssuer has a different annotation key, we removed the old and added the new.
216213
The Gateway should be picked up by cert-manager, which will create a new certificate for you, and replace the Secret.
217214

218215
You should see a new CertificateRequest to track:
@@ -290,12 +287,22 @@ $ curl -v -HHost:www.example.com --resolve www.example.com:127.0.0.1 https://www
290287

291288
## Collecting Garbage
292289

293-
cert-manager [deletes unused Certificate resources](https://github.com/cert-manager/cert-manager/blob/c5e6bf39d688d202592318eaf91988466a7ee37b/pkg/controller/certificate-shim/sync.go#L171), and they are updated in-place when possible, so there should be no need for cleaning up Certificate resources:
294-
If no Secret points to a Certificate, the Certificate is deleted.
290+
You probably want to set the `cert-manager.io/revision-history-limit` annotation on your Gateway to make cert-manager prune the CertificateRequest history.
295291

296-
The other way around is also possible, using [a flag](https://cert-manager.io/docs/usage/certificate/#cleaning-up-secrets-when-certificates-are-deleted).
292+
cert-manager [deletes unused Certificate resources](https://github.com/cert-manager/cert-manager/blob/c5e6bf39d688d202592318eaf91988466a7ee37b/pkg/controller/certificate-shim/sync.go#L171), and they are updated in-place when possible, so there should be no need for cleaning up Certificate resources.
293+
The deletion is based on whether a Gateway still holds a `tls.certificateRefs` that requires the Certificate.
297294

298-
You probably want to set the `cert-manager.io/revision-history-limit` annotation on your Gateway to make cert-manager prune the CertificateRequest history.
295+
If you remove a TLS listener from a Gateway, you may still have a Secret lingering.
296+
cert-manager can clean it up using [a flag](https://cert-manager.io/docs/usage/certificate/#cleaning-up-secrets-when-certificates-are-deleted).
297+
298+
## Issuer Namespaces
299+
300+
We have used ClusterIssuer resources in this tutorial.
301+
They are not bound to any namespace, and will read annotations from Gateways in any namespace.
302+
You could also use [Issuer](https://cert-manager.io/docs/concepts/issuer/), which is bound to a namespace.
303+
This is useful e.g. if you want to use different ACME accounts for different namespaces.
304+
305+
If you change the issuer kind, you also need to change the annotation key from `cert-manager.io/clusterissuer` to `cert-manager.io/issuer`.
299306

300307
## Using ExternalDNS
301308

0 commit comments

Comments
 (0)