31
Kubernetes Security How to secure your Kubernetes platform Johannes M. Scheuermann Karlsruhe, 09.12.2017

Kubernetes Security

Embed Size (px)

Citation preview

Page 1: Kubernetes Security

Kubernetes SecurityHow to secure your Kubernetes platform

Johannes M. Scheuermann

Karlsruhe, 09.12.2017

Page 2: Kubernetes Security

Johannes M. ScheuermannIT Engineering & Operations @ inovex

〉 Software-Defined Datacentres

〉 Infrastructure as Code

〉 Cloud technologies

〉 High Availability & Scalability

〉 Want‘s a Z-Frame

〉 @johscheuer

2

Page 3: Kubernetes Security

Security

Page 4: Kubernetes Security

• Security Cake

• Authentication and Authorisation

• Network Policies

• Pod Security Policies

• Admission Controller

• Vault Integration

Security Kubernetes

Page 5: Kubernetes Security

Security Cake

HW HW HW HW

OS OS OS OS

Platform

Container Container Container Container

Base Base Base Base

App App App App

Page 6: Kubernetes Security

Secure the Pipeline

Build Test Ship Run

Page 7: Kubernetes Security

• Secure all components with certificates

• Only talk over TLS

• Disable the insecure port (even on localhost)

• Disable anonymous authentication• Or at least restrict it to uncritical resources

• Since 1.7 Kubernetes supports an Audit Log

Focus on the Platform

Page 8: Kubernetes Security

How to build ”the” platform

Page 9: Kubernetes Security

• RBAC (Role Based Access Control)

• ABAC (Attribute Based Access Control)

• WebHook

• Certificates

• Token (JWT à https://jwt.io)

Authentication and Authorisation

Page 10: Kubernetes Security

RBAC (example)

(Cluster)Role

Subject

(Cluster)Rolebinding

Page 11: Kubernetes Security

Network Policies

Page 12: Kubernetes Security

• Since 1.6

• Ingress policies

• Egress policies (1.8)

• Network segmentation (distributed firewall)

• CNI plugin must support it

Network Policies

Page 13: Kubernetes Security

• DENY all traffic to an application

• LIMIT traffic to an application

• DENY all non-whitelisted traffic in a namespace

• DENY all traffic from other namespaces

• ALLOW traffic from other namespaces

• ALLOW traffic from external clients

Network Policies (example)

Page 14: Kubernetes Security

PodSecurityPolicies

Page 15: Kubernetes Security

• Needs to be explicitly activated• Let you define what’s allowed• There must be a default policy• Activating “runAsNonRoot” will break many things• Only activate if needed (multi-tenant)• Can be combined with RBAC

Pod Security Policies

Page 16: Kubernetes Security

• Volumes• RunAsUser• AllowedCapabilities• Privileged• HostNetwork / HostPorts• readOnlyRootFilesystem

Pod Security Policies (example)

Page 17: Kubernetes Security

Admission Controller(s)

Page 18: Kubernetes Security

• Intercepts request to the Kubernetes API

• (Can) Perform modifications

• Many default controllers exists

• You can also write your own

Admission Controller(s)

Page 19: Kubernetes Security

• DenyEscalatingExec

• ImagePolicyWebhook

• NodeRestriction

• PodSecurityPolicy

• SecurityContextDeny

• ServiceAccount

Admission Controller (example)

Page 20: Kubernetes Security

Vault

Page 21: Kubernetes Security

Vault Integration (CA)

Vault

Node

Master

1.) Auth (AppRoleID)2.) Issue certificate

Policies

etcd

Page 22: Kubernetes Security

• Since 0.9 Kubernetes auth backend

• Solves only the challenge of authentication

• Secret must be fetched• Sidecare/init container

• Integrates with ServiceAccounts

Vault Integration (secret store)

Page 23: Kubernetes Security

• Open artifact metadata API

• Pluggable (multiple providers)

• ACL for the metadata

• Query-ability

• Integrates with Kubernetes

Grafeas

Page 24: Kubernetes Security

• Service Mesh

• Policy Enforcement (L4/L7)

• Integrated CA

• Transparent TLS

• Routing

• Language/Platform agnostic

Istio

Page 25: Kubernetes Security

Conclusions

Page 26: Kubernetes Security

• Many possibilities to make your cluster more secure

• Each with it’s benefits and drawbacks

• Generally à Security means (hard) work

• Depends on your Use Case what to use

• Play around with and get a feeling (in a playground)

Conclusions

Page 27: Kubernetes Security

27

We are hiring!

www.inovexperts.com

Page 28: Kubernetes Security

Q&A

Page 29: Kubernetes Security

• https://kubernetes.io/docs/admin/admission-

controllers

• https://kubernetes.io/docs/concepts/policy/pod-

security-policy

• https://kubernetes.io/docs/concepts/services-

networking/network-policies

Further reading

Page 30: Kubernetes Security

• https://grafeas.io

• https://istio.io

• https://ahmet.im/blog/kubernetes-network-policy

• https://github.com/kubernetes/examples/tree/master/

staging/podsecuritypolicy/rbac

Further reading

Page 31: Kubernetes Security

Johannes M. Scheuermanninovex GmbH

[email protected]

CC BY-NC-ND inovex.de +JohannesScheuermann

github.com/johscheuer

@johscheuer youtube.com/inovexGmbH