All Policies

Enforce Consul min TLS version in CEL expressions

This policy will check the TLS Min version to ensure that whenever the mesh is set, there is a minimum version of TLS set for all the service mesh proxies and this enforces that service mesh mTLS traffic uses TLS v1.2 or newer.

Policy Definition

/consul-cel/enforce-min-tls-version/enforce-min-tls-version.yaml

 1apiVersion: kyverno.io/v1
 2kind: ClusterPolicy
 3metadata:
 4  name: enforce-min-tls-version
 5  annotations:
 6    policies.kyverno.io/title: Enforce Consul min TLS version  in CEL expressions
 7    policies.kyverno.io/category: Consul in CEL 
 8    policies.kyverno.io/severity: medium
 9    policies.kyverno.io/subject: Mesh
10    kyverno.io/kyverno-version: 1.11.0
11    policies.kyverno.io/minversion: 1.11.0
12    kyverno.io/kubernetes-version: "1.26-1.27"
13    policies.kyverno.io/description: >-
14      This policy will check the TLS Min version to ensure that whenever the mesh is set, there is a minimum version of TLS set for all the service mesh proxies and this enforces that service mesh mTLS traffic uses TLS v1.2 or newer.
15spec:
16  validationFailureAction: Enforce
17  background: true
18  rules:
19  - name: check-for-tls-version
20    match:
21      any:
22      - resources:
23          kinds:
24            - Mesh
25          operations:
26            - CREATE
27            - UPDATE
28    validate:
29      cel:
30        expressions:
31          - expression: >-
32              object.?spec.?tls.?incoming.?tlsMinVersion.orValue('') == 'TLSv1_2'
33            message: The minimum version of TLS is TLS v1_2