2023-09-17 22:24:26 +00:00
|
|
|
---
|
2020-11-18 22:58:32 +00:00
|
|
|
apiVersion: kyverno.io/v1
|
|
|
|
kind: ClusterPolicy
|
|
|
|
metadata:
|
|
|
|
name: secrets-not-from-env-vars
|
|
|
|
spec:
|
2023-09-17 22:24:26 +00:00
|
|
|
admission: true
|
2020-11-18 22:58:32 +00:00
|
|
|
background: false
|
|
|
|
rules:
|
2023-09-17 22:24:26 +00:00
|
|
|
- match:
|
|
|
|
any:
|
|
|
|
- resources:
|
|
|
|
kinds:
|
|
|
|
- Pod
|
|
|
|
name: secrets-not-from-env-vars
|
2020-11-18 22:58:32 +00:00
|
|
|
validate:
|
2023-09-17 22:24:26 +00:00
|
|
|
message: Secrets must be mounted as volumes, not as environment variables.
|
2020-11-18 22:58:32 +00:00
|
|
|
pattern:
|
|
|
|
spec:
|
|
|
|
containers:
|
2023-09-17 22:24:26 +00:00
|
|
|
- =(env):
|
2020-11-18 22:58:32 +00:00
|
|
|
- =(valueFrom):
|
2023-09-17 22:24:26 +00:00
|
|
|
X(secretKeyRef): "null"
|
|
|
|
name: '*'
|
|
|
|
validationFailureAction: Audit
|