Disallow Service Type LoadBalancer

Sample policy to restrict use of Service type LoadBalancer.

Policy Definition

/other/restrict_loadbalancer.yaml

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: no-loadbalancer-service
  annotations:
    policies.kyverno.io/title: Disallow Service Type LoadBalancer
    policies.kyverno.io/category: Sample 
    policies.kyverno.io/description: >-
      Sample policy to restrict use of Service type LoadBalancer.
spec:
  validationFailureAction: audit
  rules:
  - name: no-LoadBalancer
    match:
      resources:
        kinds:
        - Service
    validate:
      message: "Service of type LoadBalancer is not allowed."
      pattern:
        spec:
          type: "!LoadBalancer"
Last modified January 2, 2021: fix title & sort and regen policies (fa7e171)