The community continues to benefit from Kubernetes the Hard Way by Kelsey Hightower in understanding how each of the components work together and are configured in a reasonably secure manner, step-by-step. In a similar manner but using a slightly different approach, this guide attempts to demonstrate how the security-related settings inside kubernetes
actually work from the ground up, one change at a time, validated by real attacks where possible.
By following this guide, you will configure one of the least secure clusters possible at the start. Each step will attempt to follow the pattern of a) educate, b) attack, c) harden, and d) verify in order of security importance and maturity. Upon completion of the guide, you will have successfully hacked your cluster several times over and now fully understand all the necessary configuration changes to prevent each one from happening.
The cluster built in this tutorial is not production ready--especially at the beginning--but the concepts learned are definitely applicable to your production clusters.
The target audience for this tutorial is someone who has a working knowledge of running a Kubernetes cluster (or has completed the kubernetes-the-hard-way
tutorial) and wants to understand how each security-related setting works at a deep level.
- AWS EC2
- Ubuntu 16.0.4 LTS and search for '16.04 LTS hvm:ebs-ssd'
- Docker 1.13.x
- CNI Container Networking 0.6.0
- etcd 3.2.11
- Kubernetes 1.9.2
- AWS Account Credentials
- Create/delete VPC (subnets, route tables, internet gateways)
- Create/delete Cloudformation
- Create/delete EC2 * (security groups, keypairs, instances)
- AWS cli tools configured to use said account
- bash
- git
- dig
- kubectl (v1.9.2)
- cfssl
- Etcd - t2.micro (10.1.0.5)
- Master - t2.small (10.1.0.10)
- Worker1 - t2.small (10.1.0.11)
- Worker2 - t2.small (10.1.0.12)
TODO
- Create the VPC
- Launch and configure the
etcd
instance - Launch and configure the
master
instance - Launch and configure the
worker-1
andworker-2
instance
- Deploy kube-dns
- Deploy Heapster
- Deploy Dashboard
- Scan Ports
- etcdctl
- kubectl to API
- curl to Kubelet/metrics
- Security Groups
- Etcd TLS
- Cluster TLS
- Admission Controllers
- Helm/Tiller
- Vulnapp
- Azure Vote App
- Multi-tenant Misuse
- Too many Pods
- Too many CPU/RAM shares
- Separate Namespaces
- Request/Limits on Pods
- Namespace Resource Quotas
- Metrics via Prometheus
- Optional multi-etcd, mult-master
- Malicious Image, Compromised Container, Multi-tenant Misuse
- Service Account Tokens
- Dashboard Access
- Tiller Access
- Kubelet Exploit
- Application Tampering
- Metrics Scraping
- Metadata API
- Outbound Scanning/pivoting
- RBAC
- New Dashboard
- Separate Kubeconfigs per user
- Tiller TLS
- Kubelet Authn/z
- Network Policy/CNI
- Admission Controllers
- Logging?
- Malicious Image, Compromised Container, Multi-tenant Misuse
- Escape the container
- Advanced admission controllers
- Restrict images/sources
- Network Egress filtering
- Vuln scan images
- Pod Security Policy
- Encrypted etcd
- Sysdig Falco
- Kubernetes the Hard Way - Kelsey Hightower