-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Description
This policy restricts the usage of specific StorageClasses by Kubernetes resources.
Currently, the policy enforces checks at the PersistentVolumeClaim (PVC) level — PVCs using forbidden StorageClasses are rejected.
Unlike persistentvolumeclaim-storageclass-policy just prevent the pvc dreatehion, this policy should enforce at the workload level (e.g., rejecting a Deployment if any of its PVCs reference a forbidden StorageClass), similar to what NeuVector supports.
Restricting which StorageClasses can be used is useful in scenarios such as limiting workloads to a trusted storage provider or preventing the use of unsupported classes.
Configuration
You must configure either deniedStorageClasses or allowedStorageClasses (but not both).
# A list of storage classes that are forbidden.
# This setting is mutually exclusive with allowedStorageClasses.
deniedStorageClasses:
- fast
- nvme
# A list of storage classes that are permitted.
# This setting is mutually exclusive with deniedStorageClasses.
allowedStorageClasses:
- standard
- slowExamples
❌ Denied Example
Configuration
deniedStorageClasses:
- fast
- nvmePersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-fast
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: fast # forbidden StorageClassDeployment using this PVC
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-using-fast
spec:
replicas: 1
selector:
matchLabels:
app: test
template:
metadata:
labels:
app: test
spec:
containers:
- name: busybox
image: busybox
command: ["sleep", "3600"]
volumeMounts:
- name: data
mountPath: /data
volumes:
- name: data
persistentVolumeClaim:
claimName: pvc-fast👉 Result: This Deployment will be denied, because it references pvc-fast, which is bound to a forbidden StorageClass (fast).
✅ Allowed Example
Configuration
allowedStorageClasses:
- standard
- slowPersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-standard
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: standard # explicitly allowedDeployment using this PVC
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-using-standard
spec:
replicas: 1
selector:
matchLabels:
app: test
template:
metadata:
labels:
app: test
spec:
containers:
- name: busybox
image: busybox
command: ["sleep", "3600"]
volumeMounts:
- name: data
mountPath: /data
volumes:
- name: data
persistentVolumeClaim:
claimName: pvc-standard👉 Result: This Deployment will be accepted, because it references pvc-standard, which is bound to an allowed StorageClass (standard).
Metadata
Metadata
Assignees
Type
Projects
Status