2025-01-15 16:08:35 +02:00
|
|
|
apiVersion: admissionregistration.k8s.io/v1
|
2024-04-22 21:49:25 +08:00
|
|
|
kind: ValidatingAdmissionPolicy
|
|
|
|
metadata:
|
|
|
|
name: "disallow-host-path"
|
|
|
|
spec:
|
|
|
|
matchConstraints:
|
|
|
|
resourceRules:
|
|
|
|
- apiGroups: [""]
|
|
|
|
apiVersions: ["v1"]
|
|
|
|
operations: ["CREATE", "UPDATE"]
|
|
|
|
resources: ["pods"]
|
|
|
|
matchConditions:
|
|
|
|
- expression: "object.metadata.labels['color'] == 'red'"
|
|
|
|
name: "red-label"
|
|
|
|
validations:
|
|
|
|
- expression: "!has(object.spec.volumes) || object.spec.volumes.all(volume, !has(volume.hostPath))"
|
|
|
|
message: "HostPath volumes are forbidden. The field spec.volumes[*].hostPath must be unset."
|