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.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: restrict-volume-typesannotations:policies.kyverno.io/title: Restrict Volume Typespolicies.kyverno.io/category: Pod Security Standards (Restricted)policies.kyverno.io/severity: mediumpolicies.kyverno.io/subject: Pod,Volumepolicies.kyverno.io/minversion: 1.6.0kyverno.io/kubernetes-version: 1.22-1.23kyverno.io/kyverno-version: 1.6.0policies.kyverno.io/description: 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.spec:validationFailureAction: Auditbackground: truerules:- name: restricted-volumesmatch:any:- resources:kinds:- Podpreconditions:all:- key: "{{ request.operation || 'BACKGROUND' }}"operator: NotEqualsvalue: DELETEvalidate:message: "Only the following types of volumes may be used: configMap, csi, downwardAPI, emptyDir, ephemeral, persistentVolumeClaim, projected, and secret."deny:conditions:all:- key: "{{ request.object.spec.volumes[].keys(@)[] || '' }}"operator: AnyNotInvalue:- name- configMap- csi- downwardAPI- emptyDir- ephemeral- persistentVolumeClaim- projected- secret- ""
This policy performs some best practices validation on Application fields. Path or chart must be specified but never both. And destination.name or destination.server must be specified but never both.
This policy prevents the use of the default project in an Application.
This policy prevents updates to the project field after an Application is created.