Torin Sandall
@sometorin
openpolicyagent.org
Enforcing Bespoke Policies in
Kubernetes
openpolicyagent.org@sometorin
Overview
● Background: What Is Policy?
● Example Scenario
● Admission Control
● Open Policy Agent
openpolicyagent.org@sometorin
What Is Policy?
openpolicyagent.org@sometorin
What Is Policy?
● Policies are vital to every organization
○ Policies are required across the stack
○ Policies are organization-specific
○ Policies change frequently over time
openpolicyagent.org@sometorin
What Is Policy?
● Policies are vital to every organization
○ Policies are required across the stack
○ Policies are organization-specific
○ Policies change frequently over time
● Policy enforcement methods vary wildly
○ Weak guarantees from tribal knowledge & wikis
○ High cost from hard-coded policy decisions
openpolicyagent.org@sometorin
What Is Policy?
● Policies are vital to every organization
○ Policies are required across the stack
○ Policies are organization-specific
○ Policies change frequently over time
● Policy enforcement methods vary wildly
○ Weak guarantees from tribal knowledge & wikis
○ High cost from hard-coded policy decisions
● Existing solutions lack expressiveness
○ Logic and data
○ Decisions
○ Composition
openpolicyagent.org
Example Scenario
Alice
Platform Engineer
Bob
App Engineer
● Alice and Bob work for AcmeCorp
openpolicyagent.org
Example Scenario
Alice
Platform Engineer
Bob
App Engineer
● Alice and Bob work for AcmeCorp
● Bob needs shell access to containers
running on Kubernetes
openpolicyagent.org
Example Scenario
Alice
Platform Engineer
Bob
App Engineer
● Alice and Bob work for AcmeCorp
● Bob needs shell access to containers
running on Kubernetes
● Bob cannot be trusted with access to
privileged containers running in the
production namespace
openpolicyagent.org@sometorin
Kubernetes Extensibility
Dynamic Admission Control
Custom Resource Definitions (CRDs)
API Aggregation
Multi-scheduler
Operators (Pattern)
Image Webhook
Token Authenticator
Webhook
Authorizer Hook
1.3 1.4 1.5 1.7<1.3 1.9
MutatingWebhook
(+beta)
openpolicyagent.org@sometorin
Admission Control
etcd
Kubernetes API Server
Authentication Authorization
Admission
Control
openpolicyagent.org@sometorin
Admission Control
etcd
Kubernetes API Server
Admission Control
Resource
Quota
Service
Accounts
Authentication Authorization
Resource
Management
Security
openpolicyagent.org@sometorin
Admission Control
etcd
Kubernetes API Server
Admission Control
Resource
Quota
Service
Accounts
Authentication Authorization
Resource
Management
Security
openpolicyagent.org@sometorin
● Static compilation & configuration
○ 30+ admission controllers
○ 1-4 added per release
○ Command line arguments
○ Static configuration files
admit
deny
exec
limitranger
namespace
resourcequota
securitycontext
serviceaccount
initialresources
alwayspullimages
antiaffinity
persistentvolume
security
imagepolicy
storageclass
gc
podnodeselector
defaulttolerationseconds
podpreset
initialization
noderestriction
podtolerationrestriction
schedulingpolicy
image/imagelimitrangerplugin
image/imagepolicyplugin
ingress/ingress
project/lifecycle
project/podnodeenvironment
project/projectrequestlimit
quota/quotaclusterresourceoverride
quota/clusterquota
quota/runonceduration
scheduler/podnodeconstraints
security/constraint
Admission Control: Before 1.7
openpolicyagent.org@sometorin
● Static compilation & configuration
○ 30+ admission controllers
○ 1-4 added per release
○ Command line arguments
○ Static configuration files
● Example Scenario
○ Alice forks Kubernetes into a private repository
○ Alice implements the policy inside the plugin framework
○ Alice now has to build, push, and upgrade Kubernetes itself
Admission Control: Before 1.7 admit
deny
exec
limitranger
namespace
resourcequota
securitycontext
serviceaccount
initialresources
alwayspullimages
antiaffinity
persistentvolume
security
imagepolicy
storageclass
gc
podnodeselector
defaulttolerationseconds
podpreset
initialization
noderestriction
podtolerationrestriction
schedulingpolicy
image/imagelimitrangerplugin
image/imagepolicyplugin
ingress/ingress
project/lifecycle
bobprotectionpolicy
project/podnodeenvironment
project/projectrequestlimit
quota/quotaclusterresourceoverride
quota/clusterquota
quota/runonceduration
scheduler/podnodeconstraints
security/constraint
openpolicyagent.org@sometorin
Admission Control: Webhooks
● Admission controllers can be implemented as
webhooks that run on top of Kubernetes
● Webhooks can allow or deny incoming requests
○ Before etcd is updated
○ Before clients are notified
● Webhooks are configured dynamically via
Kubernetes APIs
Kubernetes API Server
Admission Control
External
Admission
Webhooks
openpolicyagent.org@sometorin
Admission Control: Webhooks
● The API Server calls webhooks whose
configuration rules match the incoming
request:
match [
{operations: [“create”], kinds: [“pods”]},
{operations: [“delete”], kinds: [“services”]}
]
● Rules can include wildcards:
match [
{operations: [“*”], kinds: [“*”]}
]
Kubernetes API Server
Admission Control
External
Admission
Webhooks
openpolicyagent.org@sometorin
Admission Control: Webhooks
● The API Server provides the operation, entire
object, and user info in the webhook call
kind: AdmissionReview
spec:
kind: {kind: Pod, version: v1}
name: admission-webhook-demo-373699553-8srx8
namespace: default
object:
Options:
Command: [sh]
Container: admission-webhook-demo
...
ResourcePath: pods/exec
operation: CONNECT
userInfo:
groups: ['system:masters', 'system:authenticated']
username: minikube
Kubernetes API Server
Admission Control
External
Admission
Webhooks
$ kubectl exec
openpolicyagent.org@sometorin
Admission Control: Webhooks
● Webhooks respond with an AdmissionReview
that indicates whether to allow or deny the
request
kind: AdmissionReview
status:
allowed: false
reason:
message: “nice try bob -alice”
● The API Server rejects the request IF ANY of
the webhooks return a denial
Kubernetes API Server
Admission Control
External
Admission
Webhooks
$ kubectl exec
error: nice try bob -alice
openpolicyagent.org@sometorin
Demo
openpolicyagent.org@sometorin
● Be careful with webhook dependencies!
○ Consider performance and availability
○ Avoid side effects
Webhooks: Lessons Learned
openpolicyagent.org@sometorin
● Be careful with webhook dependencies!
○ Consider performance and availability
○ Avoid side effects
● API server sends “internal representation” of Kubernetes objects over the wire
Webhooks: Lessons Learned
openpolicyagent.org@sometorin
● Be careful with webhook dependencies!
○ Consider performance and availability
○ Avoid side effects
● API server sends “internal representation” of Kubernetes objects over the wire
● API server “fails open” if webhook fails (configurable in 1.9)
Webhooks: Lessons Learned
openpolicyagent.org@sometorin
● Be careful with webhook dependencies!
○ Consider performance and availability
○ Avoid side effects
● API server sends “internal representation” of Kubernetes objects over the wire
● API server “fails open” if webhook fails (configurable in 1.9)
● Must serve POST requests at https://<ip>:<port>/ (paths supported in 1.9)
Webhooks: Lessons Learned
openpolicyagent.org@sometorin
● Be careful with webhook dependencies!
○ Consider performance and availability
○ Avoid side effects
● API server sends “internal representation” of Kubernetes objects over the wire
● API server “fails open” if webhook fails (configurable in 1.9)
● Must serve POST requests at https://<ip>:<port>/ (paths supported in 1.9)
● Client-go vendoring has improved significantly
Webhooks: Lessons Learned
openpolicyagent.org@sometorin
Webhooks...all the way down?
● Webhooks (and initializers) lay the groundwork for
extensible policy enforcement
openpolicyagent.org@sometorin
Webhooks...all the way down?
● Webhooks (and initializers) lay the groundwork for
extensible policy enforcement
● Policy decisions have been decoupled from
enforcement
openpolicyagent.org@sometorin
Webhooks...all the way down?
● Webhooks (and initializers) lay the groundwork for
extensible policy enforcement
● Policy decisions have been decoupled from
enforcement
● Is there a better way to author policies that control
who can do what?
openpolicyagent.org@sometorin
apiVersion: v1
kind: Pod
metadata:
labels:
app: nginx
name: nginx-1493591563-bvl8q
namespace: production
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
securityContext:
privileged: true
dnsPolicy: ClusterFirst
nodeName: minikube
restartPolicy: Always
status:
containerStatuses:
- name: nginx
ready: true
restartCount: 0
state:
running:
startedAt: 2017-08-01T06:34:22Z
hostIP: 192.168.99.100
phase: Running
podIP: 172.17.0.4
startTime: 2017-08-01T06:34:13Z
openpolicyagent.org@sometorin
apiVersion: v1
kind: Pod
metadata:
labels:
app: nginx
name: nginx-1493591563-bvl8q
namespace: production
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
securityContext:
privileged: true
dnsPolicy: ClusterFirst
nodeName: minikube
restartPolicy: Always
status:
containerStatuses:
- name: nginx
ready: true
restartCount: 0
state:
running:
startedAt: 2017-08-01T06:34:22Z
hostIP: 192.168.99.100
phase: Running
podIP: 172.17.0.4
startTime: 2017-08-01T06:34:13Z
# references
spec.containers[0].image
openpolicyagent.org@sometorin
apiVersion: v1
kind: Pod
metadata:
labels:
app: nginx
name: nginx-1493591563-bvl8q
namespace: production
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
securityContext:
privileged: true
dnsPolicy: ClusterFirst
nodeName: minikube
restartPolicy: Always
status:
containerStatuses:
- name: nginx
ready: true
restartCount: 0
state:
running:
startedAt: 2017-08-01T06:34:22Z
hostIP: 192.168.99.100
phase: Running
podIP: 172.17.0.4
startTime: 2017-08-01T06:34:13Z
# references
spec.containers[0].image
# variables and iteration
container = spec.containers[_]
openpolicyagent.org@sometorin
apiVersion: v1
kind: Pod
metadata:
labels:
app: nginx
name: nginx-1493591563-bvl8q
namespace: production
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
securityContext:
privileged: true
dnsPolicy: ClusterFirst
nodeName: minikube
restartPolicy: Always
status:
containerStatuses:
- name: nginx
ready: true
restartCount: 0
state:
running:
startedAt: 2017-08-01T06:34:22Z
hostIP: 192.168.99.100
phase: Running
podIP: 172.17.0.4
startTime: 2017-08-01T06:34:13Z
# references
spec.containers[0].image
# variables and iteration
container = spec.containers[_]
# expressions
container.securityContext.privileged = true
openpolicyagent.org@sometorin
apiVersion: v1
kind: Pod
metadata:
labels:
app: nginx
name: nginx-1493591563-bvl8q
namespace: production
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
securityContext:
privileged: true
dnsPolicy: ClusterFirst
nodeName: minikube
restartPolicy: Always
status:
containerStatuses:
- name: nginx
ready: true
restartCount: 0
state:
running:
startedAt: 2017-08-01T06:34:22Z
hostIP: 192.168.99.100
phase: Running
podIP: 172.17.0.4
startTime: 2017-08-01T06:34:13Z
# references
spec.containers[0].image
# variables and iteration
container = spec.containers[_]
# expressions
container.securityContext.privileged = true
# functions
is_privileged(container) {
container.securityContext.privileged = true
}
openpolicyagent.org@sometorin
apiVersion: v1
kind: Pod
metadata:
labels:
app: nginx
name: nginx-1493591563-bvl8q
namespace: production
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
securityContext:
privileged: true
dnsPolicy: ClusterFirst
nodeName: minikube
restartPolicy: Always
status:
containerStatuses:
- name: nginx
ready: true
restartCount: 0
state:
running:
startedAt: 2017-08-01T06:34:22Z
hostIP: 192.168.99.100
phase: Running
podIP: 172.17.0.4
startTime: 2017-08-01T06:34:13Z
# references
spec.containers[0].image
# variables and iteration
container = spec.containers[_]
# expressions
container.securityContext.privileged = true
# functions
is_privileged(container) {
container.securityContext.privileged = true
}
# rules
deny {
review.user = “bob”
review.operation = “CONNECT”
review.namespace = “production”
is_privileged(spec.containers[_])
}
openpolicyagent.org@sometorin
OPA is an open source, general-purpose policy engine
Policy
Query
Policy
Decision
openpolicyagent.org@sometorin
OPA is an open source, general-purpose policy engine
Policy
Query
Policy
Decision
● Declarative Language (Rego)
○ Is X allowed to call operation Y on resource Z?
○ What clusters should workload X be deployed to?
○ What annotations must be present on object X?
openpolicyagent.org@sometorin
OPA is an open source, general-purpose policy engine
Policy
Query
Policy
Decision
● Declarative Language (Rego)
○ Is X allowed to call operation Y on resource Z?
○ What clusters should workload X be deployed to?
○ What annotations must be present on object X?
● Library/Daemon (Go)
○ In-memory, zero runtime dependencies
○ Evaluation engine: parser, compiler, interpreter
○ Tooling: REPL, test runner, tracing
openpolicyagent.org@sometorin
OPA is an open source, general-purpose policy engine
Policy
Query
Policy
Decision
● Declarative Language (Rego)
○ Is X allowed to call operation Y on resource Z?
○ What clusters should workload X be deployed to?
○ What annotations must be present on object X?
● Library/Daemon (Go)
○ In-memory, zero runtime dependencies
○ Evaluation engine: parser, compiler, interpreter
○ Tooling: REPL, test runner, tracing
● Growing community
○ Sponsored by Styra and Google/Firebase
○ Used by Netflix, Medallia, Huawei, Schuberg Philis, and more
○ Integrations for Istio, Kubernetes, Terraform, PAM, AWS, and more
openpolicyagent.org@sometorin
Demo
openpolicyagent.org@sometorin
Istio
Hashicorp
Terraform
github.com/open-policy-agent/library
Contributions welcome.
Standard Library
openpolicyagent.org@sometorin
github.com/open-policy-agent/opa
tsandall/admission-webhook-demo
slack.openpolicyagent.org
Thank you!

Enforcing Bespoke Policies in Kubernetes

  • 1.
  • 2.
    openpolicyagent.org@sometorin Overview ● Background: WhatIs Policy? ● Example Scenario ● Admission Control ● Open Policy Agent
  • 3.
  • 4.
    openpolicyagent.org@sometorin What Is Policy? ●Policies are vital to every organization ○ Policies are required across the stack ○ Policies are organization-specific ○ Policies change frequently over time
  • 5.
    openpolicyagent.org@sometorin What Is Policy? ●Policies are vital to every organization ○ Policies are required across the stack ○ Policies are organization-specific ○ Policies change frequently over time ● Policy enforcement methods vary wildly ○ Weak guarantees from tribal knowledge & wikis ○ High cost from hard-coded policy decisions
  • 6.
    openpolicyagent.org@sometorin What Is Policy? ●Policies are vital to every organization ○ Policies are required across the stack ○ Policies are organization-specific ○ Policies change frequently over time ● Policy enforcement methods vary wildly ○ Weak guarantees from tribal knowledge & wikis ○ High cost from hard-coded policy decisions ● Existing solutions lack expressiveness ○ Logic and data ○ Decisions ○ Composition
  • 7.
  • 8.
    openpolicyagent.org Example Scenario Alice Platform Engineer Bob AppEngineer ● Alice and Bob work for AcmeCorp ● Bob needs shell access to containers running on Kubernetes
  • 9.
    openpolicyagent.org Example Scenario Alice Platform Engineer Bob AppEngineer ● Alice and Bob work for AcmeCorp ● Bob needs shell access to containers running on Kubernetes ● Bob cannot be trusted with access to privileged containers running in the production namespace
  • 10.
    openpolicyagent.org@sometorin Kubernetes Extensibility Dynamic AdmissionControl Custom Resource Definitions (CRDs) API Aggregation Multi-scheduler Operators (Pattern) Image Webhook Token Authenticator Webhook Authorizer Hook 1.3 1.4 1.5 1.7<1.3 1.9 MutatingWebhook (+beta)
  • 11.
    openpolicyagent.org@sometorin Admission Control etcd Kubernetes APIServer Authentication Authorization Admission Control
  • 12.
    openpolicyagent.org@sometorin Admission Control etcd Kubernetes APIServer Admission Control Resource Quota Service Accounts Authentication Authorization Resource Management Security
  • 13.
    openpolicyagent.org@sometorin Admission Control etcd Kubernetes APIServer Admission Control Resource Quota Service Accounts Authentication Authorization Resource Management Security
  • 14.
    openpolicyagent.org@sometorin ● Static compilation& configuration ○ 30+ admission controllers ○ 1-4 added per release ○ Command line arguments ○ Static configuration files admit deny exec limitranger namespace resourcequota securitycontext serviceaccount initialresources alwayspullimages antiaffinity persistentvolume security imagepolicy storageclass gc podnodeselector defaulttolerationseconds podpreset initialization noderestriction podtolerationrestriction schedulingpolicy image/imagelimitrangerplugin image/imagepolicyplugin ingress/ingress project/lifecycle project/podnodeenvironment project/projectrequestlimit quota/quotaclusterresourceoverride quota/clusterquota quota/runonceduration scheduler/podnodeconstraints security/constraint Admission Control: Before 1.7
  • 15.
    openpolicyagent.org@sometorin ● Static compilation& configuration ○ 30+ admission controllers ○ 1-4 added per release ○ Command line arguments ○ Static configuration files ● Example Scenario ○ Alice forks Kubernetes into a private repository ○ Alice implements the policy inside the plugin framework ○ Alice now has to build, push, and upgrade Kubernetes itself Admission Control: Before 1.7 admit deny exec limitranger namespace resourcequota securitycontext serviceaccount initialresources alwayspullimages antiaffinity persistentvolume security imagepolicy storageclass gc podnodeselector defaulttolerationseconds podpreset initialization noderestriction podtolerationrestriction schedulingpolicy image/imagelimitrangerplugin image/imagepolicyplugin ingress/ingress project/lifecycle bobprotectionpolicy project/podnodeenvironment project/projectrequestlimit quota/quotaclusterresourceoverride quota/clusterquota quota/runonceduration scheduler/podnodeconstraints security/constraint
  • 16.
    openpolicyagent.org@sometorin Admission Control: Webhooks ●Admission controllers can be implemented as webhooks that run on top of Kubernetes ● Webhooks can allow or deny incoming requests ○ Before etcd is updated ○ Before clients are notified ● Webhooks are configured dynamically via Kubernetes APIs Kubernetes API Server Admission Control External Admission Webhooks
  • 17.
    openpolicyagent.org@sometorin Admission Control: Webhooks ●The API Server calls webhooks whose configuration rules match the incoming request: match [ {operations: [“create”], kinds: [“pods”]}, {operations: [“delete”], kinds: [“services”]} ] ● Rules can include wildcards: match [ {operations: [“*”], kinds: [“*”]} ] Kubernetes API Server Admission Control External Admission Webhooks
  • 18.
    openpolicyagent.org@sometorin Admission Control: Webhooks ●The API Server provides the operation, entire object, and user info in the webhook call kind: AdmissionReview spec: kind: {kind: Pod, version: v1} name: admission-webhook-demo-373699553-8srx8 namespace: default object: Options: Command: [sh] Container: admission-webhook-demo ... ResourcePath: pods/exec operation: CONNECT userInfo: groups: ['system:masters', 'system:authenticated'] username: minikube Kubernetes API Server Admission Control External Admission Webhooks $ kubectl exec
  • 19.
    openpolicyagent.org@sometorin Admission Control: Webhooks ●Webhooks respond with an AdmissionReview that indicates whether to allow or deny the request kind: AdmissionReview status: allowed: false reason: message: “nice try bob -alice” ● The API Server rejects the request IF ANY of the webhooks return a denial Kubernetes API Server Admission Control External Admission Webhooks $ kubectl exec error: nice try bob -alice
  • 20.
  • 21.
    openpolicyagent.org@sometorin ● Be carefulwith webhook dependencies! ○ Consider performance and availability ○ Avoid side effects Webhooks: Lessons Learned
  • 22.
    openpolicyagent.org@sometorin ● Be carefulwith webhook dependencies! ○ Consider performance and availability ○ Avoid side effects ● API server sends “internal representation” of Kubernetes objects over the wire Webhooks: Lessons Learned
  • 23.
    openpolicyagent.org@sometorin ● Be carefulwith webhook dependencies! ○ Consider performance and availability ○ Avoid side effects ● API server sends “internal representation” of Kubernetes objects over the wire ● API server “fails open” if webhook fails (configurable in 1.9) Webhooks: Lessons Learned
  • 24.
    openpolicyagent.org@sometorin ● Be carefulwith webhook dependencies! ○ Consider performance and availability ○ Avoid side effects ● API server sends “internal representation” of Kubernetes objects over the wire ● API server “fails open” if webhook fails (configurable in 1.9) ● Must serve POST requests at https://<ip>:<port>/ (paths supported in 1.9) Webhooks: Lessons Learned
  • 25.
    openpolicyagent.org@sometorin ● Be carefulwith webhook dependencies! ○ Consider performance and availability ○ Avoid side effects ● API server sends “internal representation” of Kubernetes objects over the wire ● API server “fails open” if webhook fails (configurable in 1.9) ● Must serve POST requests at https://<ip>:<port>/ (paths supported in 1.9) ● Client-go vendoring has improved significantly Webhooks: Lessons Learned
  • 26.
    openpolicyagent.org@sometorin Webhooks...all the waydown? ● Webhooks (and initializers) lay the groundwork for extensible policy enforcement
  • 27.
    openpolicyagent.org@sometorin Webhooks...all the waydown? ● Webhooks (and initializers) lay the groundwork for extensible policy enforcement ● Policy decisions have been decoupled from enforcement
  • 28.
    openpolicyagent.org@sometorin Webhooks...all the waydown? ● Webhooks (and initializers) lay the groundwork for extensible policy enforcement ● Policy decisions have been decoupled from enforcement ● Is there a better way to author policies that control who can do what?
  • 29.
    openpolicyagent.org@sometorin apiVersion: v1 kind: Pod metadata: labels: app:nginx name: nginx-1493591563-bvl8q namespace: production spec: containers: - image: nginx imagePullPolicy: Always name: nginx securityContext: privileged: true dnsPolicy: ClusterFirst nodeName: minikube restartPolicy: Always status: containerStatuses: - name: nginx ready: true restartCount: 0 state: running: startedAt: 2017-08-01T06:34:22Z hostIP: 192.168.99.100 phase: Running podIP: 172.17.0.4 startTime: 2017-08-01T06:34:13Z
  • 30.
    openpolicyagent.org@sometorin apiVersion: v1 kind: Pod metadata: labels: app:nginx name: nginx-1493591563-bvl8q namespace: production spec: containers: - image: nginx imagePullPolicy: Always name: nginx securityContext: privileged: true dnsPolicy: ClusterFirst nodeName: minikube restartPolicy: Always status: containerStatuses: - name: nginx ready: true restartCount: 0 state: running: startedAt: 2017-08-01T06:34:22Z hostIP: 192.168.99.100 phase: Running podIP: 172.17.0.4 startTime: 2017-08-01T06:34:13Z # references spec.containers[0].image
  • 31.
    openpolicyagent.org@sometorin apiVersion: v1 kind: Pod metadata: labels: app:nginx name: nginx-1493591563-bvl8q namespace: production spec: containers: - image: nginx imagePullPolicy: Always name: nginx securityContext: privileged: true dnsPolicy: ClusterFirst nodeName: minikube restartPolicy: Always status: containerStatuses: - name: nginx ready: true restartCount: 0 state: running: startedAt: 2017-08-01T06:34:22Z hostIP: 192.168.99.100 phase: Running podIP: 172.17.0.4 startTime: 2017-08-01T06:34:13Z # references spec.containers[0].image # variables and iteration container = spec.containers[_]
  • 32.
    openpolicyagent.org@sometorin apiVersion: v1 kind: Pod metadata: labels: app:nginx name: nginx-1493591563-bvl8q namespace: production spec: containers: - image: nginx imagePullPolicy: Always name: nginx securityContext: privileged: true dnsPolicy: ClusterFirst nodeName: minikube restartPolicy: Always status: containerStatuses: - name: nginx ready: true restartCount: 0 state: running: startedAt: 2017-08-01T06:34:22Z hostIP: 192.168.99.100 phase: Running podIP: 172.17.0.4 startTime: 2017-08-01T06:34:13Z # references spec.containers[0].image # variables and iteration container = spec.containers[_] # expressions container.securityContext.privileged = true
  • 33.
    openpolicyagent.org@sometorin apiVersion: v1 kind: Pod metadata: labels: app:nginx name: nginx-1493591563-bvl8q namespace: production spec: containers: - image: nginx imagePullPolicy: Always name: nginx securityContext: privileged: true dnsPolicy: ClusterFirst nodeName: minikube restartPolicy: Always status: containerStatuses: - name: nginx ready: true restartCount: 0 state: running: startedAt: 2017-08-01T06:34:22Z hostIP: 192.168.99.100 phase: Running podIP: 172.17.0.4 startTime: 2017-08-01T06:34:13Z # references spec.containers[0].image # variables and iteration container = spec.containers[_] # expressions container.securityContext.privileged = true # functions is_privileged(container) { container.securityContext.privileged = true }
  • 34.
    openpolicyagent.org@sometorin apiVersion: v1 kind: Pod metadata: labels: app:nginx name: nginx-1493591563-bvl8q namespace: production spec: containers: - image: nginx imagePullPolicy: Always name: nginx securityContext: privileged: true dnsPolicy: ClusterFirst nodeName: minikube restartPolicy: Always status: containerStatuses: - name: nginx ready: true restartCount: 0 state: running: startedAt: 2017-08-01T06:34:22Z hostIP: 192.168.99.100 phase: Running podIP: 172.17.0.4 startTime: 2017-08-01T06:34:13Z # references spec.containers[0].image # variables and iteration container = spec.containers[_] # expressions container.securityContext.privileged = true # functions is_privileged(container) { container.securityContext.privileged = true } # rules deny { review.user = “bob” review.operation = “CONNECT” review.namespace = “production” is_privileged(spec.containers[_]) }
  • 35.
    openpolicyagent.org@sometorin OPA is anopen source, general-purpose policy engine Policy Query Policy Decision
  • 36.
    openpolicyagent.org@sometorin OPA is anopen source, general-purpose policy engine Policy Query Policy Decision ● Declarative Language (Rego) ○ Is X allowed to call operation Y on resource Z? ○ What clusters should workload X be deployed to? ○ What annotations must be present on object X?
  • 37.
    openpolicyagent.org@sometorin OPA is anopen source, general-purpose policy engine Policy Query Policy Decision ● Declarative Language (Rego) ○ Is X allowed to call operation Y on resource Z? ○ What clusters should workload X be deployed to? ○ What annotations must be present on object X? ● Library/Daemon (Go) ○ In-memory, zero runtime dependencies ○ Evaluation engine: parser, compiler, interpreter ○ Tooling: REPL, test runner, tracing
  • 38.
    openpolicyagent.org@sometorin OPA is anopen source, general-purpose policy engine Policy Query Policy Decision ● Declarative Language (Rego) ○ Is X allowed to call operation Y on resource Z? ○ What clusters should workload X be deployed to? ○ What annotations must be present on object X? ● Library/Daemon (Go) ○ In-memory, zero runtime dependencies ○ Evaluation engine: parser, compiler, interpreter ○ Tooling: REPL, test runner, tracing ● Growing community ○ Sponsored by Styra and Google/Firebase ○ Used by Netflix, Medallia, Huawei, Schuberg Philis, and more ○ Integrations for Istio, Kubernetes, Terraform, PAM, AWS, and more
  • 39.
  • 40.
  • 41.