Skip to content

Instantly share code, notes, and snippets.

@sbueringer
Last active January 11, 2019 18:25
Show Gist options
  • Save sbueringer/a5b755a6db50d0f52ea6a2c8f1998445 to your computer and use it in GitHub Desktop.
Save sbueringer/a5b755a6db50d0f52ea6a2c8f1998445 to your computer and use it in GitHub Desktop.
package authorization
import data.k8s.matches
deny[{
"id": "pods-kube-system",
"resource": {
"kind": kind,
"namespace": namespace,
"name": name,
},
"resolution": {"message": "Your're not allowed to create/update/delete pods in kube-system"},
}] {
matches[[kind, namespace, name, resource]]
not re_match("^(system:kube-controller-manager|system:kube-scheduler)$", resource.spec.user)
resource.spec.resourceAttributes.namespace = "kube-system"
resource.spec.resourceAttributes.resource = "pods"
re_match("^(create|update|delete|deletecollections)$", resource.spec.resourceAttributes.verb)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment