Skip to content

Instantly share code, notes, and snippets.

View tsandall's full-sized avatar

Torin Warwick (Sandall) tsandall

  • Apple
View GitHub Profile
- $KUBE_SRC below refers to the path of the kubernetes source code
- commit 1cce15659750d90064882738425115ec547c1634
- build using $KUBE_SRC/hack/build-go
- output is stored in $KUBE_SRC/_output/...
- kubemark:latest image is built by running "docker build -t kubemark:latest ." inside $KUBE_SRC/cluster/images/kubemark
- need to copy kubemark binary into $KUBE_SRC/cluster/images/kubemark
- hollow-node.json is taken from template in $KUBE_SRC/test/kubemark/resources/
@tsandall
tsandall / httpapi_authz.rego
Last active May 12, 2017 17:05
Authorization Examples
package httpapi.authz
default allow = false
# Allow users to get their own salaries.
allow {
input.method = "GET"
input.path = ["finance", "salary", user]
user = input.user
}
package httpapi.authz
manager_of[employee] = manager {
data.employees[employee].team = team_id
data.teams[team_id].lead = manager 
}
package ssh.authz
default allow = false
# Allow access to any user that has the "admin" role.
allow {
data.roles["admin"][_] = input.user
}
# Allow access to any user who contributed to the code running on the host.
package sudo.authz
default allow = false
# Allow sudo access to any user that has the "admin" role.
allow {
data.roles["admin"][_] = input.user
}
package puppet.authz
default allow = false
allow { not deny }
deny {
resource = catalog.resources[resource_index]
resource.type = "File"
startswith(resource.title, "/etc/infra")
# Example authorization policy for kubernetes.
#
# Configure kube-apiserver with the following command line arguments:
#
# --authorization-mode=Webhook
# --authorization-webhook-config-file=<path-to-kubeconfig-file>
#
# The kubeconfig file must locate OPA. For example:
#
# clusters:
package acmecorp.api
import data.acmecorp.roles
default allow = false
allow {
input.method = “GET”
input.path = [“accounts”, user]
input.user = user
@tsandall
tsandall / risk
Last active February 5, 2018 18:40
Examples for Partial Evaluation post on blog.openpolicyagent.org
allow {
risk_score = (input.num_deletes * 10) + input.num_adds
risk_score < risk_limit[input.user.title]
}