Just like the need to ensure uniqueness among Ingress hosts, there is a need to have the paths be unique as well. This policy checks an incoming Ingress to ensure its root path does not conflict with another root path in a different Namespace. It requires that incoming Ingress resources have a single rule with a single path only and assumes the root path is specified explicitly in an existing Ingress rule (ex., when blocking /foo/bar /foo must exist by itself and not part of /foo/baz).
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: unique-ingress-pathannotations:policies.kyverno.io/title: Unique Ingress Pathpolicies.kyverno.io/category: Samplepolicies.kyverno.io/severity: mediumpolicies.kyverno.io/subject: Ingresspolicies.kyverno.io/minversion: 1.6.0policies.kyverno.io/description: Just like the need to ensure uniqueness among Ingress hosts, there is a need to have the paths be unique as well. This policy checks an incoming Ingress to ensure its root path does not conflict with another root path in a different Namespace. It requires that incoming Ingress resources have a single rule with a single path only and assumes the root path is specified explicitly in an existing Ingress rule (ex., when blocking /foo/bar /foo must exist by itself and not part of /foo/baz).spec:validationFailureAction: Auditbackground: falserules:- name: check-pathmatch:any:- resources:kinds:- Ingresscontext:- name: allpathsapiCall:urlPath: /apis/networking.k8s.io/v1/ingressesjmesPath: items[].spec.rules[].http.paths[].path- name: nspathapiCall:urlPath: /apis/networking.k8s.io/v1/namespaces/{{request.object.metadata.namespace}}/ingressesjmesPath: items[].spec.rules[].http.paths[].pathpreconditions:any:- key: "{{request.operation || 'BACKGROUND'}}"operator: AnyInvalue:- CREATE- UPDATEvalidate:message: The root path /{{request.object.spec.rules[].http.paths[].path | [0] | to_string(@) | split(@, '/') | [1]}} exists in another Ingress rule elsewhere in the cluster.deny:conditions:all:- key: /{{request.object.spec.rules[].http.paths[].path | [0] | to_string(@) | split(@, '/') | [1]}}operator: AnyInvalue: "{{allpaths}}"- key: /{{request.object.spec.rules[].http.paths[].path | [0] | to_string(@) | split(@, '/') | [1]}}operator: AnyNotInvalue: "{{nspath}}"
This policy prevents the use of the default project in an Application.
Services of type LoadBalancer when deployed inside AWS have support for transport encryption if it is enabled via an annotation. This policy requires that Services of type LoadBalancer contain the annotation service.beta.kubernetes.io/aws-load-balancer-ssl-cert with some value.
This policy prevents updates to the project field after an Application is created.