All Policies
Restrict Volume Types in CEL
In addition to restricting HostPath volumes, the restricted pod security profile limits usage of non-core volume types to those defined through PersistentVolumes. This policy blocks any other type of volume other than those in the allow list.
Policy Definition
/pod-security-cel/restricted/restrict-volume-types/restrict-volume-types.yaml
1apiVersion: kyverno.io/v1
2kind: ClusterPolicy
3metadata:
4 name: restrict-volume-types
5 annotations:
6 policies.kyverno.io/title: Restrict Volume Types in CEL
7 policies.kyverno.io/category: Pod Security Standards (Restricted) in CEL
8 policies.kyverno.io/severity: medium
9 policies.kyverno.io/subject: Pod,Volume
10 policies.kyverno.io/minversion: 1.11.0
11 kyverno.io/kubernetes-version: "1.26-1.27"
12 kyverno.io/kyverno-version: 1.11.0
13 policies.kyverno.io/description: >-
14 In addition to restricting HostPath volumes, the restricted pod security profile
15 limits usage of non-core volume types to those defined through PersistentVolumes.
16 This policy blocks any other type of volume other than those in the allow list.
17spec:
18 validationFailureAction: Audit
19 background: true
20 rules:
21 - name: restricted-volumes
22 match:
23 any:
24 - resources:
25 kinds:
26 - Pod
27 validate:
28 cel:
29 expressions:
30 - expression: >-
31 !has(object.spec.volumes) ||
32 object.spec.volumes.all(vol, has(vol.configMap) ||
33 has(vol.csi) ||
34 has(vol.downwardAPI) ||
35 has(vol.emptyDir) ||
36 has(vol.ephemeral) ||
37 has(vol.persistentVolumeClaim) ||
38 has(vol.projected) ||
39 has(vol.secret))
40 message: >-
41 Only the following types of volumes may be used: configMap, csi, downwardAPI,
42 emptyDir, ephemeral, persistentVolumeClaim, projected, and secret.