SlideShare a Scribd company logo
Kubernetes & Container Security
by Volodymyr Shynkar
Senior Lead DevOps Engineer
2021 | intellias.com
[devops@stage ~]$ cat ABOUT_ME.md
• 6+ years of commercial DevOps experience. Overall 8+ years of
Engineering
• Member of Technology Office
• Member of the Center of Excellence
• Successfully migrated, rolled out, consulted over 15 projects in
the healthcare, gambling, automotive, e-commerce industries
• Certified SAFe Agile Software Engineer
• Addicted to IoT and Smart Home
• Cyclist, promoter of a healthy lifestyle
Volodymyr Shynkar
Senior Lead DevOps Engineer at Intellias
[devops@stage ~]$
Agenda Overview
Container Security
Kubernetes Security
Other Tooling to help
01
Overview
Will talk about:
• Scan containers and Pods for vulnerabilities or misconfigurations.
• Run containers and Pods with the least privileges possible.
• Use network separation to control the amount of damage a
compromise can cause.
• Use firewalls to limit unneeded network connectivity and
encryption to protect confidentiality.
• Use strong authentication and authorization to limit user and
administrator access as well as to limit the attack surface.
• Periodically review all Kubernetes settings and use vulnerability
scans to help ensure risks are appropriately accounted for and
security patches are applied.
Attack Surface
Analysis for:
• Cloud and Host
• Kubernetes Cluster
• Container (images and running)
Goal: Reduce the attack surface
Attack Surface – Cloud & Host
There are at least few things that you do yo achive base
security level:
• Run instances in private network
• Expose services only through external services like LB or Proxy
• Block all external traffic except exposed ports, like 80, 443
• Do not expose SSH. Try to use SSM instead.
• Minimize privilege to applications running on the host
• Optional: for HTTP traffic, use WAF if posiable
Goal: Follow “Principle of least privilege”
Managed K8s services already goes with most of this features enabled
02
Container Security
Dockerfile best practices
1.Avoid unnecessary privileges.
1. Avoid running containers as root.
2. Don’t bind to a specific UID.
3. Make executables owned by root and not writable.
2.Reduce attack surface.
1. Leverage multistage builds.
2. Use distroless images, or build your own from scratch.
3. Update your images frequently.
4. Watch out for exposed ports.
3.Prevent confidential data leaks.
1. Never put secrets or credentials in Dockerfile instructions.
2. Prefer COPY over ADD.
3. Be aware of the Docker context, and use .dockerignore.
4.Others.
1. Reduce the number of layers, and order them intelligently.
2. Add metadata and labels.
3. Leverage linters to automatize checks.
4. Scan your images locally during development.
5.Beyond image building.
1. Protect the docker socket and TCP connections.
2. Sign your images, and verify them on runtime.
3. Avoid tag mutability.
4. Don’t run your environment as root.
5. Include a health check.
6. Restrict your application capabilities. Source: https://sysdig.com/blog/dockerfile-best-practices/
Let’s start from scratch
First steps
Start from your app
• unprivileged user (rootless)
• read-only
• no shell, cat, grep, less, tail, echo, etc
• focus on fewer data stored inside the container - only
app, no source code, and build dependencies
• no backed secrets or bind through volume or
encrypted
Seriously :)
Let’s start from scratch
First steps
Start from your app
• unprivileged user (rootless)
• read-only
• no shell, cat, grep, less, tail, echo, etc
• focus on fewer data stored inside the container - only
app, no source code, and build dependencies
• no backed secrets or bind through volume or
encrypted
Serious :)
Let’s start from scratch
First steps
Start from your app
• unprivileged user (rootless)
• read-only
• no shell, cat, grep, less, tail, echo, etc
• focus on fewer data stored inside the container - only
app, no source code, and build dependencies
• no backed secrets or bind through volume or
encrypted
Seriously :)
Let’s start from scratch
First steps
Start from your app
• unprivileged user (rootless)
• read-only
• no shell, cat, grep, less, tail, echo, etc
• focus on fewer data stored inside the container - only
app, no source code, and build dependencies
• no backed secrets or bind through volume or
encrypted
Seriously :)
More examples:
https://github.com/GoogleContainerTools/distroless
Let’s start from scratch
First steps
Start from your app
• unprivileged user (rootless)
• read-only
• no shell, cat, grep, less, tail, echo, etc
• focus on fewer data stored inside the
container - only app, no source code, and
build dependencies
• no backed secrets or bind through volume or
encrypted
Seriously :)
Let’s start from scratch
First steps
Start from your app
• unprivileged user (rootless)
• read-only
• no shell, cat, grep, less, tail, echo, etc
• focus on fewer data stored inside the container - only
app, no source code, and build dependencies
• no backed secrets or bind through volume or
encrypted
Seriously :)
Scan your image
Docker and Snyk recently entered into a partnership to
provide container vulnerability scanning.
Alternative
Source: https://www.docker.com/blog/bringing-docker-scan-to-linux/
03
Kubernetes Security
Next to discuss:
• Deployment to the cluster
• Pod Security Policy
• Open Policy Agent
• Network Policy
• Secrets
• Securing the Cluster
Kubernetes Hardening
Remember: follow the “Principle of least privilege”
Deployment to the cluster
kubectl apply –f my_app.yaml
helm install my_app charts/my_app
How to automate deploy?
There are two approaches:
• Push-based
• Regular CI (Jenkins, Gitlab, GitHub, CircleCI)
How to automate deploy?
There are two approaches:
• Pull-based
• GitOps strategy (ArgoCD, Flux)
How to manage manage
By only two resources: AppProject and Application
By only two resources: AppProject and Application
How to manage manage
How to grant access
ArgoCD provided with powerful UI
• Embedded security features
• Support of SAML/OKTA.
• Enhanced experience
• Role-based
• Easy to use
Pod Security Policy
PSP are one way to control the security-related attributes of pods,
including container privilege levels.
• Do not run application processes as root
• Do not allow privilege escalation
• Use a read-only root filesystem
• Use the default (masked) /proc filesystem mount
• Do not use the host network or process space
• Drop unused and unnecessary Linux capabilities
• Service Account control
Pod Security Policy
When a PSP resource is created, it does nothing. You need to
authorize using RBAC!
Pod Security Policies is going to be marked as
deprecated since v1.21 and will be removed in v1.25
The PSP Replacement Policy is the new enhancement:
https://github.com/kubernetes/enhancements/tree/master/keps/sig-auth/2579-psp-replacement
PSP Replacement Policy
The way PSPs are applied
to Pods has proven
confusing to nearly everyone
that has attempted to use
them.
Open Policy Agent (Gatekeeper)
Gatekeeper controller provides you ability to:
• Required labels
• Required resources section
• Mutate container images to always point to the corporate image registry.
• Set node and pod affinity and anti-affinity selectors to Deployments
• You can enforce anything that you want to see or not to see in configs
I need to control other pod fields or
any fields in other resource? How
can I achieve that?
The answer is:
Open Policy Agent (Gatekeeper)
Example: enforce to use only allowed container registries
Open Policy Agent (Gatekeeper)
Example: enforce to use only allowed container registries
The other examples can be found here:
https://github.com/open-policy-agent/gatekeeper/tree/master/demo
Network Policy
By default, namespaces are not automatically isolated.
For that we have networking policies and RBAC.
With this simple config you will
isolate NS from other NS
Network Policy
Network policy will not work with default CNI from
AWS EKS. You need to install Calico.
With this simple config you will allow
traffic from specific namespace
Network Policy
With AWS EKS CNI you can use different security
groups per pod which makes network policy redundant
With this simple config you will allow
traffic to a specific port
You can also specify protocol.
Secrets
Where do I version control my secrets?
What is solution for this?
• Paper/USB/CDR two fireproof safes?
• Vault (or actually Consul)?
Secrets
Where do I version control my secrets?
What is solution for this?
• Sealed Secrets (a Kubernetes controller and a tool for
one-way encrypted Secrets):​
https://github.com/bitnami-labs/sealed-secrets
• Git Crypt - transparent file encryption in git:​
https://www.agwa.name/projects/git-crypt/
Sealed Secrets example
As you can see the value of the secret is enrypted
Sealed Secrets example
The controller will unseal that into something like:
Securing the Cluster
API Server
By default, the API server will listen on what is rightfully
port 8080
• Close the insecure port by arg in API server’s --insecure-port flag to 0
• And --insecure-bind-address is not set.
Any requests to this port bypass authentication and authorization
checks.
Securing the Cluster
etcd
The etcd backend database is a critical component and the
to secure within the cluster.
Close the insecure port by arg in API server’s --insecure-port flag to
0
• And --insecure-bind-address is not set.
etcd server should be configured to only trust certificates assigned to API
servers
Securing the Cluster
Kubelet
The kubelet is the agent that is responsible launching pods (not
Check this parameters:
• Disable anonymous access with --anonymous-auth=false
• Ensure that requests are authorized by setting --
other than AlwaysAllow
Securing the Cluster
Kubernetes Dashboard
The Dashboard has historically been used by attackers to gain
Kubernetes clusters.
Check this parameters:
• Allow only authenticated access. Only known users should be able
Dashboard.
• Use RBAC. Limit the privileges that users have so they can
they need to.
• Don’t expose your Dashboard to the public internet
• Unless you really know what you’re doing.
Securing the Cluster
Protocol Direction Port Range Purpose
TCP Inbound 6443 or 8080 if not disabled Kubernetes API server
TCP Inbound 2379-2380 etcd server client API
TCP Inbound 10250 kubelet API
TCP Inbound 10251 kube-scheduler
TCP Inbound 10252 kube-controller-manager
TCP Inbound 10258 cloud-controller-manager (optional)
The following table lists the control plane ports and services.
You can try to curl on each port to check if it’s secured.
04
Other Tooling to help
Kubescape
Kubescape is the first tool for testing if Kubernetes deployed securely
Source: https://github.com/armosec/kubescape
Kube-bench
The same tool as Kubescape but could be deployed as CronJob and executed
on regular bases
Source: https://github.com/aquasecurity/kube-bench
Kubesec
kubectl plugin for scanning Kubernetes pods,
deployments, daemonsets and statefulsets
Source: https://github.com/controlplaneio/kubectl-kubesec
Suggests what should be improved or changed
Kubeaudit
kubeaudit is a command line tool to audit Kubernetes clusters for various security
concerns, such as:
• run as non-root
• use a read-only root filesystem
• drop scary capabilities, don't add new ones
• don't run privileged
Source: https://github.com/Shopify/kubeaudit
Ksniff
A kubectl plugin that utilize tcpdump and Wireshark to start a remote capture
on any pod in your Kubernetes cluster.
Source: https://github.com/eldadru/ksniff
Demo Time
Demo Time
THANK
YOU!
Let's get connected!

More Related Content

What's hot (20)

PPTX
Kubernetes Introduction
Martin Danielsson
 
PDF
Open shift 4 infra deep dive
Winton Winton
 
PDF
Kubernetes Webinar - Using ConfigMaps & Secrets
Janakiram MSV
 
PPTX
Kubernetes Security
Karthik Gaekwad
 
PPTX
Kubernetes 101
Stanislav Pogrebnyak
 
PDF
Kubernetes - A Comprehensive Overview
Bob Killen
 
PDF
Kubernetes
erialc_w
 
PDF
Introduction to kubernetes
Raffaele Di Fazio
 
PDF
Getting Started with Kubernetes
VMware Tanzu
 
PDF
CKA Certified Kubernetes Administrator Notes
Adnan Rashid
 
ODP
Kubernetes Architecture
Knoldus Inc.
 
PDF
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Edureka!
 
PDF
Hands-On Introduction to Kubernetes at LISA17
Ryan Jarvinen
 
PPTX
Kubernetes workshop
Raúl Requero García
 
PDF
Kubernetes 101
Crevise Technologies
 
PDF
Kubernetes Architecture and Introduction
Stefan Schimanski
 
ODP
Openshift Container Platform
DLT Solutions
 
PDF
OpenShift 4 installation
Robert Bohne
 
PPTX
DevOps with Kubernetes
EastBanc Tachnologies
 
PDF
Cluster management with Kubernetes
Satnam Singh
 
Kubernetes Introduction
Martin Danielsson
 
Open shift 4 infra deep dive
Winton Winton
 
Kubernetes Webinar - Using ConfigMaps & Secrets
Janakiram MSV
 
Kubernetes Security
Karthik Gaekwad
 
Kubernetes 101
Stanislav Pogrebnyak
 
Kubernetes - A Comprehensive Overview
Bob Killen
 
Kubernetes
erialc_w
 
Introduction to kubernetes
Raffaele Di Fazio
 
Getting Started with Kubernetes
VMware Tanzu
 
CKA Certified Kubernetes Administrator Notes
Adnan Rashid
 
Kubernetes Architecture
Knoldus Inc.
 
Kubernetes Architecture | Understanding Kubernetes Components | Kubernetes Tu...
Edureka!
 
Hands-On Introduction to Kubernetes at LISA17
Ryan Jarvinen
 
Kubernetes workshop
Raúl Requero García
 
Kubernetes 101
Crevise Technologies
 
Kubernetes Architecture and Introduction
Stefan Schimanski
 
Openshift Container Platform
DLT Solutions
 
OpenShift 4 installation
Robert Bohne
 
DevOps with Kubernetes
EastBanc Tachnologies
 
Cluster management with Kubernetes
Satnam Singh
 

Similar to Kubernetes and container security (20)

PPTX
12 Ways Not to get 'Hacked' your Kubernetes Cluster
Suman Chakraborty
 
PPTX
Secure development on Kubernetes by Andreas Falk
SBA Research
 
PPTX
The State of Kubernetes Security
Jimmy Mesta
 
PDF
Automate Your Container Deployments Securely
DevOps.com
 
PDF
Docker London: Container Security
Phil Estes
 
PDF
Securing Containerized Applications: A Primer
Phil Estes
 
PPTX
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
PDF
GDG SLK - Why should devs care about container security.pdf
James Anderson
 
PDF
Securing Containerized Applications: A Primer
Phil Estes
 
PDF
How Secure Is Your Container? ContainerCon Berlin 2016
Phil Estes
 
PDF
Docker security 101 (CfgMgmtCamp 2019)
Frank Louwers
 
PDF
Containerizing your Security Operations Center
Jimmy Mesta
 
PPTX
Three Years of Lessons Running Potentially Malicious Code Inside Containers
Ben Hall
 
PDF
Kubernetes 101 for_penetration_testers_-_null_mumbai
n|u - The Open Security Community
 
PPTX
Security best practices for kubernetes deployment
Aqua Security
 
PPTX
Security best practices for kubernetes deployment
Michael Cherny
 
PDF
Cloud Native TLV Meetup: Securing Containerized Applications Primer
Phil Estes
 
PDF
Hacking into your containers, and how to stop it!
Eric Smalling
 
PDF
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
Eric Smalling
 
PDF
Policy as code what helm developers need to know about security
LibbySchulze
 
12 Ways Not to get 'Hacked' your Kubernetes Cluster
Suman Chakraborty
 
Secure development on Kubernetes by Andreas Falk
SBA Research
 
The State of Kubernetes Security
Jimmy Mesta
 
Automate Your Container Deployments Securely
DevOps.com
 
Docker London: Container Security
Phil Estes
 
Securing Containerized Applications: A Primer
Phil Estes
 
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
GDG SLK - Why should devs care about container security.pdf
James Anderson
 
Securing Containerized Applications: A Primer
Phil Estes
 
How Secure Is Your Container? ContainerCon Berlin 2016
Phil Estes
 
Docker security 101 (CfgMgmtCamp 2019)
Frank Louwers
 
Containerizing your Security Operations Center
Jimmy Mesta
 
Three Years of Lessons Running Potentially Malicious Code Inside Containers
Ben Hall
 
Kubernetes 101 for_penetration_testers_-_null_mumbai
n|u - The Open Security Community
 
Security best practices for kubernetes deployment
Aqua Security
 
Security best practices for kubernetes deployment
Michael Cherny
 
Cloud Native TLV Meetup: Securing Containerized Applications Primer
Phil Estes
 
Hacking into your containers, and how to stop it!
Eric Smalling
 
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
Eric Smalling
 
Policy as code what helm developers need to know about security
LibbySchulze
 
Ad

Recently uploaded (20)

PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Digital Circuits, important subject in CS
contactparinay1
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Ad

Kubernetes and container security

  • 1. Kubernetes & Container Security by Volodymyr Shynkar Senior Lead DevOps Engineer 2021 | intellias.com
  • 2. [devops@stage ~]$ cat ABOUT_ME.md • 6+ years of commercial DevOps experience. Overall 8+ years of Engineering • Member of Technology Office • Member of the Center of Excellence • Successfully migrated, rolled out, consulted over 15 projects in the healthcare, gambling, automotive, e-commerce industries • Certified SAFe Agile Software Engineer • Addicted to IoT and Smart Home • Cyclist, promoter of a healthy lifestyle Volodymyr Shynkar Senior Lead DevOps Engineer at Intellias [devops@stage ~]$
  • 3. Agenda Overview Container Security Kubernetes Security Other Tooling to help
  • 5. Will talk about: • Scan containers and Pods for vulnerabilities or misconfigurations. • Run containers and Pods with the least privileges possible. • Use network separation to control the amount of damage a compromise can cause. • Use firewalls to limit unneeded network connectivity and encryption to protect confidentiality. • Use strong authentication and authorization to limit user and administrator access as well as to limit the attack surface. • Periodically review all Kubernetes settings and use vulnerability scans to help ensure risks are appropriately accounted for and security patches are applied.
  • 6. Attack Surface Analysis for: • Cloud and Host • Kubernetes Cluster • Container (images and running) Goal: Reduce the attack surface
  • 7. Attack Surface – Cloud & Host There are at least few things that you do yo achive base security level: • Run instances in private network • Expose services only through external services like LB or Proxy • Block all external traffic except exposed ports, like 80, 443 • Do not expose SSH. Try to use SSM instead. • Minimize privilege to applications running on the host • Optional: for HTTP traffic, use WAF if posiable Goal: Follow “Principle of least privilege” Managed K8s services already goes with most of this features enabled
  • 9. Dockerfile best practices 1.Avoid unnecessary privileges. 1. Avoid running containers as root. 2. Don’t bind to a specific UID. 3. Make executables owned by root and not writable. 2.Reduce attack surface. 1. Leverage multistage builds. 2. Use distroless images, or build your own from scratch. 3. Update your images frequently. 4. Watch out for exposed ports. 3.Prevent confidential data leaks. 1. Never put secrets or credentials in Dockerfile instructions. 2. Prefer COPY over ADD. 3. Be aware of the Docker context, and use .dockerignore. 4.Others. 1. Reduce the number of layers, and order them intelligently. 2. Add metadata and labels. 3. Leverage linters to automatize checks. 4. Scan your images locally during development. 5.Beyond image building. 1. Protect the docker socket and TCP connections. 2. Sign your images, and verify them on runtime. 3. Avoid tag mutability. 4. Don’t run your environment as root. 5. Include a health check. 6. Restrict your application capabilities. Source: https://sysdig.com/blog/dockerfile-best-practices/
  • 10. Let’s start from scratch First steps Start from your app • unprivileged user (rootless) • read-only • no shell, cat, grep, less, tail, echo, etc • focus on fewer data stored inside the container - only app, no source code, and build dependencies • no backed secrets or bind through volume or encrypted Seriously :)
  • 11. Let’s start from scratch First steps Start from your app • unprivileged user (rootless) • read-only • no shell, cat, grep, less, tail, echo, etc • focus on fewer data stored inside the container - only app, no source code, and build dependencies • no backed secrets or bind through volume or encrypted Serious :)
  • 12. Let’s start from scratch First steps Start from your app • unprivileged user (rootless) • read-only • no shell, cat, grep, less, tail, echo, etc • focus on fewer data stored inside the container - only app, no source code, and build dependencies • no backed secrets or bind through volume or encrypted Seriously :)
  • 13. Let’s start from scratch First steps Start from your app • unprivileged user (rootless) • read-only • no shell, cat, grep, less, tail, echo, etc • focus on fewer data stored inside the container - only app, no source code, and build dependencies • no backed secrets or bind through volume or encrypted Seriously :) More examples: https://github.com/GoogleContainerTools/distroless
  • 14. Let’s start from scratch First steps Start from your app • unprivileged user (rootless) • read-only • no shell, cat, grep, less, tail, echo, etc • focus on fewer data stored inside the container - only app, no source code, and build dependencies • no backed secrets or bind through volume or encrypted Seriously :)
  • 15. Let’s start from scratch First steps Start from your app • unprivileged user (rootless) • read-only • no shell, cat, grep, less, tail, echo, etc • focus on fewer data stored inside the container - only app, no source code, and build dependencies • no backed secrets or bind through volume or encrypted Seriously :)
  • 16. Scan your image Docker and Snyk recently entered into a partnership to provide container vulnerability scanning. Alternative Source: https://www.docker.com/blog/bringing-docker-scan-to-linux/
  • 18. Next to discuss: • Deployment to the cluster • Pod Security Policy • Open Policy Agent • Network Policy • Secrets • Securing the Cluster Kubernetes Hardening Remember: follow the “Principle of least privilege”
  • 19. Deployment to the cluster kubectl apply –f my_app.yaml helm install my_app charts/my_app
  • 20. How to automate deploy? There are two approaches: • Push-based • Regular CI (Jenkins, Gitlab, GitHub, CircleCI)
  • 21. How to automate deploy? There are two approaches: • Pull-based • GitOps strategy (ArgoCD, Flux)
  • 22. How to manage manage By only two resources: AppProject and Application
  • 23. By only two resources: AppProject and Application How to manage manage
  • 24. How to grant access ArgoCD provided with powerful UI • Embedded security features • Support of SAML/OKTA. • Enhanced experience • Role-based • Easy to use
  • 25. Pod Security Policy PSP are one way to control the security-related attributes of pods, including container privilege levels. • Do not run application processes as root • Do not allow privilege escalation • Use a read-only root filesystem • Use the default (masked) /proc filesystem mount • Do not use the host network or process space • Drop unused and unnecessary Linux capabilities • Service Account control
  • 26. Pod Security Policy When a PSP resource is created, it does nothing. You need to authorize using RBAC!
  • 27. Pod Security Policies is going to be marked as deprecated since v1.21 and will be removed in v1.25 The PSP Replacement Policy is the new enhancement: https://github.com/kubernetes/enhancements/tree/master/keps/sig-auth/2579-psp-replacement PSP Replacement Policy The way PSPs are applied to Pods has proven confusing to nearly everyone that has attempted to use them.
  • 28. Open Policy Agent (Gatekeeper) Gatekeeper controller provides you ability to: • Required labels • Required resources section • Mutate container images to always point to the corporate image registry. • Set node and pod affinity and anti-affinity selectors to Deployments • You can enforce anything that you want to see or not to see in configs I need to control other pod fields or any fields in other resource? How can I achieve that? The answer is:
  • 29. Open Policy Agent (Gatekeeper) Example: enforce to use only allowed container registries
  • 30. Open Policy Agent (Gatekeeper) Example: enforce to use only allowed container registries The other examples can be found here: https://github.com/open-policy-agent/gatekeeper/tree/master/demo
  • 31. Network Policy By default, namespaces are not automatically isolated. For that we have networking policies and RBAC. With this simple config you will isolate NS from other NS
  • 32. Network Policy Network policy will not work with default CNI from AWS EKS. You need to install Calico. With this simple config you will allow traffic from specific namespace
  • 33. Network Policy With AWS EKS CNI you can use different security groups per pod which makes network policy redundant With this simple config you will allow traffic to a specific port You can also specify protocol.
  • 34. Secrets Where do I version control my secrets? What is solution for this? • Paper/USB/CDR two fireproof safes? • Vault (or actually Consul)?
  • 35. Secrets Where do I version control my secrets? What is solution for this? • Sealed Secrets (a Kubernetes controller and a tool for one-way encrypted Secrets):​ https://github.com/bitnami-labs/sealed-secrets • Git Crypt - transparent file encryption in git:​ https://www.agwa.name/projects/git-crypt/
  • 36. Sealed Secrets example As you can see the value of the secret is enrypted
  • 37. Sealed Secrets example The controller will unseal that into something like:
  • 38. Securing the Cluster API Server By default, the API server will listen on what is rightfully port 8080 • Close the insecure port by arg in API server’s --insecure-port flag to 0 • And --insecure-bind-address is not set. Any requests to this port bypass authentication and authorization checks.
  • 39. Securing the Cluster etcd The etcd backend database is a critical component and the to secure within the cluster. Close the insecure port by arg in API server’s --insecure-port flag to 0 • And --insecure-bind-address is not set. etcd server should be configured to only trust certificates assigned to API servers
  • 40. Securing the Cluster Kubelet The kubelet is the agent that is responsible launching pods (not Check this parameters: • Disable anonymous access with --anonymous-auth=false • Ensure that requests are authorized by setting -- other than AlwaysAllow
  • 41. Securing the Cluster Kubernetes Dashboard The Dashboard has historically been used by attackers to gain Kubernetes clusters. Check this parameters: • Allow only authenticated access. Only known users should be able Dashboard. • Use RBAC. Limit the privileges that users have so they can they need to. • Don’t expose your Dashboard to the public internet • Unless you really know what you’re doing.
  • 42. Securing the Cluster Protocol Direction Port Range Purpose TCP Inbound 6443 or 8080 if not disabled Kubernetes API server TCP Inbound 2379-2380 etcd server client API TCP Inbound 10250 kubelet API TCP Inbound 10251 kube-scheduler TCP Inbound 10252 kube-controller-manager TCP Inbound 10258 cloud-controller-manager (optional) The following table lists the control plane ports and services. You can try to curl on each port to check if it’s secured.
  • 44. Kubescape Kubescape is the first tool for testing if Kubernetes deployed securely Source: https://github.com/armosec/kubescape
  • 45. Kube-bench The same tool as Kubescape but could be deployed as CronJob and executed on regular bases Source: https://github.com/aquasecurity/kube-bench
  • 46. Kubesec kubectl plugin for scanning Kubernetes pods, deployments, daemonsets and statefulsets Source: https://github.com/controlplaneio/kubectl-kubesec Suggests what should be improved or changed
  • 47. Kubeaudit kubeaudit is a command line tool to audit Kubernetes clusters for various security concerns, such as: • run as non-root • use a read-only root filesystem • drop scary capabilities, don't add new ones • don't run privileged Source: https://github.com/Shopify/kubeaudit
  • 48. Ksniff A kubectl plugin that utilize tcpdump and Wireshark to start a remote capture on any pod in your Kubernetes cluster. Source: https://github.com/eldadru/ksniff

Editor's Notes

  • #20: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda
  • #26: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda
  • #27: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda
  • #28: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda
  • #29: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda
  • #30: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda
  • #31: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda
  • #32: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda
  • #33: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda
  • #34: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda
  • #45: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda
  • #46: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda
  • #47: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda
  • #48: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda
  • #49: List of tools: Kubeflow, Apache Airflow, AWS Batch, AWS Lambda