Pods can have many different containers which are tightly coupled. It may be desirable to limit the amount of containers that can be in a single Pod to control best practice application or so policy can be applied consistently. This policy checks all Pods to ensure they have no more than four containers.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: limit-containers-per-podannotations:policies.kyverno.io/title: Limit Containers per Pod in CEL expressionspolicies.kyverno.io/category: Sample in CELpolicies.kyverno.io/minversion: 1.11.0kyverno.io/kubernetes-version: 1.26-1.27policies.kyverno.io/subject: Podpolicies.kyverno.io/description: Pods can have many different containers which are tightly coupled. It may be desirable to limit the amount of containers that can be in a single Pod to control best practice application or so policy can be applied consistently. This policy checks all Pods to ensure they have no more than four containers.spec:validationFailureAction: Auditbackground: falserules:- name: limit-containers-per-podmatch:any:- resources:kinds:- Podoperations:- CREATE- UPDATEvalidate:cel:expressions:- expression: size(object.spec.containers) <= 4message: Pods can only have a maximum of 4 containers.
This policy performs some best practices validation on Application fields. Path or chart must be specified but never both. And destination.name or destination.server must be specified but never both.
This policy prevents the use of the default project in an Application.
This policy prevents updates to the project field after an Application is created.