Top Banner
Secure Networking for Kubernetes @mikegstowe Mike Stowe
65

Secure Networking for Kubernetes

Jan 28, 2018

Download

Software

Michael Stowe
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Secure Networking for Kubernetes

SecureNetworking for Kubernetes

@mikegstoweMike Stowe

Page 2: Secure Networking for Kubernetes

AboutMe

• API & Security Fanatic

• Open Source Contributor

• Speaker, Author, Consultant

• 10+ years Hacking Professional Code

• Community Guy at Tigera

https://www.mikestowe.com

Page 3: Secure Networking for Kubernetes

AboutMe

• API & Security Fanatic

• Open Source Contributor

• Speaker, Author, Consultant

• 10+ years Hacking Professional Code

• Community Guy at Tigera

https://www.mikestowe.com

Felix

Page 4: Secure Networking for Kubernetes

Let’s get started

Page 5: Secure Networking for Kubernetes

Microservices are scalable…Yay!

Page 6: Secure Networking for Kubernetes

Microservices are scalable…Yay!

Microservices increase network complexity!?

Page 7: Secure Networking for Kubernetes

Containers are deployedfaster than typical VMs 900x

source: https://www.slideshare.net/Flux7Labs/performance-of-docker-vs-vms

60sec45sec 50ms50ms

Page 8: Secure Networking for Kubernetes

DistributedContainer basedenvironments increaseworkloads for hosts by 10xsource: https://sysdig.com/blog/sysdig-docker-usage-report-2017/

Page 9: Secure Networking for Kubernetes

While orchestratedcontainers haveashorter lifespan…bymore than

source: https://www.datadoghq.com/docker-adoption/

25x

Page 10: Secure Networking for Kubernetes

Which creates a churnper host ofmore than 250x

Page 11: Secure Networking for Kubernetes

Traditional SDNsdon’twork formicroservices architectures

InOtherWords

Page 12: Secure Networking for Kubernetes

Microservices are secure…Yay!

Page 13: Secure Networking for Kubernetes

Microservices are secure…Yay!

Microservices increase attack surface!?

Page 14: Secure Networking for Kubernetes

SampleApproach toaMicroservices BasedArchitectures

Page 15: Secure Networking for Kubernetes

Attack Surfaceof SampleArchitecture

Page 16: Secure Networking for Kubernetes

Attack Surfaceof Real-WorldMicroservices BasedArchitectures

Page 17: Secure Networking for Kubernetes

Each Service hasMultipleNetworkAttackPoints

Application (Layer 7)

Presentation(Layer 6)

Session (Layer 5)

Transport(Layer 4)

Network (Layer 3)

Data Link (Layer 2)

Physical (Layer 1)

HTTP, FTP, Telnet

Encryption, ASCII, Graphics (GIF, JPEG)

SQL, RPC

SPX, TCP, UDP

IP, IPX, DDP, Apple Talk

PPP, FDDI, IEEE 802.5, HDLC, FR

FDDI, B8ZS, RJ45

Page 18: Secure Networking for Kubernetes

Percent of IoTDevicesVulnerable to anAttack

70%source: http://h20195.www2.hp.com/V2/GetDocument.aspx?docname=4AA5-4759ENW&cc=us&lc=en

Page 19: Secure Networking for Kubernetes

Percent ofWebServiceswithHighRiskVulnerabilities

60%source: https://betanews.com/2016/06/08/web-services-mobile-apis-security-vulnerabilities/

API

Page 20: Secure Networking for Kubernetes

OSVulnerabilities (in 2014)

24source: https://techtalk.gfi.com/most-vulnerable-operating-systems-and-applications-in-2014/

Mac OS X

Windows Server

Linux Kernel

2664

741267

Page 21: Secure Networking for Kubernetes
Page 22: Secure Networking for Kubernetes

$252M

Page 23: Secure Networking for Kubernetes
Page 24: Secure Networking for Kubernetes

$35M in IT Repairs

Page 25: Secure Networking for Kubernetes

Security is important… it’s hard…and it needs to be implementedateach layer.

InOtherWords

Page 26: Secure Networking for Kubernetes

There are several open sourceprojects designed tomakenetworkingand security easier.

TheGoodNews

Page 27: Secure Networking for Kubernetes
Page 28: Secure Networking for Kubernetes
Page 29: Secure Networking for Kubernetes

Flannel for networking

Application (Layer 7)

Presentation(Layer 6)

Session (Layer 5)

Transport(Layer 4)

Network (Layer 3)

Data Link (Layer 2)

Physical (Layer 1)

Flannel provides easy tousenetworking viaVXLANoverlays.

While flexible, it is oneof theeasiest open sourcenetworking solutions available today.

Page 30: Secure Networking for Kubernetes

Project Calico for L3-4 security

Application (Layer 7)

Presentation(Layer 6)

Session (Layer 5)

Transport(Layer 4)

Network (Layer 3)

Data Link (Layer 2)

Physical (Layer 1)

Enforcedat thehost node, Project Calicoallowsyou to restrict access (incomingandoutgoing) atthenetworkand transport layers.

This layer is critical as it prevents compromisedservices or pods fromhaving free range/ accesswithin thenetwork.

Page 31: Secure Networking for Kubernetes

Istio for L5-7networking& security

Application (Layer 7)

Presentation(Layer 6)

Session (Layer 5)

Transport(Layer 4)

Network (Layer 3)

Data Link (Layer 2)

Physical (Layer 1)

Enforced inside thepodasa sidecar, Istio allowsyou to restrict access (incomingandoutgoing) attheapplication, presentation, and session layers.

This layer is the first defenseas it preventsmanyofthemost common types of attacks, and is able todetermalicious users before they reach thenetwork.

Page 32: Secure Networking for Kubernetes

Application (Layer 7)

Presentation(Layer 6)

Session (Layer 5)

Transport(Layer 4)

Network (Layer 3)

Data Link (Layer 2)

Physical (Layer 1)

HTTP, FTP, Telnet

Encryption, ASCII, Graphics (GIF, JPEG)

SQL, RPC

SPX, TCP, UDP

IP, IPX, DDP, Apple Talk

PPP, FDDI, IEEE 802.5, HDLC, FR

FDDI, B8ZS, RJ45

ReducingAttack Surface via Policy Enforcement

By combining Calico and Istio, you are to enforce policies onLayers 3-7.

While Istio operates inside thepod to restrict access to otherproxy-enabled pods, Calico isenforced at the host node, helping prevent attacks fromcompromised services.

» http://bit.ly/istio_calico

Page 33: Secure Networking for Kubernetes

Installing

Page 34: Secure Networking for Kubernetes

InstallationOptions

1

2

3

Install Flannel and Calico individually, then manually configure

Install just Calico for networking and isolation policies, and then configure manually

Use Canal, an installer script that installs and configures Flannel with Calico

Page 35: Secure Networking for Kubernetes

InstallationOptions

1

2 https://docs.projectcalico.org

https://coreos.com/flannel

Page 36: Secure Networking for Kubernetes

InstallationOptions3 Use Canal, an installer script that installs and configures

Flannel with Calico

kubectl apply -f https://raw.githubusercontent.com/projectcalico/canal/master/k8s-install/1.6/rbac.yaml

kubectl apply -f https://raw.githubusercontent.com/projectcalico/canal/master/k8s-install/1.6/canal.yaml

kubectl apply -f https://raw.githubusercontent.com/projectcalico/canal/master/k8s-install/canal.yaml

1.6+

1.5

Page 37: Secure Networking for Kubernetes

InstallationOptions3 Use Canal, an installer script that installs and configures

Flannel with Calico

https://github.com/projectcalico/canal

Page 38: Secure Networking for Kubernetes

Configuring Policies

Page 39: Secure Networking for Kubernetes

Configuring Policies1 Create policy files

kind: PodapiVersion: v1metadata:name: clientnamespace: policy-demolabels:run: client

spec:containers:- name: busyboximage: busyboxargs:- sleep- "10000"

kind: NetworkPolicyapiVersion: extensions/v1beta1metadata:name: access-nginxnamespace: policy-demo

spec:podSelector:matchLabels:run: nginx

ingress:- from:- podSelector:

matchLabels:run: client

pod.yaml network-policy.yaml

Page 40: Secure Networking for Kubernetes

Configuring Policies

2 Create a namespace called “policy-demo” as previously specified in our policy YAML files.

kubectl create ns policy-demo

Page 41: Secure Networking for Kubernetes

Configuring Policies

3 Launch and expose pods in “policy-demo” namespace

kubectl run --namespace=policy-demo nginx --replicas=2 --image=nginx

kubectl expose --namespace=policy-demo deployment nginx --port=80

Page 42: Secure Networking for Kubernetes

Configuring Policies

Page 43: Secure Networking for Kubernetes

Configuring Policies

4 Enable isolation within Kubernetes

kubectl annotate ns policy-demo "net.beta.kubernetes.io/network-policy={\"ingress\":{\"isolation\":\"DefaultDeny\"}}"

Page 44: Secure Networking for Kubernetes

Configuring Policies

Page 45: Secure Networking for Kubernetes

Configuring Policies

5 Apply network-policy.yaml, allowing access from client pods.

kubectl create -f network-policy.yaml

Page 46: Secure Networking for Kubernetes

Configuring Policies

Page 47: Secure Networking for Kubernetes

More advanced policies can be defined by using ingress and egress, as well as utilizing actions and tags.

kind: profilemetadata:name: k8s_ns.advanced-policy-demotags: - k8s_ns.advanced-policy-demospec:

egress:- action: allow

destination: {}source: {}

ingress: - action: deny

destination: {}source: {}

DoingMorewith Calico

Page 48: Secure Networking for Kubernetes

You can also apply multiple policies (with lower order taking precedence) based on selectors, protocols, ports, source, destination, and ICMP (Internet Control Message Protocol).

kind: policy metadata:

name: advanced-policy-demo.allow-dnsspec:

selector: has(calico/k8s_ns) order: 400 egress:- action: allow

protocol: udpdestination:

selector: calico/k8s_ns == 'kube-system' && k8s-app == 'kube-dns'

ports: [53]

DoingMorewith Calico

Page 49: Secure Networking for Kubernetes

Try It Yourselfprojectcalico.org/demo

Page 50: Secure Networking for Kubernetes

Installing

Page 51: Secure Networking for Kubernetes

Installing

1

2

3

Download and extract the installation file

Check RBAC Settings

curl -L https://git.io/getIstio | sh -

Add the istioctl client to your PATH

export PATH=$PWD/bin:$PATH

kubectl api-versions | grep rbac

Page 52: Secure Networking for Kubernetes

RBACSettingsMapIf error – continue to step

If it returns ”alpha” WITHOUT “beta” run the following configuration:

If it returns “beta” or both “beta” and “alpha” run Istio RBAC configuration:

kubectl apply -f install/kubernetes/istio-rbac-alpha.yaml

kubectl apply -f install/kubernetes/istio-rbac-beta.yaml

If you receive a “Forbidden” error, create clusterrolebinding:

kubectl create clusterrolebinding myname-cluster-admin-binding --clusterrole=cluster-admin [email protected]

4

Page 53: Secure Networking for Kubernetes

Installing

4 Install Istio without the Auth module:

kubectl apply -f install/kubernetes/istio.yaml

Advanced: Install Istio with the Auth module:

kubectl apply -f install/kubernetes/istio-auth.yaml

Page 54: Secure Networking for Kubernetes

Configuring Policies

Page 55: Secure Networking for Kubernetes

Configuring Ingress1 Create simple-istio-policy.yaml file

apiVersion: extensions/v1beta1kind: Ingressmetadata:name: simple-istio-ingressannotations:kubernetes.io/ingress.class: istio

spec:rules:- http:

paths:- path: /headersbackend:serviceName: httpbinservicePort: 8000

- path: /delay/.*backend:serviceName: httpbinservicePort: 8000

Page 56: Secure Networking for Kubernetes

Configuring Ingress

2 Apply simple-istio-policy.yaml

kubectl create -f simple-istio-policy.yaml

Page 57: Secure Networking for Kubernetes

Configuring Egress

1 Create simple-egress-istio-policy.yaml file

apiVersion: v1kind: Servicemetadata:name: securegooglespec:type: ExternalNameexternalName: www.google.comports:- port: 443# important to set protocol namename: https

Page 58: Secure Networking for Kubernetes

Configuring Egress

2 Apply simple-egress-istio-policy.yaml

kubectl create -f simple-egress-istio-policy.yaml

Page 59: Secure Networking for Kubernetes

Beyond ingress and egress policy management at the pod level, Istio comes with many more features including:

• Request Routing and Load Balancing

• Managing Request Timeouts

• Fault Injection and Rate Limiting

• Simple Access Control and Logging

DoingMorewith Istio

Page 60: Secure Networking for Kubernetes

LearnMoreatistio.io

Page 61: Secure Networking for Kubernetes

WrappingUp

Page 62: Secure Networking for Kubernetes

Application (Layer 7)

Presentation(Layer 6)

Session (Layer 5)

Transport(Layer 4)

Network (Layer 3)

Data Link (Layer 2)

Physical (Layer 1)

HTTP, FTP, Telnet

Encryption, ASCII, Graphics (GIF, JPEG)

SQL, RPC

SPX, TCP, UDP

IP, IPX, DDP, Apple Talk

PPP, FDDI, IEEE 802.5, HDLC, FR

FDDI, B8ZS, RJ45

TheEndResult

You now have a network that isboth scalable, and more secure. Helping protect yourapplications, user data, andinfrastructure from a myriad ofattacks by significantly reducingthe attack surface.

However, this is still just thebeginning, as security meansaddressing each layer withmultiple barriers.

Page 63: Secure Networking for Kubernetes

GetHelp& EarnAwesomePrizes

Join the Tigera MVP Program

http://mvp.tigera.io

Get Support and Free Help on Slack: http://projectcalico.org/community

Page 64: Secure Networking for Kubernetes

Security is about layers. Onions have layers. Ogres have layers. Has anyone ever hacked

anOnionor anOgre?

Page 65: Secure Networking for Kubernetes

THANKYOU!!!!@mikegstowe @tigeraio