Top Banner
Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg, 26. June 2019
30

Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Jun 09, 2020

Download

Documents

dariahiddleston
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: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Trust is good, control is betterA short story about Network Policies

Maximilian Bischoff, Johannes M. Scheuermann

Hamburg, 26. June 2019

Page 2: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Maximilian Bischoff

Unofficial: Chaos Monkey

@johscheuer2

Cloud Platform Engineer

Cloud Platform Engineer

Johannes M. Scheuermann

Page 3: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

What can you expect ?

● Get an overview about challenges with network policies

● Get an overview on different aspects of testing / validating your setup

3

Page 4: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

What about you?

4

Page 5: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Why should I test my network policies?

5

Page 6: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Why should I test my policies ?

Many adjustment screws

https://www.pexels.com/photo/colorful-toothed-wheels-171198 6

Page 7: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Why should I test my policies ?

Kubernetes doesn’t implement the policies

7

kube-apiserver

Netpol

CNI PluginRead NetPol

Implements them

Page 8: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Why should I test my policies ?

Kubernetes doesn’t implement the policies

8

kube-apiserver

CNI PluginRead NetPol

No Feedback !

Netpol

Implements them

Page 9: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Why should I test my policies ?

I choose you !

This list is not complete!9

Page 10: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

...

spec:

ingress:

- from:

- namespaceSelector:

matchLabels:

team: operations

podSelector:

matchLabels:

type: monitoring

Why should I test?Hard to read policies

https://github.com/ahmetb/kubernetes-network-policy-recipes/blob/master/07-allow-traffic-from-some-pods-in-another-namespace.md10

...

spec:

ingress:

- from:

- namespaceSelector:

matchLabels:

team: operations

- podSelector:

matchLabels:

type: monitoring

and or

Page 11: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Node

Why should I test my policies ?

Component updates

11

kube-proxy

iptables CNI-Plugins

Node

kube-proxy

ipvs CNI-Plugins

Node

kube-proxy

iptables CNI-Plugins v1

Node

kube-proxy

iptables CNI-Pluginsv2

Page 12: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Node

Why should I test my policies ?

Component updates

12

kube-proxy

iptables CNI-Plugins

Node

kube-proxy

ipvs CNI-Plugins

Node

kube-proxy

iptables CNI-Plugins v1

Node

kube-proxy

iptables CNI-Pluginsv2

Is everything still working after an update?

Page 13: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Node

Why should I test my policies ?

Component updates

13

kube-proxy

iptables CNI-Plugins

Node

kube-proxy

ipvs CNI-Plugins

Node

kube-proxy

iptables CNI-Plugins v1

Node

kube-proxy

iptables CNI-Pluginsv2

Conformance tests don’t test network policies!

Page 14: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

What to test

14

Page 15: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

What to test

15

PolicyPolicyPolicy

SDN Control

PlaneData Plane

Conformance - Effect of policies- Synchronisation

Page 16: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

How to test

16

Page 17: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

How to test

17

PolicyPolicyPolicy

SDN Control

PlaneData Plane

Conformance - Effect of policies- Synchronisation

Page 18: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Testing strategiesCopy-pod

18

kind: podapiVersion: v1metadata: name: foo namespace: default labels:

app: foospec: containers: - name: foo image: foo:latest ...

kind: podapiVersion: v1metadata: name: foo-test-copy namespace: default labels:

app: footesting.framework: “”

spec: containers: - name: test image: test/runner:latest ...

copy

Page 19: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Testing strategiesDocker networking

19

foopausefoo

test-runner

Page 20: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Testing strategiesLinux namespaces

20

pause(of pod

foo)

test-runner

underlying OS

...

Network

IPC

CGroup

...

IPC

CGroup

Page 21: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

kubectl exec -it foo -- wget -qO - --timeout=2 http://bar.defaultwget: download timed out

Manually

https://github.com/ahmetb/kubernetes-network-policy-recipes/blob/master/03-deny-all-non-whitelisted-traffic-in-the-namespace.md21

kind: NetworkPolicyapiVersion: networking.k8s.io/v1metadata: name: default-deny-all namespace: defaultspec: podSelector: {} ingress: []

default

foo barbar

Page 22: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

node 1

netassert

https://github.com/controlplaneio/netassert22

default

foo barbar

config.yaml---k8s: deployment: default:foo: default:bar: TCP:80

ssh

docker run --net ...

test.js

nmap

netassert

Page 23: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

node 1

illuminatio

23

default

foo barbar

API Server

nsenter

results

test.py

nmap

illuminatio

Page 24: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

kind: NetworkPolicyapiVersion: networking.k8s.io/v1metadata: name: demo namespace: defaultspec: podSelector: matchLabels: app: prometheus ingress: ...

Test case generationPreface

24

isolated from every pod

except for those matching

Page 25: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Test case generationTwo kinds of tests

25

pod Aapp=prometheus

pod Bapp=grafana

pod C

...spec: podSelector: matchLabels: app: prometheus ingress: - from: - podSelector: matchLabels: app: grafana

Page 26: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

pod Aapp=prometheus

Test case generationMultiple policies

26

pod Bteam=opsapp=foo

...spec: podSelector: matchLabels: app: prometheus ingress: - from: - podSelector: matchLabels: app: grafana

...spec: podSelector: {} ingress: - from: - podSelector: matchLabels: team: ops namespaceSelector: {}

?

Page 27: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Wrap up

27

Page 28: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

How do these tools complement

28

PolicyPolicyPolicy

kubeaudit/

SDN Control

PlaneData Plane

netassert/illuminatio

Page 29: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Recap

● Test your assumptions!

● Regression testing makes your life easier

● Network Policies are still hard to get right○ Missing feedback○ Does it work for Services and Pods?

29

Page 30: Trust is good, control is better A short story about ... · Trust is good, control is better A short story about Network Policies Maximilian Bischoff, Johannes M. Scheuermann Hamburg,

Thank You

Maximilian BischoffIT Engineering & Operations

inovex GmbHLudwig-Erhard-Allee 676131 Karlsruhe

[email protected]

Johannes ScheuermannIT Engineering & Operations

inovex GmbHLudwig-Erhard-Allee 676131 Karlsruhe

[email protected]