You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/usage/certificate.md
+90Lines changed: 90 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -322,6 +322,96 @@ It is also required that `spec.duration` > `spec.renewBefore`.
322
322
323
323
Once an X.509 certificate has been issued, cert-manager will calculate the renewal time for the `Certificate`. By default this will be 2/3 through the X.509 certificate's duration. If `spec.renewBefore` or `spec.renewBeforePercentage` has been set, it will be the effective `spec.renewBefore` amount of time before expiry. cert-manager will set `Certificate`'s `status.RenewalTime` to the time when the renewal will be attempted.
324
324
325
+
### Renewal policies and renewal windows
326
+
327
+
In addition to `spec.renewBefore` and `spec.renewBeforePercentage`, cert-manager supports
328
+
configuring *when* renewal is allowed to happen by using `spec.renewal`.
329
+
330
+
This is useful when you want certificate renewals to happen only during approved maintenance
331
+
periods, business hours, or other time windows.
332
+
333
+
#### Overview
334
+
335
+
The `spec.renewal` field supports two policies:
336
+
337
+
- `RenewBefore`: cert-manager renews the certificate according to the normal renewal time
338
+
calculation, while also respecting any configured renewal windows.
339
+
- `Disabled`: disables automatic renewal for the `Certificate`.
340
+
341
+
A renewal window is defined by:
342
+
343
+
- `cron`: a `cron` expression describing when a window starts. This uses a standard 5 field `cron` expression as shown below:
344
+
```markdown
345
+
* * * * *
346
+
| | | | |
347
+
| | | | day of week (0-6)
348
+
| | | month (1-12)
349
+
| | day of month (1-31)
350
+
| hour (0-23)
351
+
minute (0-59)
352
+
```
353
+
For example:
354
+
- `0 0 * * *`- everyday at 00:00.
355
+
- `0 2 * * 1-5`- at 02:00 only on weekdays.
356
+
357
+
- `windowDuration`: how long that window stays open.
358
+
- `timezone`: an optional IANA timezone such as `America/Denver`. If omitted, UTC is used.
359
+
360
+
```yaml
361
+
apiVersion: cert-manager.io/v1
362
+
kind: Certificate
363
+
metadata:
364
+
name: example-com
365
+
namespace: sandbox
366
+
spec:
367
+
secretName: example-com-tls
368
+
dnsNames:
369
+
- example.com
370
+
issuerRef:
371
+
name: ca-issuer
372
+
kind: Issuer
373
+
374
+
duration: 2160h # 90d
375
+
renewBefore: 360h # 15d
376
+
377
+
renewal:
378
+
policy: RenewBefore
379
+
windows:
380
+
- cron: "0 2 * * 1-5"
381
+
timezone: America/Denver
382
+
windowDuration: 2h
383
+
```
384
+
385
+
In the above example, cert-manager calculates the certificate's normal renewal time using
386
+
renewBefore. Renewal is then attempted in the next matching renewal window.
387
+
388
+
#### How renewal windows work
389
+
390
+
cert-manager first calculates the certificate's renewal time in the usual way:
391
+
392
+
- by default, at 2/3 of the issued certificate's lifetime,
393
+
- or using `spec.renewBefore`,
394
+
- or using `spec.renewBeforePercentage`.
395
+
396
+
If `spec.renewal.windows` is configured, cert-manager will only renew the certificate during
397
+
one of the matching windows. Each window starts at the time matched by `cron` and remains open
398
+
for `windowDuration`.
399
+
400
+
If multiple windows are configured, renewal may happen in any matching window that occurs after
401
+
the calculated renewal time and before the certificate expires.
402
+
403
+
#### Disabling automatic renewal
404
+
405
+
To disable automatic renewal for a certificate, set `spec.renewal.policy` to `Disabled`.
406
+
407
+
> Note: Renewal windows do not replace `renewBefore` or `renewBeforePercentage`;
408
+
> they further restrict when renewal is allowed to happen.
409
+
> Care should be taken to ensure that there is at least one valid renewal window between the
410
+
> calculated renewal time and the certificate's expiry. If no valid window exists, cert-manager
411
+
> cannot calculate a renewal time and the Certificate status will report an error. However, the renewal
412
+
> will still happen at the calculated `desiredRenewalTime` using the `spec.renewBefore`/ `spec.renewBeforePercentage` fields.
413
+
> This behavior is intentional and is done to avoid certificates from expiring due to window misconfiguration.
0 commit comments