The Docker Multitenancy Problem: A Journey through Infrastructure Hell

52
A JOURNEY THROUGH INFRASTRUCTURE MULTITENANCY WITH DOCKER Peter Klipfe

Transcript of The Docker Multitenancy Problem: A Journey through Infrastructure Hell

Page 1: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

A JOURNEY THROUGH INFRASTRUCTURE HELL

MULTITENANCY WITH DOCKER

Peter Klipfel

Page 2: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

STOP ME IF YOU WANT TO LOOK AROUND

THERE’S A LOT TO SEE

Page 3: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

I WILL PAUSEWHEN I SEE A TURTLE

Page 4: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

SOME CONTEXT

Page 5: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

WHAT WE’RE TRYING TO DO

EACH USER GETS

▸ Private data storage

▸ Notebook (executable code on our servers)

▸ Deployed microservices

Page 6: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

WHAT WE’RE TRYING TO DO

WE NEED

▸ Scalability

▸ Fault Tolerance

▸ Security

Page 7: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

HOW HARD IS IT TO CREATE A MULTI-TENANT ELASTICSEARCH CLUSTER?

LET’S START WITH A QUESTION

Page 8: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

VERY HARD

Page 9: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

MULTITENANT ELASTICSEARCH

POSSIBLE SOLUTIONS

▸ Built in multi tenancy

▸ Shield

▸ Search-guard

Page 10: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

MULTITENANT ELASTICSEARCH

NONE OF THEM WORK

▸ Built in multi tenancy: update yml file every user ->

restart

▸ Shield: Not Free

▸ Search-guard: SSL was painful

Page 11: The Docker Multitenancy Problem: A Journey through Infrastructure Hell
Page 12: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

HOW CAN WE DO THAT?

EACH USER GETS THEIR OWN DATABASE

Page 13: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

ELASTICSEARCH INSTANCE PER USER

POSSIBLE SOLUTIONS

▸ Use hosted ES: Really expensive

▸ Use a cloud provider: expensive

▸ Use Docker: not as expensive

Page 14: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

DOCKER TO THE RESCUE!

Page 15: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

HOW DO WE CREATE DOCKER CONTAINERS ON DEMAND?

BUT WAIT

Page 16: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

DOCKER CONTAINERS ON DEMAND

POSSIBLE SOLUTIONS

▸ Mesos (+ marathon)

▸ Docker Swarm

▸ Kubernetes

Page 17: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

DOCKER CONTAINERS ON DEMAND

WHAT ARE THOSE TOOLS?

▸ Container schedulers

▸ APIs to run a docker container somewhere in the

cluster

▸ Uniform cluster nodes

Page 18: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

DOCKER CONTAINERS ON DEMAND

WHAT ARE THOSE TOOLS?

MASTER

AGENT

AGENT

AGENT

AGENT

AGENT

CONTAINER

CONTAINER

CONTAINER

Page 19: The Docker Multitenancy Problem: A Journey through Infrastructure Hell
Page 20: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

DOCKER CONTAINERS ON DEMAND

THE PROBLEMS

▸ How do users get to their services (databases)?

▸ What if a node goes down?

▸ How do I separate users?

Page 21: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

HOW DO USERS GET TO THEIR DATABASES?

Page 22: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

SERVICE ACCESS

WHAT ARE THOSE TOOLS?MAST

ER

AGENT

CONTAINER

CONTAINER

CONTAINER

AGENT

CONTAINER

CONTAINER

CONTAINER

AGENT

CONTAINER

CONTAINER

CONTAINER

AGENT

CONTAINER

CONTAINER

CONTAINER

REVERSE

PROXY

Page 23: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

SERVICE ACCESS

REVERSE PROXY

▸ Nginx (reloads good)

▸ HAProxy (reloads bad)

▸ And we will need Consul

Page 24: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

SERVICE ACCESS

CONSUL: THE EASIEST WAY

▸ We need Registrator on every node

▸ consul-dns creates routing

▸ consul-template builds nginx config

Page 25: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

SERVICE ACCESS

NOW OUR REVERSE PROXY WORKS!MAST

ER

AGENT

CONTAINER

CONTAINER

CONTAINER

AGENT

CONTAINER

CONTAINER

CONTAINER

AGENT

CONTAINER

CONTAINER

CONTAINER

AGENT

CONTAINER

CONTAINER

CONTAINER

REVERSE

PROXY

Page 26: The Docker Multitenancy Problem: A Journey through Infrastructure Hell
Page 27: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

SERVICE ACCESS

POTENTIAL ALTERNATIVES

▸ ETCD

▸ MesosDNS

▸ Zookeeper

Page 28: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

WHAT IF A NODE GOES DOWN?

GREAT! USERS CAN ACCESS THINGS!

Page 29: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

STATEFUL SERVICES

PROBLEMS

▸ Containers have different fs mounts on each instance

▸ Node spin-up is non-deterministic (which disk will it

use)

▸ Network file systems require implementation

changes

Page 30: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

STATEFUL SERVICES

SOME SOLUTIONS

▸ We can mount docker container filesystems with

volumes

▸ Can specify certain nodes for services

▸ Force stateful services to same node

Page 31: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

CLUSTERINGSOLUTION:

Page 32: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

STATEFUL SERVICES

CLUSTERING

▸ Failure is ok, as long as it’s not the whole cluster

▸ Storage can be ephemeral

▸ Most databases cluster

Page 33: The Docker Multitenancy Problem: A Journey through Infrastructure Hell
Page 34: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

HOW DO WE KEEP OUR USERS SEPARATED?

GREAT! LET’S CLUSTER

Page 35: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

NETWORK ISOLATION

THEY’RE ALL ON THE SAME SYSTEMMAST

ER

AGENT

CONTAINER

CONTAINER

CONTAINER

AGENT

CONTAINER

CONTAINER

CONTAINER

AGENT

CONTAINER

CONTAINER

CONTAINER

AGENT

CONTAINER

CONTAINER

CONTAINER

REVERSE

PROXY

Page 36: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

NETWORK ISOLATION

PROBLEMS WITH CLUSTERING

▸ Reverse proxy works only for HTTP

▸ Don’t want to DOS the internal network

▸ Need isolation between users

Page 37: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

NETWORK ISOLATION

SOLUTION: DOCKER OVERLAY NETWORK▸ Weave

▸ Callico

▸ Flannel

Page 38: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

WE JUST REINVENTED OPENSTACK…

BUT WAIT

Page 39: The Docker Multitenancy Problem: A Journey through Infrastructure Hell
Page 40: The Docker Multitenancy Problem: A Journey through Infrastructure Hell
Page 41: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

NETWORK ISOLATION

PROBLEMS WITH OPENSTACK

▸ Maintaining it sucks

▸ Upgrading it sucks

▸ Paying for it sucks

Page 42: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

SO I USED OPENSTACK FOR A WHILE

Page 43: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

NETWORK ISOLATION

HOW IT WORKED

▸ User gets their own account

▸ Every user gets their own network

▸ Every user gets their own persistent storage

Page 44: The Docker Multitenancy Problem: A Journey through Infrastructure Hell
Page 45: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

KUBERNETES

AND AFTER IT STOPPED SCALING I TRIED

Page 46: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

GOOGLE CONTAINER ENGINE

AND AFTER IT STOPPED SCALING I TRIED

Page 47: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

GOOGLE CONTAINER ENGINE (GKE)

THE BEST SOLUTION I HAVE FOUND

▸ Persistent volumes

▸ Decent library support

▸ Hopeful networking promised land

Page 48: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

GOOGLE CONTAINER ENGINE (GKE)

PERSISTENT VOLUMES

▸ I don’t need automated clustering if disks are

persistent

▸ Manual deploy for customers that require larger

clusters

▸ Can separate disk utilization by service

Page 49: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

GOOGLE CONTAINER ENGINE (GKE)

HOPEFUL NETWORKING PROMISED LAND▸ Configuration defines subnetwork id

▸ Subnets can exist across data centers

▸ Lots of opportunities for more clever reverse

proxying

Page 50: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

CONCLUSIONWHAT HAVE WE LEARNED?

Page 51: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

CONCLUSION

WHAT HAVE WE LEARNED?

▸ Docker is a glorified package manager

▸ Complex microservice architectures are still hard

▸ The promised land is close

Page 52: The Docker Multitenancy Problem: A Journey through Infrastructure Hell

[email protected] YOU