Skip to content

Commit

Permalink
Enforce our 7 day TTL on certificates
Browse files Browse the repository at this point in the history
Certificates must be issued for 7 days and start renewing 2/3rds of the
way through.
  • Loading branch information
rcrowe committed Oct 30, 2023
1 parent c9a7c8f commit 4bb8046
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
30 changes: 30 additions & 0 deletions bitnami/shared/kyverno/require-default-duration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-default-duration
annotations:
policies.kyverno.io/title: Require certificate duration to be set to 7days
policies.kyverno.io/category: cert-manager
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Certificate
policies.kyverno.io/description: >-
certificate requests should set the duration to 7days
spec:
validationFailureAction: Enforce
background: true
rules:
- name: require-certificate-default-duration
match:
resources:
kinds:
- Certificate
preconditions:
any:
- key: "{{ request.object.spec.issuerRef.name || '' }}"
operator: Equals
value: kafka-shared-selfsigned-issuer
validate:
message: "Duration must be set to 168h (7 days) as per our recommended best practices"
pattern:
spec:
duration: "168h"
30 changes: 30 additions & 0 deletions bitnami/shared/kyverno/require-default-renewbefore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-defaukt-renewbefore
annotations:
policies.kyverno.io/title: Require certificate renewBefore to be set to 2/3rds of duration
policies.kyverno.io/category: cert-manager
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: Certificate
policies.kyverno.io/description: >-
certificate requests should set renewBefore to 2/3rds of duration
spec:
validationFailureAction: Enforce
background: true
rules:
- name: require-certificate-default-renewbefore
match:
resources:
kinds:
- Certificate
preconditions:
any:
- key: "{{ request.object.spec.issuerRef.name || '' }}"
operator: Equals
value: kafka-shared-selfsigned-issuer
validate:
message: "renewBefore must be unset or set to 2/3 of duration, which is required to be 168hrs currently (7 days)"
pattern:
spec:
=(renewBefore): "112h"

0 comments on commit 4bb8046

Please sign in to comment.