kubewarden / volumeMounts-policy

A Kubewarden Policy that controls the usage of `volumeMounts`
https://kubewarden.io
Apache License 2.0
2 stars 4 forks source link
hacktoberfest kubernetes kubernetes-security kubewarden-policy policy-as-code webassembly

Kubewarden Policy Repository Stable

Kubewarden policy volumemounts-policy

Description

Policy that inspects containers, init containers, and ephemeral containers, and restricts their usage of volumes by checking the volume name being used in volumeMounts[*].name.

The policy can either target Pods, or workload resources (Deployments, ReplicaSets, DaemonSets, ReplicationControllers, Jobs, CronJobs) by setting the policy's spec.rules accordingly.

Both have trade-offs:

Settings

reject: anyIn # one of anyIn (default, denylist), anyNotIn (allowlist), allAreUsed, notAllAreUsed
volumeMountsNames:  # list of volumeMounts.name to match using the defined reject operator
  - foo
  - bar
  - baz

Examples

# denylist, reject volumeMounts named `my-volume` or `my-volume2`
reject: anyIn
volumeMountsNames:
  - my-volume
  - my-volume2
# allowlist, only allow volumeMounts named `my-volume3` or `my-volume4`
reject: anyNotIn
volumeMountsNames:
  - my-volume3
  - my-volume4
# container cannot use both volumes at once, only one or the other
reject: allAreUsed
volumeMountsNames:
  - my-volume5
  - my-volume6
# container can use both volumes at once, but not only one of them
reject: notAllAreUsed
volumeMountsNames:
  - my-volume5
  - my-volume6