Created
June 28, 2020 06:33
-
-
Save velotiotech/a803bbbea60524e7b7a8c3a117b4cbe9 to your computer and use it in GitHub Desktop.
Constraint Template to deny service of type LoadBalancer
This file contains hidden or 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/v1beta1 | |
kind: ConstraintTemplate | |
metadata: | |
name: lbtypesvcnotallowed | |
spec: | |
crd: | |
spec: | |
names: | |
kind: LBTypeSvcNotAllowed | |
listKind: LBTypeSvcNotAllowedList | |
plural: lbtypesvcnotallowed | |
singular: lbtypesvcnotallowed | |
targets: | |
- target: admission.k8s.gatekeeper.sh | |
rego: | | |
package kubernetes.admission | |
violation[{"msg": msg}] { | |
input.review.kind.kind = "Service" | |
input.review.operation = "CREATE" | |
input.review.object.spec.type = "LoadBalancer" | |
msg := "LoadBalancer Services are not permitted" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment