@tlhinrichs openpolicyagent.org
Tim Hinrichs
CTO, Co-Founder of Styra
Co-Founder of OPA
Kubernetes Security
with Open Policy Agent
Desired State
^
@tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org
kubectl create -f nginx.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
nginx.yaml
Desired State Runtime State
Server Node
Server Node
@tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org
Compute
● Run arbitrary binaries from the internet
● Deploy code with known vulnerabilities
Networking
● App A can steal traffic from App B
(unintentionally or otherwise)
● Open egress traffic to 0.0.0.0
Storage
● Mission-critical data can be automatically
deleted when workloads move to new
nodes
Security
● 3rdparty software runs with root
privileges
● Data at-rest and in-transit not encrypted
Dangers Desired State
kubectl create -f nginx.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
nginx.yaml
@tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org
Compute
● Images may only be pulled from internal
registry
● Only scanned images may be deployed in
namespaces A, B, and C
● QA team must sign-off on image before
deployed to production
Networking
● Ingresses across namespaces should not
conflict
● Developers must not modify selectors or
labels referred to by selectors after creation
Storage
● Stateful deployments must use
‘RollingUpdate’ update strategy
Security
● Containers cannot run with privileged
security context
● Services in namespace X should have
AWS SSL annotation added
Guardrails Desired State
Open
Policy
Agent
kubectl create -f nginx.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
nginx.yaml
@tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org
Desired State Runtime State
Server Node
Server Node
Kubernetes implements
Kubernetes
API Server
Validating
Webhook
Open
Policy
Agent
kubectl create -f nginx.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
nginx.yaml
@tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org
Open Policy Agent: How it works
K8s API Server
OPA
Policy (Rego) Data
(JSON)
Request
DecisionQuery
kubectl create -f nginx.yaml
@tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org
Open Policy Agent: How it works
K8s API Server
OPA
Policy (Rego) Data
(JSON)
Request
DecisionQuery
kind:
kind: Deployment
request:
object:
metadata:
name: nginx-deployment
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
allow: false
reason: |
no costcenter label
kubectl create -f nginx.yaml
@tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org
What kind of guardrails do YOU need?
● Image repository safety
● Prevent conflicting ingresses
●
@tlhinrichs openpolicyagent.org
Live Coding!
@tlhinrichs openpolicyagent.org
openpolicyagent.org
kubernetes.io
Tim Hinrichs
@tlhinrichs
styra.com
@tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org
Sample Policies
package kubernetes.admission
deny[msg] {
input.request.kind.kind == "Pod"
image := input.request.object.spec.containers[_].image
not startswith(image, "hooli.com")
msg := sprintf("image fails to come from trusted registry: %v", [image])
}
deny[msg] {
input.request.kind.kind == "Ingress"
newhost := input.request.object.spec.rules[_].host
oldhost := data.kubernetes.ingresses[namespace][name].spec.rules[_].host
newhost == oldhost
msg := sprintf("ingress host conflicts with ingress %v/%v", [namespace, name])
}
@tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org
Open Policy Agent: Features
● Declarative Policy Language (Rego)
○ Can user X do operation Y on resource Z?
○ What invariants does workload W violate?
○ Which records should bob be allowed to see?
● Library, sidecar, host-level daemon
○ Policy and data are kept in-memory
○ Zero decision-time dependencies
● Management APIs for control & observability
○ Bundle service API for sending policy & data to OPA
○ Status service API for receiving status from OPA
○ Log service API for receiving audit log from OPA
● Tooling to build, test, and debug policy
○ opa run, opa test, opa fmt, opa deps, opa check, etc.
○ VS Code plugin, Tracing, Profiling, etc.
Open
Policy
Agent
@tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org
Open Policy Agent: Community
Inception
Project started in 2016 at
Styra.
Goal
Unify policy enforcement
across the stack.
Use Cases
Admission control
Authorization
ACLs
RBAC
IAM
ABAC
Risk management
Data Protection
Data Filtering
Users
Netflix
Chef
Medallia
Cloudflare
State Street
Pinterest
Intuit
Capital One
...and many more.
Today
CNCF project
(Incubation)
36 contributors
700 slack members
1.7K stars
20+ integrations

More Related Content

PDF
Whats new in brigade 2
PDF
Is your kubernetes negative or positive
PDF
DCSF19 Deploying Istio as an Ingress Controller
PDF
Kubescape single pane of glass
PDF
DCEU 18: From Monolith to Microservices
PPTX
Zero-downtime deployment with Kubernetes [Meetup #21 - 01]
PDF
Zero-downtime deployment of Micro-services with Kubernetes
PDF
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
Whats new in brigade 2
Is your kubernetes negative or positive
DCSF19 Deploying Istio as an Ingress Controller
Kubescape single pane of glass
DCEU 18: From Monolith to Microservices
Zero-downtime deployment with Kubernetes [Meetup #21 - 01]
Zero-downtime deployment of Micro-services with Kubernetes
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...

What's hot (20)

PDF
Demystifying container connectivity with kubernetes in docker
PPTX
Using the SDACK Architecture on Security Event Inspection by Yu-Lun Chen and ...
PDF
Networking in Docker EE 2.0 with Kubernetes and Swarm
PDF
Empower Your Docker Containers with Watson - DockerCon 2017 Austin
PDF
Docker ee an architecture and operations overview
PDF
The Complexity to "Yes" in Analytics Software and the Possibilities with Dock...
PDF
Montreal Kubernetes Meetup: Developer-first workflows (for microservices) on ...
PDF
DCEU 18: App-in-a-Box with Docker Application Packages
PDF
A vision of persistence
PDF
Building your production tech stack for docker container platform
PDF
Operatorhub.io and your Kubernetes cluster | DevNation Tech Talk
PDF
DockerCon 18 Cool Hacks: solo.io
PPTX
Monitoring Docker Application in Production
PDF
Skynet vs. Planet of The Apes: Duel!
PDF
5 patterns for success for application transformation
PDF
Modernizing Traditional Applications
PDF
Windows container security
PDF
Docker Store: The New Destination for Enterprise Software - Lily Guo and Alfr...
PPTX
The Challenges of Becoming Cloud Native
PDF
Building a Secure Supply Chain with Docker
Demystifying container connectivity with kubernetes in docker
Using the SDACK Architecture on Security Event Inspection by Yu-Lun Chen and ...
Networking in Docker EE 2.0 with Kubernetes and Swarm
Empower Your Docker Containers with Watson - DockerCon 2017 Austin
Docker ee an architecture and operations overview
The Complexity to "Yes" in Analytics Software and the Possibilities with Dock...
Montreal Kubernetes Meetup: Developer-first workflows (for microservices) on ...
DCEU 18: App-in-a-Box with Docker Application Packages
A vision of persistence
Building your production tech stack for docker container platform
Operatorhub.io and your Kubernetes cluster | DevNation Tech Talk
DockerCon 18 Cool Hacks: solo.io
Monitoring Docker Application in Production
Skynet vs. Planet of The Apes: Duel!
5 patterns for success for application transformation
Modernizing Traditional Applications
Windows container security
Docker Store: The New Destination for Enterprise Software - Lily Guo and Alfr...
The Challenges of Becoming Cloud Native
Building a Secure Supply Chain with Docker
Ad

Similar to DCSF19 Kubernetes Security with OPA (20)

PDF
OPA open policy agent
PPTX
OPA APIs and Use Case Survey
PDF
DSO-LG 2021 Reboot: Policy As Code (Anders Eknert)
PPTX
Cloud native policy enforcement with Open Policy Agent
PDF
Kubernetes Security with Calico and Open Policy Agent
PDF
Fine-grained Authorization in a Containerized World
PDF
Enforcing Bespoke Policies in Kubernetes
PDF
Dynamic Policy Enforcement for Microservice Environments
PPTX
apidays LIVE New York 2021 - Simplify Open Policy Agent with Styra DAS by Tim...
PDF
stackconf 2021 | Embracing change: Policy-as-code for Kubernetes with OPA and...
PDF
Evolution of security strategies in K8s environments- All day devops
PDF
Dynamic Authorization & Policy Control for Docker Environments
PPTX
Securing Kubernetes Clusters with NGINX Plus Ingress Controller & NAP
PDF
Nginx app protect-for-meetup-v1.0-202006_lk
PDF
Securing Kubernetes Workloads
PPTX
Policy Enforcement on Kubernetes with Open Policy Agent
PDF
Open Policy Agent
PPTX
Nagivating the interface between open and closed source software
PPTX
Opa microservice authorization
PDF
Defining & Enforcing Policies the GitOps Way
OPA open policy agent
OPA APIs and Use Case Survey
DSO-LG 2021 Reboot: Policy As Code (Anders Eknert)
Cloud native policy enforcement with Open Policy Agent
Kubernetes Security with Calico and Open Policy Agent
Fine-grained Authorization in a Containerized World
Enforcing Bespoke Policies in Kubernetes
Dynamic Policy Enforcement for Microservice Environments
apidays LIVE New York 2021 - Simplify Open Policy Agent with Styra DAS by Tim...
stackconf 2021 | Embracing change: Policy-as-code for Kubernetes with OPA and...
Evolution of security strategies in K8s environments- All day devops
Dynamic Authorization & Policy Control for Docker Environments
Securing Kubernetes Clusters with NGINX Plus Ingress Controller & NAP
Nginx app protect-for-meetup-v1.0-202006_lk
Securing Kubernetes Workloads
Policy Enforcement on Kubernetes with Open Policy Agent
Open Policy Agent
Nagivating the interface between open and closed source software
Opa microservice authorization
Defining & Enforcing Policies the GitOps Way
Ad

More from Docker, Inc. (20)

PDF
Containerize Your Game Server for the Best Multiplayer Experience
PDF
How to Improve Your Image Builds Using Advance Docker Build
PDF
Build & Deploy Multi-Container Applications to AWS
PDF
Securing Your Containerized Applications with NGINX
PDF
How To Build and Run Node Apps with Docker and Compose
PDF
Hands-on Helm
PDF
Distributed Deep Learning with Docker at Salesforce
PDF
The First 10M Pulls: Building The Official Curl Image for Docker Hub
PDF
Monitoring in a Microservices World
PDF
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
PDF
Predicting Space Weather with Docker
PDF
Become a Docker Power User With Microsoft Visual Studio Code
PDF
How to Use Mirroring and Caching to Optimize your Container Registry
PDF
Monolithic to Microservices + Docker = SDLC on Steroids!
PDF
Kubernetes at Datadog Scale
PDF
Labels, Labels, Labels
PDF
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
PDF
Build & Deploy Multi-Container Applications to AWS
PDF
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
PDF
Developing with Docker for the Arm Architecture
Containerize Your Game Server for the Best Multiplayer Experience
How to Improve Your Image Builds Using Advance Docker Build
Build & Deploy Multi-Container Applications to AWS
Securing Your Containerized Applications with NGINX
How To Build and Run Node Apps with Docker and Compose
Hands-on Helm
Distributed Deep Learning with Docker at Salesforce
The First 10M Pulls: Building The Official Curl Image for Docker Hub
Monitoring in a Microservices World
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
Predicting Space Weather with Docker
Become a Docker Power User With Microsoft Visual Studio Code
How to Use Mirroring and Caching to Optimize your Container Registry
Monolithic to Microservices + Docker = SDLC on Steroids!
Kubernetes at Datadog Scale
Labels, Labels, Labels
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
Build & Deploy Multi-Container Applications to AWS
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
Developing with Docker for the Arm Architecture

Recently uploaded (20)

PDF
substrate PowerPoint Presentation basic one
PDF
EGCB_Solar_Project_Presentation_and Finalcial Analysis.pdf
PPTX
Presentation - Principles of Instructional Design.pptx
PDF
TrustArc Webinar - Data Minimization in Practice_ Reducing Risk, Enhancing Co...
PDF
CCUS-as-the-Missing-Link-to-Net-Zero_AksCurious.pdf
PPTX
From XAI to XEE through Influence and Provenance.Controlling model fairness o...
PPTX
AQUEEL MUSHTAQUE FAKIH COMPUTER CENTER .
PPTX
CRM(Customer Relationship Managmnet) Presentation
PPTX
Information-Technology-in-Human-Society (2).pptx
PDF
State of AI in Business 2025 - MIT NANDA
PPTX
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
PDF
Optimizing bioinformatics applications: a novel approach with human protein d...
PDF
TicketRoot: Event Tech Solutions Deck 2025
PDF
Fitaura: AI & Machine Learning Powered Fitness Tracker
PDF
Secure Java Applications against Quantum Threats
PDF
Ebook - The Future of AI A Comprehensive Guide.pdf
PPTX
maintenance powerrpoint for adaprive and preventive
PDF
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
PDF
Peak of Data & AI Encore: Scalable Design & Infrastructure
PPTX
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
substrate PowerPoint Presentation basic one
EGCB_Solar_Project_Presentation_and Finalcial Analysis.pdf
Presentation - Principles of Instructional Design.pptx
TrustArc Webinar - Data Minimization in Practice_ Reducing Risk, Enhancing Co...
CCUS-as-the-Missing-Link-to-Net-Zero_AksCurious.pdf
From XAI to XEE through Influence and Provenance.Controlling model fairness o...
AQUEEL MUSHTAQUE FAKIH COMPUTER CENTER .
CRM(Customer Relationship Managmnet) Presentation
Information-Technology-in-Human-Society (2).pptx
State of AI in Business 2025 - MIT NANDA
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
Optimizing bioinformatics applications: a novel approach with human protein d...
TicketRoot: Event Tech Solutions Deck 2025
Fitaura: AI & Machine Learning Powered Fitness Tracker
Secure Java Applications against Quantum Threats
Ebook - The Future of AI A Comprehensive Guide.pdf
maintenance powerrpoint for adaprive and preventive
“Introduction to Designing with AI Agents,” a Presentation from Amazon Web Se...
Peak of Data & AI Encore: Scalable Design & Infrastructure
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com

DCSF19 Kubernetes Security with OPA

  • 1. @tlhinrichs openpolicyagent.org Tim Hinrichs CTO, Co-Founder of Styra Co-Founder of OPA Kubernetes Security with Open Policy Agent Desired State ^
  • 2. @tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org kubectl create -f nginx.yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 nginx.yaml Desired State Runtime State Server Node Server Node
  • 3. @tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org Compute ● Run arbitrary binaries from the internet ● Deploy code with known vulnerabilities Networking ● App A can steal traffic from App B (unintentionally or otherwise) ● Open egress traffic to 0.0.0.0 Storage ● Mission-critical data can be automatically deleted when workloads move to new nodes Security ● 3rdparty software runs with root privileges ● Data at-rest and in-transit not encrypted Dangers Desired State kubectl create -f nginx.yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 nginx.yaml
  • 4. @tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org Compute ● Images may only be pulled from internal registry ● Only scanned images may be deployed in namespaces A, B, and C ● QA team must sign-off on image before deployed to production Networking ● Ingresses across namespaces should not conflict ● Developers must not modify selectors or labels referred to by selectors after creation Storage ● Stateful deployments must use ‘RollingUpdate’ update strategy Security ● Containers cannot run with privileged security context ● Services in namespace X should have AWS SSL annotation added Guardrails Desired State Open Policy Agent kubectl create -f nginx.yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 nginx.yaml
  • 5. @tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org Desired State Runtime State Server Node Server Node Kubernetes implements Kubernetes API Server Validating Webhook Open Policy Agent kubectl create -f nginx.yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 nginx.yaml
  • 6. @tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org Open Policy Agent: How it works K8s API Server OPA Policy (Rego) Data (JSON) Request DecisionQuery kubectl create -f nginx.yaml
  • 7. @tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org Open Policy Agent: How it works K8s API Server OPA Policy (Rego) Data (JSON) Request DecisionQuery kind: kind: Deployment request: object: metadata: name: nginx-deployment spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 allow: false reason: | no costcenter label kubectl create -f nginx.yaml
  • 8. @tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org What kind of guardrails do YOU need? ● Image repository safety ● Prevent conflicting ingresses ●
  • 11. @tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org Sample Policies package kubernetes.admission deny[msg] { input.request.kind.kind == "Pod" image := input.request.object.spec.containers[_].image not startswith(image, "hooli.com") msg := sprintf("image fails to come from trusted registry: %v", [image]) } deny[msg] { input.request.kind.kind == "Ingress" newhost := input.request.object.spec.rules[_].host oldhost := data.kubernetes.ingresses[namespace][name].spec.rules[_].host newhost == oldhost msg := sprintf("ingress host conflicts with ingress %v/%v", [namespace, name]) }
  • 12. @tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org Open Policy Agent: Features ● Declarative Policy Language (Rego) ○ Can user X do operation Y on resource Z? ○ What invariants does workload W violate? ○ Which records should bob be allowed to see? ● Library, sidecar, host-level daemon ○ Policy and data are kept in-memory ○ Zero decision-time dependencies ● Management APIs for control & observability ○ Bundle service API for sending policy & data to OPA ○ Status service API for receiving status from OPA ○ Log service API for receiving audit log from OPA ● Tooling to build, test, and debug policy ○ opa run, opa test, opa fmt, opa deps, opa check, etc. ○ VS Code plugin, Tracing, Profiling, etc. Open Policy Agent
  • 13. @tlhinrichs openpolicyagent.org@tlhinrichs openpolicyagent.org Open Policy Agent: Community Inception Project started in 2016 at Styra. Goal Unify policy enforcement across the stack. Use Cases Admission control Authorization ACLs RBAC IAM ABAC Risk management Data Protection Data Filtering Users Netflix Chef Medallia Cloudflare State Street Pinterest Intuit Capital One ...and many more. Today CNCF project (Incubation) 36 contributors 700 slack members 1.7K stars 20+ integrations