An Ingress with no rules sends all traffic to a single default backend. The defaultBackend is conventionally a configuration option of the Ingress controller and is not specified in your Ingress resources. If none of the hosts or paths match the HTTP request in the Ingress objects, the traffic is routed to your default backend. In a multi-tenant environment, you want users to use explicit hosts, they should not be able to overwrite the global default backend service. This policy prohibits the use of the defaultBackend field.
apiVersion: policies.kyverno.io/v1alpha1kind: ValidatingPolicymetadata:name: restrict-ingress-defaultbackendannotations:policies.kyverno.io/title: Restrict Ingress defaultBackend in ValidatingPolicypolicies.kyverno.io/category: Best Practices in vpolpolicies.kyverno.io/severity: highkyverno.io/kyverno-version: 1.14.0policies.kyverno.io/minversion: 1.14.0kyverno.io/kubernetes-version: "1.30"policies.kyverno.io/subject: Ingresspolicies.kyverno.io/description: An Ingress with no rules sends all traffic to a single default backend. The defaultBackend is conventionally a configuration option of the Ingress controller and is not specified in your Ingress resources. If none of the hosts or paths match the HTTP request in the Ingress objects, the traffic is routed to your default backend. In a multi-tenant environment, you want users to use explicit hosts, they should not be able to overwrite the global default backend service. This policy prohibits the use of the defaultBackend field.spec:validationActions:- Auditevaluation:background:enabled: truematchConstraints:resourceRules:- apiGroups:- networking.k8s.ioapiVersions:- v1operations:- CREATE- UPDATEresources:- ingressesvalidations:- expression: "!has(object.spec.defaultBackend)"message: Setting the defaultBackend field is prohibited.
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.
This policy ensures that the name of the ApplicationSet is the same value provided in the project.