Security best practices for kubernetes deployment

Copyright @ 2017 Aqua Security Software Ltd. All Rights Reserved.
Security Best Practices for
Kubernetes Deployment
Michael Cherny
Head of Research, Aqua Security
2
WHO AM I
 Head of Security Research at Aqua Security, a leader
in container security
 20 years of building security products, development
and research
 Held senior security research positions at Microsoft,
Aorato
and Imperva.
 Presented at security conferences, among them,
BlackHat Europe, RSA Europe and Virus Bulleting.
3
BUILD SECURITY ALIGNED WITH DEVOPS
Build Ship Cluster
Environment
Networking
and Runtime
Monitoring
Productio
n
Dev. / Testing
 
BUILD AND SHIP
5
BUILD AND SHIP
 Ensure That Only Authorized Images are Used in Your
Environment
 Ensure That Images Are Free of Vulnerabilities
 Integrate Security into your CI/CD pipeline
6
SECURITY INTEGRATED WITH CI/CD
Build
• Only vetted code (approved for production) is
used for building the images
ShipTest
 
7
SECURITY INTEGRATED WITH CI/CD
Build
• Implement Continuous Security Vulnerability
Scanning
• Regularly Apply Security Updates to Your
Environment
ShipTest
 
8
SECURITY INTEGRATED WITH CI/CD
Build
• Use private registries to store your approved
images - make sure you only push approved
images to these registries
ShipTest
 
CLUSTER ENVIRONMENT
10
SSH
LIMIT DIRECT ACCESS TO KUBERNETES
NODES
 Limit SSH access to Kubernetes nodes
 Ask users to use “kubectl exec”
11
CONSIDER KUBERNETES AUTHORIZATION
PLUGINS
 Enables define fine-grained-access control rules
 Namespaces
 Containers
 Operations
 ABAC mode
 RBAC mode
 Webhook mode
 Custom mode
12
CREATE ADMINISTRATIVE BOUNDARIES
BETWEEN RESOURCES
 Limits the damage of mistake or malicious intent
 Partition resources into logical groups
 Use Kubernetes namespaces to facilitate resource
segregation
 Kubernetes Authorization plugins to segregate user’s
access to namespace resources
13
CREATE ADMINISTRATIVE BOUNDARIES
BETWEEN RESOURCES
 Example: allow ‘alice’ to read pods from namespace
‘fronto’
{
"apiVersion": "abac.authorization.kubernetes.io/v1beta1",
"kind": "Policy",
"spec": {
"user": "alice",
"namespace": "fronto",
"resource": "pods",
"readonly": true
}
}
14
DEFINE RESOURCE QUOTA
 Resource-unbound containers in shared cluster are
bad practice
 Create resource quota policies
 Pods
 CPUs
 Memory
 Etc.
 Assigned to namespace
15
DEFINE RESOURCE QUOTA EXAMPLE
 computer-resource.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
name: compute-resources
spec:
hard:
pods: "4“
requests.cpu: "1“
requests.memory: 1Gi
limits.cpu: "2“
limits.memory: 2Gi
 kubectl create -f ./compute-resources.yaml --
namespace=myspace
16
SAFELY DISTRIBUTE YOUR SECRETS
 Storing sensitive data in docker file, POD definition
etc. is not safe
 Centrally and securely stored secrets
 Manage user access
 Manage containers/pods access
 Store securely
 Facilitate secrets expiry and rotation
 Etc.
17
KUBERNETES SECRETS
 Secret object
 As file
 As Environment variable
 Risks
 Secrets stored in plain text
 Is at rest
 No separation of duties: operator can see secret value
 Secrets are available, even if there is no container using it
18
KUBERNETES SECRETS - EXAMPLE
 echo -n "admin" > ./username.txt
echo -n "1f2d1e2e67df" > ./password.txt
 kubectl create secret generic db-user-pass --from-
file=./username.txt --from-file=./password.txt
secret "db-user-pass" created
 kubectl get secrets
 Kubectl describe secrets/db-user-pass
19
KUBERNETES SECRETS - EXAMPLE
 It call also be done manually
 echo -n "admin" | base64
YWRtaW4=
 echo -n "1f2d1e2e67df" | base64
MWYyZDFlMmU2N2Rm
apiVersion: v1
kind: Secret
metadata:
name: mysecret
type: Opaque
data:
username: YWRtaW4=
password: MWYyZDFlMmU2N2Rm
 kubectl create -f ./secret.yaml
NETWORKING
21
IMPLEMENT NETWORK SEGMENTATION
 “Good neighbor” compromised application is a door
open into cluster
 Network segmentation
 Ensures that container can communicate only with
whom it must
22
IMPLEMENT NETWORK SEGMENTATION
 Cross-cluster segmentation can be achieved using
firewall rules
 “dynamic” nature of container network identities
makes container network segmentation a true
challenge
 Kubernetes Network SIG works on pod-to-pod
network policies
 Currently only ingress policies can be defined
23
IMPLEMENT NETWORK SEGMENTATION:
EXAMPLE
 Enable using an annotation on the Namespace
kind: Namespace
apiVersion: v1
metadata:
annotations:
net.beta.kubernetes.io/network-policy: |
{
"ingress": {
"isolation": "DefaultDeny"
}
}
kubectl annotate ns <namespace> "net.beta.kubernetes.io/network-policy={"ingress": {"isolation": "DefaultDeny"}}"
24
IMPLEMENT NETWORK SEGMENTATION:
EXAMPLE
apiVersion: extensions/v1beta1
kind: NetworkPolicy
metadata:
name: test-network-policy
namespace: default
spec:
podSelector:
matchLabels:
role: db
ingress:
- from:
- namespaceSelector:
matchLabels:
project: myproject
- podSelector:
matchLabels:
role: frontend
ports:
- protocol: tcp
port: 6379
kubectl create -f policy.yaml
RUNTIME
26
RUNTIME
 Implement “least privileges” principal
 Security Context control security parameters to be assigned
 Pod
 Containers
 Pod Security Policy
 Consider Kubernetes admission controllers:
 “DenyEscalatingExec” – for containers/pods with elevated
privileges
 “ImagePolicyWebhook” – Kubernetes support to plug external
image reviewer
 “AlwaysPullImages” – in multitenant cluster
27
SECURITY CONTEXT
Security Context Setting Description
SecurityContext->runAsNonRoot Indicates that containers should run as non-root
user
SecurityContext->Capabilities Controls the Linux capabilities assigned to the
container.
SecurityContext->readOnlyRootFilesystem Controls whether a container will be able to write
into the root filesystem.
PodSecurityContext->runAsNonRoot Prevents running a container with ‘root’ user as part
of the pod
28
SECURITY CONTEXT: EXAMPLE
apiVersion: v1
kind: Pod
metadata:
name: hello-world
spec:
containers:
# specification of the pod’s containers
# ...
securityContext:
readOnlyRootFilesystem: true
runAsNonRoot: true
29
IMAGE POLICY WEBHOOK
 api.imagepolicy.v1alpha1.ImageReview object
describing the action
 Fields describing the containers being admitted, as
well as any pod annotations that match *.image-
policy.k8s.io/*
30
IMAGE POLICY WEBHOOK: EXAMPLE
{
"apiVersion":"imagepolicy.k8s.io/v1alpha1",
"kind":"ImageReview",
"spec":{
"containers":[
{
"image":"myrepo/myimage:v1“
},
{
"image":"myrepo/myimage@sha256:beb6bd6a68f114c1dc2ea4b28db81bdf91de202a9014972bec5e4d9171d
90ed“
}
],
"annotations":[
"mycluster.image-policy.k8s.io/ticket-1234": "break-glass“
],
"namespace":"mynamespace“
}
}
31
MONITORING AND VISIBILITY
 Log everything
 Cluster-based logging
 Log container activity into a central log hub.
 Use Fluentd agent on each node
 Ingested logs using
 Google Stackdriver Logging
 Elasticsearch
 Viewed with Kibana.
SUMMARY
33
SECURITY ALIGNED WITH DEVOPS
Build Ship Cluster
Environment
Networking
and Runtime
Monitoring
Productio
n
Dev. / Testing
Only vetted code can
be used for build
Scan images against
known vulnerabilities
Use private registries
Only approved images
are pushed
Only use kubectl
Fine-grained-access
control to resources
Create administrative
boundaries and assign
resource quotas
Manage your secrets
Implement “least
privileges” principal
Isolate container
networks in logical
application groups
Log everything
Integrates with SIEM
and monitoring
systems
 
THANK YOU
Michael Cherny
cherny@aquasec.com
@chernymi
https://www.aquasec.com
1 of 34

Recommended

Kubernetes deployment on bare metal with container linux by
Kubernetes deployment on bare metal with container linuxKubernetes deployment on bare metal with container linux
Kubernetes deployment on bare metal with container linuxmacchiang
1.1K views39 slides
K8s security best practices by
K8s security best practicesK8s security best practices
K8s security best practicesSharon Vendrov
3K views40 slides
Container Security Deep Dive & Kubernetes by
Container Security Deep Dive & Kubernetes Container Security Deep Dive & Kubernetes
Container Security Deep Dive & Kubernetes Aqua Security
2.6K views34 slides
Kubernetes - Security Journey by
Kubernetes - Security JourneyKubernetes - Security Journey
Kubernetes - Security JourneyJerry Jalava
1.2K views43 slides
How abusing the Docker API led to remote code execution same origin bypass an... by
How abusing the Docker API led to remote code execution same origin bypass an...How abusing the Docker API led to remote code execution same origin bypass an...
How abusing the Docker API led to remote code execution same origin bypass an...Aqua Security
6.1K views102 slides
Multi-Container Apps spanning Docker, Mesos and OpenStack by
Multi-Container Apps spanning Docker, Mesos and OpenStackMulti-Container Apps spanning Docker, Mesos and OpenStack
Multi-Container Apps spanning Docker, Mesos and OpenStackDocker, Inc.
1.8K views31 slides

More Related Content

What's hot

K8s security best practices by
K8s security best practicesK8s security best practices
K8s security best practicesSharon Vendrov
523 views40 slides
Building Clustered Applications with Kubernetes and Docker by
Building Clustered Applications with Kubernetes and DockerBuilding Clustered Applications with Kubernetes and Docker
Building Clustered Applications with Kubernetes and DockerSteve Watt
4.8K views13 slides
Container Security by
Container SecurityContainer Security
Container SecurityJie Liau
577 views33 slides
Effective Data Pipelines with Docker & Jenkins - Brian Donaldson by
Effective Data Pipelines with Docker & Jenkins - Brian DonaldsonEffective Data Pipelines with Docker & Jenkins - Brian Donaldson
Effective Data Pipelines with Docker & Jenkins - Brian DonaldsonDocker, Inc.
2.6K views29 slides
A brief study on Kubernetes and its components by
A brief study on Kubernetes and its componentsA brief study on Kubernetes and its components
A brief study on Kubernetes and its componentsRamit Surana
5.8K views34 slides
Kubernetes Security by
Kubernetes SecurityKubernetes Security
Kubernetes Securityinovex GmbH
1K views31 slides

What's hot(20)

Building Clustered Applications with Kubernetes and Docker by Steve Watt
Building Clustered Applications with Kubernetes and DockerBuilding Clustered Applications with Kubernetes and Docker
Building Clustered Applications with Kubernetes and Docker
Steve Watt4.8K views
Container Security by Jie Liau
Container SecurityContainer Security
Container Security
Jie Liau577 views
Effective Data Pipelines with Docker & Jenkins - Brian Donaldson by Docker, Inc.
Effective Data Pipelines with Docker & Jenkins - Brian DonaldsonEffective Data Pipelines with Docker & Jenkins - Brian Donaldson
Effective Data Pipelines with Docker & Jenkins - Brian Donaldson
Docker, Inc.2.6K views
A brief study on Kubernetes and its components by Ramit Surana
A brief study on Kubernetes and its componentsA brief study on Kubernetes and its components
A brief study on Kubernetes and its components
Ramit Surana5.8K views
Kubernetes Security by inovex GmbH
Kubernetes SecurityKubernetes Security
Kubernetes Security
inovex GmbH1K views
Kubernetes Summit 2019 - Harden Your Kubernetes Cluster by smalltown
Kubernetes Summit 2019 - Harden Your Kubernetes ClusterKubernetes Summit 2019 - Harden Your Kubernetes Cluster
Kubernetes Summit 2019 - Harden Your Kubernetes Cluster
smalltown 1.6K views
Kubernetes - how to orchestrate containers by inovex GmbH
Kubernetes - how to orchestrate containersKubernetes - how to orchestrate containers
Kubernetes - how to orchestrate containers
inovex GmbH1.5K views
Achieving CI/CD with Kubernetes by Ramit Surana
Achieving CI/CD with KubernetesAchieving CI/CD with Kubernetes
Achieving CI/CD with Kubernetes
Ramit Surana48.8K views
Cloud networking deep dive by amylynn11
Cloud networking deep diveCloud networking deep dive
Cloud networking deep dive
amylynn111K views
CI / CD / CS - Continuous Security in Kubernetes by Sysdig
CI / CD / CS - Continuous Security in KubernetesCI / CD / CS - Continuous Security in Kubernetes
CI / CD / CS - Continuous Security in Kubernetes
Sysdig 1.2K views
Platform as a Service with Kubernetes and Mesos by Miguel Zuniga
Platform as a Service with Kubernetes and Mesos Platform as a Service with Kubernetes and Mesos
Platform as a Service with Kubernetes and Mesos
Miguel Zuniga3.1K views
Docker London: Container Security by Phil Estes
Docker London: Container SecurityDocker London: Container Security
Docker London: Container Security
Phil Estes16.9K views
Moving to Kubernetes - Tales from SoundCloud by Tobias Schmidt
Moving to Kubernetes - Tales from SoundCloudMoving to Kubernetes - Tales from SoundCloud
Moving to Kubernetes - Tales from SoundCloud
Tobias Schmidt3.6K views
Docker Online Meetup: Infrakit update and Q&A by Docker, Inc.
Docker Online Meetup: Infrakit update and Q&ADocker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&A
Docker, Inc.6.7K views
Continuous delivery of microservices with kubernetes - Quintor 27-2-2017 by Arjen Wassink
Continuous delivery of microservices with kubernetes - Quintor 27-2-2017Continuous delivery of microservices with kubernetes - Quintor 27-2-2017
Continuous delivery of microservices with kubernetes - Quintor 27-2-2017
Arjen Wassink889 views
Kubernetes - Sailing a Sea of Containers by Kel Cecil
Kubernetes - Sailing a Sea of ContainersKubernetes - Sailing a Sea of Containers
Kubernetes - Sailing a Sea of Containers
Kel Cecil1.4K views
Deploying Kubernetes without scaring off your security team - KubeCon 2017 by Major Hayden
Deploying Kubernetes without scaring off your security team - KubeCon 2017Deploying Kubernetes without scaring off your security team - KubeCon 2017
Deploying Kubernetes without scaring off your security team - KubeCon 2017
Major Hayden1.8K views

Viewers also liked

Extend and build on Kubernetes by
Extend and build on KubernetesExtend and build on Kubernetes
Extend and build on KubernetesStefan Schimanski
4.8K views49 slides
Docker Security: Are Your Containers Tightly Secured to the Ship? by
Docker Security: Are Your Containers Tightly Secured to the Ship?Docker Security: Are Your Containers Tightly Secured to the Ship?
Docker Security: Are Your Containers Tightly Secured to the Ship?Michael Boelen
8.7K views44 slides
Atomic CLI scan by
Atomic CLI scanAtomic CLI scan
Atomic CLI scanLalatendu Mohanty
4.2K views19 slides
Open Source Tools for Container Security and Compliance @Docker LA Meetup 2/13 by
Open Source Tools for Container Security and Compliance @Docker LA Meetup 2/13Open Source Tools for Container Security and Compliance @Docker LA Meetup 2/13
Open Source Tools for Container Security and Compliance @Docker LA Meetup 2/13Zach Hill
858 views18 slides
Practical Approaches to Container Security by
Practical Approaches to Container SecurityPractical Approaches to Container Security
Practical Approaches to Container SecurityShea Stewart
524 views12 slides
Understanding container security by
Understanding container securityUnderstanding container security
Understanding container securityJohn Kinsella
2.7K views45 slides

Viewers also liked(20)

Docker Security: Are Your Containers Tightly Secured to the Ship? by Michael Boelen
Docker Security: Are Your Containers Tightly Secured to the Ship?Docker Security: Are Your Containers Tightly Secured to the Ship?
Docker Security: Are Your Containers Tightly Secured to the Ship?
Michael Boelen8.7K views
Open Source Tools for Container Security and Compliance @Docker LA Meetup 2/13 by Zach Hill
Open Source Tools for Container Security and Compliance @Docker LA Meetup 2/13Open Source Tools for Container Security and Compliance @Docker LA Meetup 2/13
Open Source Tools for Container Security and Compliance @Docker LA Meetup 2/13
Zach Hill858 views
Practical Approaches to Container Security by Shea Stewart
Practical Approaches to Container SecurityPractical Approaches to Container Security
Practical Approaches to Container Security
Shea Stewart524 views
Understanding container security by John Kinsella
Understanding container securityUnderstanding container security
Understanding container security
John Kinsella2.7K views
Why You Need to Rethink Container Security by FlawCheck
Why You Need to Rethink Container SecurityWhy You Need to Rethink Container Security
Why You Need to Rethink Container Security
FlawCheck594 views
How GitLab and HackerOne help organizations innovate faster without compromis... by HackerOne
How GitLab and HackerOne help organizations innovate faster without compromis...How GitLab and HackerOne help organizations innovate faster without compromis...
How GitLab and HackerOne help organizations innovate faster without compromis...
HackerOne6.9K views
ContainerDays NYC 2016: "The Secure Introduction Problem: Getting Secrets Int... by DynamicInfraDays
ContainerDays NYC 2016: "The Secure Introduction Problem: Getting Secrets Int...ContainerDays NYC 2016: "The Secure Introduction Problem: Getting Secrets Int...
ContainerDays NYC 2016: "The Secure Introduction Problem: Getting Secrets Int...
DynamicInfraDays2.4K views
Veer's Container Security by Jim Barlow
Veer's Container SecurityVeer's Container Security
Veer's Container Security
Jim Barlow1K views
Docker Security workshop slides by Docker, Inc.
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
Docker, Inc.5.3K views
Introduction to Infrastructure as Code & Automation / Introduction to Chef by Nathen Harvey
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Nathen Harvey911 views
AWS Security Architecture - Overview by Sai Kesavamatham
AWS Security Architecture - OverviewAWS Security Architecture - Overview
AWS Security Architecture - Overview
Sai Kesavamatham3.6K views
AWS Security Best Practices and Design Patterns by Amazon Web Services
AWS Security Best Practices and Design PatternsAWS Security Best Practices and Design Patterns
AWS Security Best Practices and Design Patterns
Amazon Web Services15.6K views
Monitoring, Logging and Tracing on Kubernetes by Martin Etmajer
Monitoring, Logging and Tracing on KubernetesMonitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on Kubernetes
Martin Etmajer6.6K views
Docker Security - Secure Container Deployment on Linux by Michael Boelen
Docker Security - Secure Container Deployment on LinuxDocker Security - Secure Container Deployment on Linux
Docker Security - Secure Container Deployment on Linux
Michael Boelen3.4K views
Container Orchestration Wars by Karl Isenberg
Container Orchestration WarsContainer Orchestration Wars
Container Orchestration Wars
Karl Isenberg14.2K views

Similar to Security best practices for kubernetes deployment

Evolution of security strategies in K8s environments.pdf by
Evolution of security strategies in K8s environments.pdfEvolution of security strategies in K8s environments.pdf
Evolution of security strategies in K8s environments.pdfJose Manuel Ortega Candel
6 views41 slides
2015 DockerCon Using Docker in production at bity.com by
2015 DockerCon Using Docker in production at bity.com2015 DockerCon Using Docker in production at bity.com
2015 DockerCon Using Docker in production at bity.comMathieu Buffenoir
1.1K views36 slides
Who is afraid of privileged containers ? by
Who is afraid of privileged containers ?Who is afraid of privileged containers ?
Who is afraid of privileged containers ?Marko Bevc
65 views22 slides
DockerCon EU 2015: Trading Bitcoin with Docker by
DockerCon EU 2015: Trading Bitcoin with DockerDockerCon EU 2015: Trading Bitcoin with Docker
DockerCon EU 2015: Trading Bitcoin with DockerDocker, Inc.
5.9K views35 slides
Cloud Native TLV Meetup: Securing Containerized Applications Primer by
Cloud Native TLV Meetup: Securing Containerized Applications PrimerCloud Native TLV Meetup: Securing Containerized Applications Primer
Cloud Native TLV Meetup: Securing Containerized Applications PrimerPhil Estes
295 views18 slides
Deep Dive into Kubernetes - Part 2 by
Deep Dive into Kubernetes - Part 2Deep Dive into Kubernetes - Part 2
Deep Dive into Kubernetes - Part 2Imesh Gunaratne
1.7K views48 slides

Similar to Security best practices for kubernetes deployment(20)

2015 DockerCon Using Docker in production at bity.com by Mathieu Buffenoir
2015 DockerCon Using Docker in production at bity.com2015 DockerCon Using Docker in production at bity.com
2015 DockerCon Using Docker in production at bity.com
Mathieu Buffenoir1.1K views
Who is afraid of privileged containers ? by Marko Bevc
Who is afraid of privileged containers ?Who is afraid of privileged containers ?
Who is afraid of privileged containers ?
Marko Bevc65 views
DockerCon EU 2015: Trading Bitcoin with Docker by Docker, Inc.
DockerCon EU 2015: Trading Bitcoin with DockerDockerCon EU 2015: Trading Bitcoin with Docker
DockerCon EU 2015: Trading Bitcoin with Docker
Docker, Inc.5.9K views
Cloud Native TLV Meetup: Securing Containerized Applications Primer by Phil Estes
Cloud Native TLV Meetup: Securing Containerized Applications PrimerCloud Native TLV Meetup: Securing Containerized Applications Primer
Cloud Native TLV Meetup: Securing Containerized Applications Primer
Phil Estes295 views
Deep Dive into Kubernetes - Part 2 by Imesh Gunaratne
Deep Dive into Kubernetes - Part 2Deep Dive into Kubernetes - Part 2
Deep Dive into Kubernetes - Part 2
Imesh Gunaratne1.7K views
Integrating security testing into your container build pipeline - SDD308 - AW... by Amazon Web Services
Integrating security testing into your container build pipeline - SDD308 - AW...Integrating security testing into your container build pipeline - SDD308 - AW...
Integrating security testing into your container build pipeline - SDD308 - AW...
Amazon Web Services1.2K views
A Survey of Container Security in 2016: A Security Update on Container Platforms by Salman Baset
A Survey of Container Security in 2016: A Security Update on Container PlatformsA Survey of Container Security in 2016: A Security Update on Container Platforms
A Survey of Container Security in 2016: A Security Update on Container Platforms
Salman Baset496 views
Securing the Infrastructure and the Workloads of Linux Containers by Massimiliano Mattetti
Securing the Infrastructure and the Workloads of Linux ContainersSecuring the Infrastructure and the Workloads of Linux Containers
Securing the Infrastructure and the Workloads of Linux Containers
Cloud-native applications with Java and Kubernetes - Yehor Volkov by Kuberton
 Cloud-native applications with Java and Kubernetes - Yehor Volkov Cloud-native applications with Java and Kubernetes - Yehor Volkov
Cloud-native applications with Java and Kubernetes - Yehor Volkov
Kuberton393 views
Docker Runtime Security by Sysdig
Docker Runtime SecurityDocker Runtime Security
Docker Runtime Security
Sysdig 733 views
Breaking and fixing_your_dockerized_environments_owasp_appsec_usa2016 by Manideep Konakandla
Breaking and fixing_your_dockerized_environments_owasp_appsec_usa2016Breaking and fixing_your_dockerized_environments_owasp_appsec_usa2016
Breaking and fixing_your_dockerized_environments_owasp_appsec_usa2016
It's 2018. Are My Containers Secure Yet!? by Phil Estes
It's 2018. Are My Containers Secure Yet!?It's 2018. Are My Containers Secure Yet!?
It's 2018. Are My Containers Secure Yet!?
Phil Estes2.9K views
ClickHouse on Kubernetes! By Robert Hodges, Altinity CEO by Altinity Ltd
ClickHouse on Kubernetes! By Robert Hodges, Altinity CEOClickHouse on Kubernetes! By Robert Hodges, Altinity CEO
ClickHouse on Kubernetes! By Robert Hodges, Altinity CEO
Altinity Ltd2.1K views
Security Tips to run Docker in Production by Gianluca Arbezzano
Security Tips to run Docker in ProductionSecurity Tips to run Docker in Production
Security Tips to run Docker in Production
Gianluca Arbezzano2.9K views
AWS re:Invent 2016: Securing Container-Based Applications (CON402) by Amazon Web Services
AWS re:Invent 2016: Securing Container-Based Applications (CON402)AWS re:Invent 2016: Securing Container-Based Applications (CON402)
AWS re:Invent 2016: Securing Container-Based Applications (CON402)
Amazon Web Services2.3K views

Recently uploaded

Keep by
KeepKeep
KeepGeniusee
78 views10 slides
FOSSLight Community Day 2023-11-30 by
FOSSLight Community Day 2023-11-30FOSSLight Community Day 2023-11-30
FOSSLight Community Day 2023-11-30Shane Coughlan
6 views18 slides
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action by
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionGen Apps on Google Cloud PaLM2 and Codey APIs in Action
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionMárton Kodok
15 views55 slides
nintendo_64.pptx by
nintendo_64.pptxnintendo_64.pptx
nintendo_64.pptxpaiga02016
5 views7 slides
Top-5-production-devconMunich-2023-v2.pptx by
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptxTier1 app
6 views42 slides
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with... by
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...sparkfabrik
8 views46 slides

Recently uploaded(20)

FOSSLight Community Day 2023-11-30 by Shane Coughlan
FOSSLight Community Day 2023-11-30FOSSLight Community Day 2023-11-30
FOSSLight Community Day 2023-11-30
Shane Coughlan6 views
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action by Márton Kodok
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionGen Apps on Google Cloud PaLM2 and Codey APIs in Action
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action
Márton Kodok15 views
Top-5-production-devconMunich-2023-v2.pptx by Tier1 app
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptx
Tier1 app6 views
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with... by sparkfabrik
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
sparkfabrik8 views
Quality Engineer: A Day in the Life by John Valentino
Quality Engineer: A Day in the LifeQuality Engineer: A Day in the Life
Quality Engineer: A Day in the Life
John Valentino7 views
Introduction to Git Source Control by John Valentino
Introduction to Git Source ControlIntroduction to Git Source Control
Introduction to Git Source Control
John Valentino6 views
Dapr Unleashed: Accelerating Microservice Development by Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
Miroslav Janeski12 views
Top-5-production-devconMunich-2023.pptx by Tier1 app
Top-5-production-devconMunich-2023.pptxTop-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptx
Tier1 app8 views
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P... by NimaTorabi2
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...
NimaTorabi215 views
Airline Booking Software by SharmiMehta
Airline Booking SoftwareAirline Booking Software
Airline Booking Software
SharmiMehta7 views
predicting-m3-devopsconMunich-2023-v2.pptx by Tier1 app
predicting-m3-devopsconMunich-2023-v2.pptxpredicting-m3-devopsconMunich-2023-v2.pptx
predicting-m3-devopsconMunich-2023-v2.pptx
Tier1 app9 views
How Workforce Management Software Empowers SMEs | TraQSuite by TraQSuite
How Workforce Management Software Empowers SMEs | TraQSuiteHow Workforce Management Software Empowers SMEs | TraQSuite
How Workforce Management Software Empowers SMEs | TraQSuite
TraQSuite5 views
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... by Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke35 views
Ports-and-Adapters Architecture for Embedded HMI by Burkhard Stubert
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMI
Burkhard Stubert26 views

Security best practices for kubernetes deployment

  • 1. Copyright @ 2017 Aqua Security Software Ltd. All Rights Reserved. Security Best Practices for Kubernetes Deployment Michael Cherny Head of Research, Aqua Security
  • 2. 2 WHO AM I  Head of Security Research at Aqua Security, a leader in container security  20 years of building security products, development and research  Held senior security research positions at Microsoft, Aorato and Imperva.  Presented at security conferences, among them, BlackHat Europe, RSA Europe and Virus Bulleting.
  • 3. 3 BUILD SECURITY ALIGNED WITH DEVOPS Build Ship Cluster Environment Networking and Runtime Monitoring Productio n Dev. / Testing  
  • 5. 5 BUILD AND SHIP  Ensure That Only Authorized Images are Used in Your Environment  Ensure That Images Are Free of Vulnerabilities  Integrate Security into your CI/CD pipeline
  • 6. 6 SECURITY INTEGRATED WITH CI/CD Build • Only vetted code (approved for production) is used for building the images ShipTest  
  • 7. 7 SECURITY INTEGRATED WITH CI/CD Build • Implement Continuous Security Vulnerability Scanning • Regularly Apply Security Updates to Your Environment ShipTest  
  • 8. 8 SECURITY INTEGRATED WITH CI/CD Build • Use private registries to store your approved images - make sure you only push approved images to these registries ShipTest  
  • 10. 10 SSH LIMIT DIRECT ACCESS TO KUBERNETES NODES  Limit SSH access to Kubernetes nodes  Ask users to use “kubectl exec”
  • 11. 11 CONSIDER KUBERNETES AUTHORIZATION PLUGINS  Enables define fine-grained-access control rules  Namespaces  Containers  Operations  ABAC mode  RBAC mode  Webhook mode  Custom mode
  • 12. 12 CREATE ADMINISTRATIVE BOUNDARIES BETWEEN RESOURCES  Limits the damage of mistake or malicious intent  Partition resources into logical groups  Use Kubernetes namespaces to facilitate resource segregation  Kubernetes Authorization plugins to segregate user’s access to namespace resources
  • 13. 13 CREATE ADMINISTRATIVE BOUNDARIES BETWEEN RESOURCES  Example: allow ‘alice’ to read pods from namespace ‘fronto’ { "apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind": "Policy", "spec": { "user": "alice", "namespace": "fronto", "resource": "pods", "readonly": true } }
  • 14. 14 DEFINE RESOURCE QUOTA  Resource-unbound containers in shared cluster are bad practice  Create resource quota policies  Pods  CPUs  Memory  Etc.  Assigned to namespace
  • 15. 15 DEFINE RESOURCE QUOTA EXAMPLE  computer-resource.yaml apiVersion: v1 kind: ResourceQuota metadata: name: compute-resources spec: hard: pods: "4“ requests.cpu: "1“ requests.memory: 1Gi limits.cpu: "2“ limits.memory: 2Gi  kubectl create -f ./compute-resources.yaml -- namespace=myspace
  • 16. 16 SAFELY DISTRIBUTE YOUR SECRETS  Storing sensitive data in docker file, POD definition etc. is not safe  Centrally and securely stored secrets  Manage user access  Manage containers/pods access  Store securely  Facilitate secrets expiry and rotation  Etc.
  • 17. 17 KUBERNETES SECRETS  Secret object  As file  As Environment variable  Risks  Secrets stored in plain text  Is at rest  No separation of duties: operator can see secret value  Secrets are available, even if there is no container using it
  • 18. 18 KUBERNETES SECRETS - EXAMPLE  echo -n "admin" > ./username.txt echo -n "1f2d1e2e67df" > ./password.txt  kubectl create secret generic db-user-pass --from- file=./username.txt --from-file=./password.txt secret "db-user-pass" created  kubectl get secrets  Kubectl describe secrets/db-user-pass
  • 19. 19 KUBERNETES SECRETS - EXAMPLE  It call also be done manually  echo -n "admin" | base64 YWRtaW4=  echo -n "1f2d1e2e67df" | base64 MWYyZDFlMmU2N2Rm apiVersion: v1 kind: Secret metadata: name: mysecret type: Opaque data: username: YWRtaW4= password: MWYyZDFlMmU2N2Rm  kubectl create -f ./secret.yaml
  • 21. 21 IMPLEMENT NETWORK SEGMENTATION  “Good neighbor” compromised application is a door open into cluster  Network segmentation  Ensures that container can communicate only with whom it must
  • 22. 22 IMPLEMENT NETWORK SEGMENTATION  Cross-cluster segmentation can be achieved using firewall rules  “dynamic” nature of container network identities makes container network segmentation a true challenge  Kubernetes Network SIG works on pod-to-pod network policies  Currently only ingress policies can be defined
  • 23. 23 IMPLEMENT NETWORK SEGMENTATION: EXAMPLE  Enable using an annotation on the Namespace kind: Namespace apiVersion: v1 metadata: annotations: net.beta.kubernetes.io/network-policy: | { "ingress": { "isolation": "DefaultDeny" } } kubectl annotate ns <namespace> "net.beta.kubernetes.io/network-policy={"ingress": {"isolation": "DefaultDeny"}}"
  • 24. 24 IMPLEMENT NETWORK SEGMENTATION: EXAMPLE apiVersion: extensions/v1beta1 kind: NetworkPolicy metadata: name: test-network-policy namespace: default spec: podSelector: matchLabels: role: db ingress: - from: - namespaceSelector: matchLabels: project: myproject - podSelector: matchLabels: role: frontend ports: - protocol: tcp port: 6379 kubectl create -f policy.yaml
  • 26. 26 RUNTIME  Implement “least privileges” principal  Security Context control security parameters to be assigned  Pod  Containers  Pod Security Policy  Consider Kubernetes admission controllers:  “DenyEscalatingExec” – for containers/pods with elevated privileges  “ImagePolicyWebhook” – Kubernetes support to plug external image reviewer  “AlwaysPullImages” – in multitenant cluster
  • 27. 27 SECURITY CONTEXT Security Context Setting Description SecurityContext->runAsNonRoot Indicates that containers should run as non-root user SecurityContext->Capabilities Controls the Linux capabilities assigned to the container. SecurityContext->readOnlyRootFilesystem Controls whether a container will be able to write into the root filesystem. PodSecurityContext->runAsNonRoot Prevents running a container with ‘root’ user as part of the pod
  • 28. 28 SECURITY CONTEXT: EXAMPLE apiVersion: v1 kind: Pod metadata: name: hello-world spec: containers: # specification of the pod’s containers # ... securityContext: readOnlyRootFilesystem: true runAsNonRoot: true
  • 29. 29 IMAGE POLICY WEBHOOK  api.imagepolicy.v1alpha1.ImageReview object describing the action  Fields describing the containers being admitted, as well as any pod annotations that match *.image- policy.k8s.io/*
  • 30. 30 IMAGE POLICY WEBHOOK: EXAMPLE { "apiVersion":"imagepolicy.k8s.io/v1alpha1", "kind":"ImageReview", "spec":{ "containers":[ { "image":"myrepo/myimage:v1“ }, { "image":"myrepo/myimage@sha256:beb6bd6a68f114c1dc2ea4b28db81bdf91de202a9014972bec5e4d9171d 90ed“ } ], "annotations":[ "mycluster.image-policy.k8s.io/ticket-1234": "break-glass“ ], "namespace":"mynamespace“ } }
  • 31. 31 MONITORING AND VISIBILITY  Log everything  Cluster-based logging  Log container activity into a central log hub.  Use Fluentd agent on each node  Ingested logs using  Google Stackdriver Logging  Elasticsearch  Viewed with Kibana.
  • 33. 33 SECURITY ALIGNED WITH DEVOPS Build Ship Cluster Environment Networking and Runtime Monitoring Productio n Dev. / Testing Only vetted code can be used for build Scan images against known vulnerabilities Use private registries Only approved images are pushed Only use kubectl Fine-grained-access control to resources Create administrative boundaries and assign resource quotas Manage your secrets Implement “least privileges” principal Isolate container networks in logical application groups Log everything Integrates with SIEM and monitoring systems  