An Route host is a URL at which services may be made available externally. In most cases, these hosts should be unique across the cluster to ensure no routing conflicts occur. This policy checks an incoming Route resource to ensure its hosts are unique to the cluster.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: unique-routesannotations:policies.kyverno.io/title: Require unique host names in OpenShift routespolicies.kyverno.io/category: OpenShiftpolicies.kyverno.io/severity: highkyverno.io/kyverno-version: 1.6.0policies.kyverno.io/minversion: 1.6.0kyverno.io/kubernetes-version: "1.20"policies.kyverno.io/subject: Routepolicies.kyverno.io/description: An Route host is a URL at which services may be made available externally. In most cases, these hosts should be unique across the cluster to ensure no routing conflicts occur. This policy checks an incoming Route resource to ensure its hosts are unique to the cluster.spec:validationFailureAction: Enforcebackground: falserules:- name: require-unique-routesmatch:any:- resources:kinds:- route.openshift.io/v1/Routecontext:- name: hostsapiCall:urlPath: /apis/route.openshift.io/v1/RoutesjmesPath: items[].spec.hostpreconditions:all:- key: "{{ request.operation || 'BACKGROUND' }}"operator: NotEqualsvalue: DELETEvalidate:message: The Route host name must be unique.deny:conditions:all:- key: "{{ request.object.spec.host }}"operator: AnyInvalue: "{{ hosts }}"
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.