SlideShare a Scribd company logo
Copyright © 2021 Mirantis, Inc. All rights reserved
PRO TALK:
Kubernetes Security Workshop
Avinash Desireddy
Sr. Solutions Architect
2
Sr. Solutions Architect @ Mirantis
/avinashdesireddy
/avinashdesiredd
/avinashdesireddy
AVINASH DESIREDDY
SPEAKER
Director, Professional Services @ Mirantis
/anokun7
/anooplive
/anoopkumarv
ANOOP KUMAR
MODERATOR
3
Kubernetes: Adoption, Security & Market Trends
Source: The State of Containers and Kubernetes Security Report - Survey by StackRox(RedHat) in 2021
In the past 12 months, what security incidents or
issues related to containers and/or Kubernetes
have you experienced?
Have you ever delayed or slowed down
application deployment into production due to
container or Kubernetes security concerns?
What is your biggest concern about your
company’s container strategy?
4
Code
Code Best Practices
Vulnerability scanners
Container
Restrict Images, Privileged
The 4 C’s of Cloud-Native Security
Cluster
Authentication,
Authorization, Admission,
Network Policy
Cloud
Datacenter, Network,
Servers
2
4
3
1
5
https://github.com/avinashdesireddy/k8s-security-workshop.git
API
ETCD
Overview: Onboard Apps Securely
Blue
Red
Green
Worker Node
Master Node
SCHED
C-M
Worker Node
Worker Node
● Isolate App teams Access rights?
● Protect clusters from restricted workloads?
● Protect communication layer in the cluster?
Apps
&
App
Teams
Platform Engineer
6
https://github.com/avinashdesireddy/k8s-security-workshop.git
Worker Node
Master Node
API
ETCD
SCHED
C-M
Worker Node
Worker Node
Scenario #1 - Grant access to Users
Blue
Red
Green
Worker Node
Master Node
API
ETCD
SCHED
C-M
Worker Node
Worker Node
Role-Based Access Control
A way of granting users access to Kubernetes API
resources
❏ What API Resources a user should access?
❏ What Operations(Verbs) can be performed?
❏ Who can grant access?
Apps
&
App
Teams
Platform Engineer
7
https://github.com/avinashdesireddy/k8s-security-workshop.git
ClusterRoleBinding
RoleBinding
Role Based Access Control
- List
- Get
- Watch
- Create
- Update
- Patch
- Delete
Verbs / Actions
Subjects
Resources
Role
ClusterRole
belongs to
binds
binds
connects
8
https://github.com/avinashdesireddy/k8s-security-workshop.git
ClusterRoleBinding
RoleBinding
Role Based Access Control
- List
- Get
- Watch
- Create
- Update
- Patch
- Delete
Verbs / Actions
Subjects
Resources
Role
ClusterRole
belongs to
binds
binds
connects
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: role-blue
namespace: blue
rules:
- apiGroups: ["", "apps"]
resources: ["deployments", "services"]
verbs: ["create", "delete", "list"]
apiVersion:
rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: blue-rb
namespace: blue-ns
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: blue
roleRef:
kind: Role
name: role-blue
apiGroup: rbac.authorization.k8s.io
9
https://github.com/avinashdesireddy/k8s-security-workshop.git
Demo: RBAC
● Create Namespaces
● Grant Access to App Users to respective
Namespaces
● Deploy 3 applications
Environment
Kubernetes IDE
Access the cluster
/avinashdesireddy/k8s-securi
ty-workshop.git
Mirantis Kubernetes Engine
1 Manager, 3 Worker
Version - 1.21.3
Infrastructure
Nodes, LB, DNS, etc
10
https://github.com/avinashdesireddy/k8s-security-workshop.git
Worker Node
Master Node
API
ETCD
SCHED
C-M
Worker Node
Worker Node
Happy Users!!!
POD
POD
POD
POD
POD
POD
POD
POD
POD
POD
POD
Green
Blue
Red
Apps
&
App
Teams
Platform Engineer
11
https://github.com/avinashdesireddy/k8s-security-workshop.git
All of a sudden, Pods belong to App
Blue started consuming a lot of
memory in the cluster.
How do we fix it?
Resource Limits
Worker Node
Master Node
API
ETCD
SCHED
C-M
Worker Node
Worker Node
Scenario #2
POD
POD
POD
POD
POD
POD
POD
POD
POD
POD
POD
12
https://github.com/avinashdesireddy/k8s-security-workshop.git
Scenario #2: Coordinating changes
● Identify Application Owner
● Ask Owner of App Blue to specify Memory & CPU Limits on
Containers
● Configure Resource Quota & Limits on Namespaces
13
https://github.com/avinashdesireddy/k8s-security-workshop.git
Scenario #2: Challenges
● How can we enforce these across all the applications in the
cluster?
○ Reach out to multiple application to make changes?
○ Define Best Practices?
○ Monthly Audits?
Do you find it a challenge while
agreeing on Cluster Best
Practices with App Teams?
ⓘ Start presenting to display the poll results on this slide.
15
https://github.com/avinashdesireddy/k8s-security-workshop.git
Worker Node
Master Node
API
ETCD
SCHED
C-M
Worker Node
Worker Node
Scenario #2 - Policy Enforcement
Blue
Red
Green
POD
POD
POD
POD
POD
POD
POD
POD
POD
POD
POD
Apps
&
App
Teams
Platform Engineer
16
https://github.com/avinashdesireddy/k8s-security-workshop.git
Worker Node
Master Node
API
ETCD
SCHED
C-M
Worker Node
Worker Node
Scenario #2 - Policy Enforcement
Blue
Red
Green
POD
POD
POD
POD
POD
POD
POD
POD
POD
POD
POD
Policies
❏ Set up Resource Limits on
containers
❏ Set Resource Quota & Limits
on Namespaces
❏ Images from approved
registries
❏ Limit NodePort Services
❏ Specific labels
Apps
&
App
Teams
Platform Engineer
17
https://github.com/avinashdesireddy/k8s-security-workshop.git
Worker Node
Master Node
API
ETCD
SCHED
C-M
Worker Node
Worker Node
Scenario #2 - Policy Enforcement
Blue
Red
Green
POD
POD
POD
POD
POD
POD
POD
POD
POD
POD
POD
Policies
❏ Set up Resource Limits on
containers
❏ Set Resource Quota & Limits
on Namespaces
❏ Images from approved
registries
❏ Limit NodePort Services
❏ Specific labels
Apps
&
App
Teams
Platform Engineer
18
https://github.com/avinashdesireddy/k8s-security-workshop.git
Open Policy Agent (OPA)
● CNCF Graduated
● General Purpose Policy Engine
● Empowers admins with more
CONTROL over the system
● REGO Language
● Gatekeeper → Admission Controller
implementation of OPA
19
https://github.com/avinashdesireddy/k8s-security-workshop.git
app.yaml
Policy
ConstraintTemplate
Policy Constraint
OPA in Kubernetes
Admission
Controller
Gatekeeper/OPA
defines
kubectl apply
validates
Approve /
deny
20
Demo: OPA
● Restrict NodePort Usage
● Enforce Container Resource Limits
Environment
Kubernetes IDE
Access the cluster
/avinashdesireddy/k8s-securi
ty-workshop.git
Mirantis Kubernetes Engine
1 Manager, 3 Worker
Version - 1.21.3
Open Policy Agent /
Gatekeeper
21
https://github.com/avinashdesireddy/k8s-security-workshop.git
Worker Node
Master Node
API
ETCD
SCHED
C-M
Worker Node
Worker Node
Happy Users… Happy Cluster!!!
Blue
Red
Green
POD POD
POD
POD
POD
POD
POD
Apps
&
App
Teams
Platform Engineer
22
https://github.com/avinashdesireddy/k8s-security-workshop.git
Worker Node
Master Node
API
ETCD
SCHED
C-M
Worker Node
Worker Node
Scenario #3: Network Security
POD POD
POD
POD
POD
POD
POD
New features are added to App Blue,
the pods must connect to an external
MySql DB and to an exposed API in
Green App Pod
How do we control
Network Traffic to/from
Pods?
Network Policies
23
Network Policy
POD POD
POD
apiVersion
: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: test-network-policy
namespace: default
spec:
podSelector
:
matchLabels
:
role: db
policyTypes
:
- Ingress
- Egress
ingress:
- from:
- ipBlock:
cidr: 172.17.0.0/16
except:
- 172.17.1.0/24
- namespaceSelector
:
matchLabels
:
project: myproject
- podSelector
:
matchLabels
:
role: frontend
ports:
- protocol: TCP
port: 6379
egress:
- to:
- ipBlock:
cidr: 10.0.0.0/24
ports:
- protocol: TCP
port: 5978
● Control Traffic to/from pods
● Traffic between pods are non-Isolated
● Namespace scoped
● Can be defined based on -
○ Pod, Namespace or IP Range
Who are using Network
Policies?
ⓘ Start presenting to display the poll results on this slide.
25
Default Deny Policy
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-all
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
egress:
- to:
- namespaceSelector
:
matchLabels:
kubernetes.io/metadata.name
: kube-system
podSelector:
matchLabels:
k8s-app: kube-dns
ports:
- protocol: UDP
port: 53
- protocol: TCP
port: 53
POD
26
https://github.com/avinashdesireddy/k8s-security-workshop.git
Scenario #3: App Blue connecting to MySQL
13.56.49.134
172.31.0.0/24
App Blue
POD
POD
192.168.96.4
192.168.96.3
App Green
POD
POD
192.168.206.7
192.168.206.9
1
Open firewall rule on DB to allow
connections from 172.31.0.0/24 on
port 3306
1
Create Egress Network Policy
based on PodSelector
3
Open firewall rule on Cluster
Nodes to allow traffic to
13.56.49.134 on port 3306
2
apiVersion
: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: mysql-port-egress
spec:
podSelector
:
matchLabels
:
app: blue
backend: mysql
policyTypes
:
- Egress
egress:
- to:
- ipBlock:
cidr: 13.56.49.134/32
ports:
- protocol: TCP
port: 3306
27
https://github.com/avinashdesireddy/k8s-security-workshop.git
Scenario #3: App Blue connecting to App Green
172.31.0.0/24
App Blue
POD
POD
192.168.96.4
192.168.96.3
App Green
POD
POD
192.168.206.7
192.168.206.9
Create Egress Network Policy
based on Green PodSelector
1
Create Ingress Network Policy
based on Blue PodSelector
2
apiVersion
: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: to-green-egress
namespace: blue
spec:
podSelector
:
matchLabels
:
app: blue
policyTypes
:
- Egress
egress:
- to:
- podSelector
:
matchLabels
:
app: green
ports:
- protocol: TCP
port: 8080
apiVersion
: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: from-blue-ingress
namespace: green
spec:
podSelector
:
matchLabels
:
app: green
policyTypes
:
- Ingress
ingress:
- from:
- podSelector
:
matchLabels
:
app: blue
28
Demo: Network Policies
● Create Default Network Policies
● Allow access for “Blue” App to MySQL on
Port 3306
● Allow access for “Blue” App to access
“Green” Application’s API
Environment
Mirantis
Kubernetes
Engine
Kubernetes IDE
Access the cluster
/avinashdesireddy/k8s-securi
ty-workshop.git
Mirantis Kubernetes Engine
1 Manager, 3 Worker
Version - 1.21.3
Kubernetes Network Policies
29
https://github.com/avinashdesireddy/k8s-security-workshop.git
CNIs with Network Policy Support
● Weave
● Calico
● Cilium
● Kube-router
● Istio
30
https://github.com/avinashdesireddy/k8s-security-workshop.git
Apps
&
App
Teams
Platform Engineer
Takeaways…
Worker Node
Master Node
API
ETCD
SCHED
C-M
Worker Node
Worker Node
Blue
Red
Green
Enforce Policies
Build RBAC
Strategy
Start with
Zero-Trust
Network Policy
31
https://github.com/avinashdesireddy/k8s-security-workshop.git
Thank you!
/avinashdesiredd /anooplive

More Related Content

PDF
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
PDF
A hitchhiker‘s guide to the cloud native stack
PDF
A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17
PDF
In Search of Segmentation
PDF
Security in a containerized world - Jessie Frazelle
PPTX
#Interactive Session by Kirti Ranjan Satapathy and Nandini K, "Elements of Qu...
PPTX
Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...
PPTX
Securing Kubernetes Clusters with NGINX Plus Ingress Controller & NAP
Kubernetes One-Click Deployment: Hands-on Workshop (Mainz)
A hitchhiker‘s guide to the cloud native stack
A Hitchhiker’s Guide to the Cloud Native Stack. #CDS17
In Search of Segmentation
Security in a containerized world - Jessie Frazelle
#Interactive Session by Kirti Ranjan Satapathy and Nandini K, "Elements of Qu...
Scaling Prometheus Metrics in Kubernetes with Telegraf | Chris Goller | Influ...
Securing Kubernetes Clusters with NGINX Plus Ingress Controller & NAP

Similar to Kubernetes Security Workshop (20)

PDF
Dipping Your Toes Into Cloud Native Application Development
PDF
Why Pay for Open Source Linux? Avoid the Hidden Cost of DIY
PDF
IoTWorld 2016 OSS Keynote Param Singh, Ian Skerrett
PPTX
apidays LIVE New York 2021 - Simplify Open Policy Agent with Styra DAS by Tim...
PPTX
Use GitLab with Chaos Engineering to Harden your Applications + OpenEBS 1.3 ...
PDF
DCEU 18: Docker Container Networking
PDF
Getting More Out of the Node.js, PHP, and Python Agents - AppSphere16
PDF
Scaling frontend applications with micro-frontends Presentation.pdf
PDF
Pursuing evasive custom command & control - GuideM
PDF
Managing Compliance in Container Environments
DOCX
Bindu_Resume
PPTX
Cloud nativemicroservices jax-london2020
PPTX
Cloud nativemicroservices jax-london2020
PDF
BSidesLV 2018 - Katie Nickels and John Wunder - ATT&CKing the Status Quo
PDF
simplifying_operations_with_automation.pdf
PDF
Cloud-native .NET Microservices mit Kubernetes
PDF
Join Our Party: The Cloud Native Adventure Brigade (TCSW 2019)
PPTX
Cross Section and Deep Dive into GE Predix
PDF
Cilium - API-aware Networking and Security for Containers based on BPF
PPTX
K8Guard - An Auditing System For Kubernetes
Dipping Your Toes Into Cloud Native Application Development
Why Pay for Open Source Linux? Avoid the Hidden Cost of DIY
IoTWorld 2016 OSS Keynote Param Singh, Ian Skerrett
apidays LIVE New York 2021 - Simplify Open Policy Agent with Styra DAS by Tim...
Use GitLab with Chaos Engineering to Harden your Applications + OpenEBS 1.3 ...
DCEU 18: Docker Container Networking
Getting More Out of the Node.js, PHP, and Python Agents - AppSphere16
Scaling frontend applications with micro-frontends Presentation.pdf
Pursuing evasive custom command & control - GuideM
Managing Compliance in Container Environments
Bindu_Resume
Cloud nativemicroservices jax-london2020
Cloud nativemicroservices jax-london2020
BSidesLV 2018 - Katie Nickels and John Wunder - ATT&CKing the Status Quo
simplifying_operations_with_automation.pdf
Cloud-native .NET Microservices mit Kubernetes
Join Our Party: The Cloud Native Adventure Brigade (TCSW 2019)
Cross Section and Deep Dive into GE Predix
Cilium - API-aware Networking and Security for Containers based on BPF
K8Guard - An Auditing System For Kubernetes
Ad

More from Mirantis (20)

PDF
How to Accelerate Your Application Delivery Process on Top of Kubernetes Usin...
PDF
Using Kubernetes to make cellular data plans cheaper for 50M users
PDF
How to Build a Basic Edge Cloud
PDF
Securing Your Containers is Not Enough: How to Encrypt Container Data
PDF
What's New in Kubernetes 1.18 Webinar Slides
PDF
Comparison of Current Service Mesh Architectures
PDF
Your Application Deserves Better than Kubernetes Ingress: Istio vs. Kubernetes
PDF
Demystifying Cloud Security Compliance
PDF
Mirantis life
PDF
OpenStack and the IoT: Where we are, where we're going, what we need to get t...
PDF
Boris Renski: OpenStack Summit Keynote Austin 2016
PPTX
Digital Disciplines: Attaining Market Leadership through the Cloud
PPTX
Decomposing Lithium's Monolith with Kubernetes and OpenStack
PPTX
OpenStack: Changing the Face of Service Delivery
PPTX
Accelerating the Next 10,000 Clouds
PPTX
Containers for the Enterprise: It's Not That Simple
PPTX
Protecting Yourself from the Container Shakeout
PPTX
It's Not the Technology, It's You
PDF
OpenStack as the Platform for Innovation
PPTX
Moving AWS workloads to OpenStack
How to Accelerate Your Application Delivery Process on Top of Kubernetes Usin...
Using Kubernetes to make cellular data plans cheaper for 50M users
How to Build a Basic Edge Cloud
Securing Your Containers is Not Enough: How to Encrypt Container Data
What's New in Kubernetes 1.18 Webinar Slides
Comparison of Current Service Mesh Architectures
Your Application Deserves Better than Kubernetes Ingress: Istio vs. Kubernetes
Demystifying Cloud Security Compliance
Mirantis life
OpenStack and the IoT: Where we are, where we're going, what we need to get t...
Boris Renski: OpenStack Summit Keynote Austin 2016
Digital Disciplines: Attaining Market Leadership through the Cloud
Decomposing Lithium's Monolith with Kubernetes and OpenStack
OpenStack: Changing the Face of Service Delivery
Accelerating the Next 10,000 Clouds
Containers for the Enterprise: It's Not That Simple
Protecting Yourself from the Container Shakeout
It's Not the Technology, It's You
OpenStack as the Platform for Innovation
Moving AWS workloads to OpenStack
Ad

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
cuic standard and advanced reporting.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Machine learning based COVID-19 study performance prediction
PDF
Spectral efficient network and resource selection model in 5G networks
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Approach and Philosophy of On baking technology
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Modernizing your data center with Dell and AMD
PPTX
A Presentation on Artificial Intelligence
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
cuic standard and advanced reporting.pdf
Empathic Computing: Creating Shared Understanding
Machine learning based COVID-19 study performance prediction
Spectral efficient network and resource selection model in 5G networks
The AUB Centre for AI in Media Proposal.docx
The Rise and Fall of 3GPP – Time for a Sabbatical?
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Per capita expenditure prediction using model stacking based on satellite ima...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Approach and Philosophy of On baking technology
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Understanding_Digital_Forensics_Presentation.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Modernizing your data center with Dell and AMD
A Presentation on Artificial Intelligence
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

Kubernetes Security Workshop