OCI images may optionally be built with VOLUME statements which, if run in read-only mode, would still result in write access to the specified location. This may be unexpected and undesirable. This policy checks the contents of every container image and inspects them for such VOLUME statements, then blocks if found.
apiVersion: policies.kyverno.io/v1alpha1kind: ValidatingPolicymetadata:name: block-images-with-volumesannotations:policies.kyverno.io/title: Block Images with Volumespolicies.kyverno.io/category: Otherpolicies.kyverno.io/severity: mediumpolicies.kyverno.io/minversion: 1.15.0policies.kyverno.io/subject: Podpolicies.kyverno.io/description: OCI images may optionally be built with VOLUME statements which, if run in read-only mode, would still result in write access to the specified location. This may be unexpected and undesirable. This policy checks the contents of every container image and inspects them for such VOLUME statements, then blocks if found.spec:evaluation:background:enabled: truevalidationActions:- Auditvariables:- name: allContainersexpression: object.spec.containers + object.spec.?initContainers.orValue([]) + object.spec.?ephemeralContainers.orValue([])matchConstraints:resourceRules:- resources:- podsoperations:- CREATE- UPDATEapiGroups:- ""apiVersions:- v1validations:- message: Images containing built-in volumes are prohibited.expression: variables.allContainers.all(container, !has(image.GetMetadata(container.image).config.Volumes) || size(image.GetMetadata(container.image).config.?Volumes.orValue({})) == 0)
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.