mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-06 16:06:56 +00:00
23 lines
507 B
YAML
23 lines
507 B
YAML
|
apiVersion: kyverno.io/v1
|
||
|
kind: ClusterPolicy
|
||
|
metadata:
|
||
|
name: max-containers
|
||
|
spec:
|
||
|
validationFailureAction: Enforce
|
||
|
background: false
|
||
|
rules:
|
||
|
- name: max-two-containers
|
||
|
match:
|
||
|
any:
|
||
|
- resources:
|
||
|
kinds:
|
||
|
- Pod
|
||
|
validate:
|
||
|
message: "A maximum of 2 containers are allowed inside a Pod."
|
||
|
deny:
|
||
|
conditions:
|
||
|
any:
|
||
|
- key: "{{request.object.spec.containers[] | length(@)}}"
|
||
|
operator: GreaterThan
|
||
|
value: "2"
|