# Note: this policy uses the operator "AnyIn", which was introduced in Kyverno 1.6.
# (This policy won't work with Kyverno 1.5!)
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: ingress-domain-name
spec:
  rules:
  - name: create-ingress
    match:
      resources: 
        kinds:
        - Service
    preconditions:
      - key: "{{request.object.spec.ports[*].port}}"
        operator: AnyIn
        value: [ 80 ]
    generate: 
      kind: Ingress
      name: "{{request.object.metadata.name}}"
      namespace: "{{request.object.metadata.namespace}}"
      data:
        spec:
          rules:
          - host: "{{request.object.metadata.name}}.{{request.object.metadata.namespace}}.A.B.C.D.nip.io"
            http:
              paths:
              - backend:
                  service:
                    name: "{{request.object.metadata.name}}"
                    port:
                      name: http
                path: /
                pathType: Prefix
