Skip to content

Commit 4bb8046

Browse files
committed
Enforce our 7 day TTL on certificates
Certificates must be issued for 7 days and start renewing 2/3rds of the way through.
1 parent c9a7c8f commit 4bb8046

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: kyverno.io/v1
2+
kind: ClusterPolicy
3+
metadata:
4+
name: require-default-duration
5+
annotations:
6+
policies.kyverno.io/title: Require certificate duration to be set to 7days
7+
policies.kyverno.io/category: cert-manager
8+
policies.kyverno.io/severity: medium
9+
policies.kyverno.io/subject: Certificate
10+
policies.kyverno.io/description: >-
11+
certificate requests should set the duration to 7days
12+
spec:
13+
validationFailureAction: Enforce
14+
background: true
15+
rules:
16+
- name: require-certificate-default-duration
17+
match:
18+
resources:
19+
kinds:
20+
- Certificate
21+
preconditions:
22+
any:
23+
- key: "{{ request.object.spec.issuerRef.name || '' }}"
24+
operator: Equals
25+
value: kafka-shared-selfsigned-issuer
26+
validate:
27+
message: "Duration must be set to 168h (7 days) as per our recommended best practices"
28+
pattern:
29+
spec:
30+
duration: "168h"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: kyverno.io/v1
2+
kind: ClusterPolicy
3+
metadata:
4+
name: require-defaukt-renewbefore
5+
annotations:
6+
policies.kyverno.io/title: Require certificate renewBefore to be set to 2/3rds of duration
7+
policies.kyverno.io/category: cert-manager
8+
policies.kyverno.io/severity: medium
9+
policies.kyverno.io/subject: Certificate
10+
policies.kyverno.io/description: >-
11+
certificate requests should set renewBefore to 2/3rds of duration
12+
spec:
13+
validationFailureAction: Enforce
14+
background: true
15+
rules:
16+
- name: require-certificate-default-renewbefore
17+
match:
18+
resources:
19+
kinds:
20+
- Certificate
21+
preconditions:
22+
any:
23+
- key: "{{ request.object.spec.issuerRef.name || '' }}"
24+
operator: Equals
25+
value: kafka-shared-selfsigned-issuer
26+
validate:
27+
message: "renewBefore must be unset or set to 2/3 of duration, which is required to be 168hrs currently (7 days)"
28+
pattern:
29+
spec:
30+
=(renewBefore): "112h"

0 commit comments

Comments
 (0)