mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-09 17:37:12 +00:00
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com> Co-authored-by: Jim Bugwadia <jim@nirmata.com>
22 lines
501 B
YAML
22 lines
501 B
YAML
apiVersion: kyverno.io/v1
|
|
kind: ClusterPolicy
|
|
metadata:
|
|
name: max-containers
|
|
spec:
|
|
background: false
|
|
rules:
|
|
- name: max-two-containers
|
|
match:
|
|
any:
|
|
- resources:
|
|
kinds:
|
|
- Pod
|
|
validate:
|
|
failureAction: Enforce
|
|
message: "A maximum of 2 containers are allowed inside a Pod."
|
|
deny:
|
|
conditions:
|
|
any:
|
|
- key: "{{request.object.spec.containers[] | length(@)}}"
|
|
operator: GreaterThan
|
|
value: "2"
|