-
-
Save developer-guy/9b5bf6b3b7e2ceca771c8a9d347a3b11 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