Created
September 17, 2019 12:58
-
-
Save cartyc/db0fe2cea80d0b5fa8075befb1e76375 to your computer and use it in GitHub Desktop.
OPA Gatekeeper Duplicate Ingress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: templates.gatekeeper.sh/v1alpha1 | |
kind: ConstraintTemplate | |
metadata: | |
name: ingressdupes | |
spec: | |
crd: | |
spec: | |
names: | |
kind: IngressDupe | |
listKind: IngressDupeList | |
plural: ingressdupes | |
singular: ingressdupes | |
targets: | |
- target: admission.k8s.gatekeeper.sh | |
rego: | | |
package kubernetes.admission | |
deny[{"msg":msg}] { | |
host := input.review.object.spec.rules[_].host | |
ingress := data.inventory.namespace[other_ns]["extensions"].Ingress[other_ingress] | |
other_ns != input.review.namespace | |
ingress.spec.rules[_].host == host | |
msg := sprintf("invalid ingress host <%q> (conflicts with <%v>/<%v>)", [host, other_ns, other_ingress]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment