32
Endoctus Academy Next Trainings: INTRODUCTION TO KUBERNETES April 27th May 4th May 18th https://endoctus.com/course/introduction-to-kubernetes

Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Embed Size (px)

Citation preview

Page 1: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Endoctus Academy

Next Trainings:

INTRODUCTION TO KUBERNETES

April 27thMay 4thMay 18th

https://endoctus.com/course/introduction-to-kubernetes

Page 2: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Architecture Patterns for Microservices in Kubernetes

Thomas FrickeCTO

[email protected]

Page 3: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Penrose Tilings 1973

Golden Section

CC BY-SA 2.5, https://commons.wikimedia.org/w/index.php?curid=474348

Page 4: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Giri Tiles, since 1200

Cronholm144, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=2303498

Page 5: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Roof Hafez Tomb

By Pentocelo - Own work, CC BY 3.0, https://commons.wikimedia.org/w/index.php?curid=4129063

Page 6: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

WHAT ARE CONTAINERSWay of isolating and restricting Linux processes

● Isolation○ namespaces

● Restriction○ cgroups○ capabilities○ seccomp

Page 7: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

CGROUPS: CONTROL GROUPS● cpuset● cpu● cpuacct● memory● devices● freezer● net_cls● ns● blkio

these are directories with fine grained sub folders

Page 8: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

NAMESPACESNamespace Constant IsolatesCgroup CLONE_NEWCGROUP Cgroup root directoryIPC CLONE_NEWIPC System V IPC, POSIX message queuesNetwork CLONE_NEWNET Network devices, stacks, ports, etc.Mount CLONE_NEWNS Mount pointsPID CLONE_NEWPID Process IDsUser CLONE_NEWUSER User and group IDsUTS CLONE_NEWUTS Hostname and NIS domain name

Page 9: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

CAPABILITIESCAP_AUDIT_CONTROL, CAP_AUDIT_READ, CAP_AUDIT_WRITE, CAP_BLOCK_SUSPEND, CAP_CHOWN,CAP_DAC_OVERRIDE, CAP_DAC_READ_SEARCH, CAP_FOWNER, CAP_FSETID, CAP_IPC_LOCK, CAP_IPC_OWNER, CAP_KILL, CAP_LEASE, CAP_LINUX_IMMUTABLE, CAP_MAC_ADMIN,CAP_MAC_OVERRIDE, CAP_MKNOD, CAP_NET_ADMIN, CAP_NET_BIND_SERVICE, CAP_NET_BROADCAST, CAP_NET_RAW, CAP_SETGID, CAP_SETFCAP, CAP_SETPCAP, CAP_SETUID, CAP_SYS_ADMIN, CAP_SYS_BOOT,CAP_SYS_CHROOT, CAP_SYS_MODULE, CAP_SYS_NICE, CAP_SYS_PACCT, CAP_SYS_PTRACE, CAP_SYS_RAWIO, CAP_SYS_RESOURCE, CAP_SYS_TIME, CAP_SYS_TTY_CONFIG, CAP_SYSLOG, CAP_WAKE_ALARM, CAP_INIT_EFF_SET

These are a lot! Use profiles to group them together!

Page 10: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Linking Containers: Patternsat least one common Namespace

processnetwork…

processnetwork…

mount

Page 11: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes
Page 12: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes
Page 13: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

No need for a running process

network…

pause

mount: WAR file

Page 14: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Multiple Containers

network…

pause

mount: WAR file

pause

pause

mount: WAR file

Page 15: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Locomotive Pattern

By Nate Beal (originally posted to Flickr as Griffith, IN) [CC BY 2.0 (http://creativecommons.org/licenses/by/2.0)], via Wikimedia Commons

Page 16: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Scary ideas

network…

pause

Page 17: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes
Page 18: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Share the Network namespace

files: credentialsusermount

filesusermount

network: tun0 iptables

NET ADMIN

Page 19: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Photograph of Women Working at a Bell System international Telephone Switchboard

U.S. National Archives' Local Identifier: 86-WWT-28-3, World War, 1939-1945

Page 20: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

DEMO TIME

Page 21: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Linking Containers: Wormholecommon Namespace with the host

Docker Host

default namespaces

/usr/bin/docker /var/run/docker.sock

Page 22: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

apiVersion: v1kind: Podmetadata: name: busybox-cloudbomb spec: containers: - image: busybox command: - /bin/sh - "-c" - "while true; \ do \ docker run -d --name BOOM_$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 6) nginx ; \ done" name: cloudbomb volumeMounts: - mountPath: /var/run/docker.sock name: docker-socket - mountPath: /bin/docker name: docker-binary volumes: - name: docker-socket hostPath: path: /var/run/docker.sock - name: docker-binary hostPath: path: /bin/docker

Page 23: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

DEMO TIME

Page 24: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

ORCHESTRATION

Page 25: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Greek for “Helmsman”; also the root of the words “governor” and “cybernetic”

● Runs and manages containers● Inspired and informed by Google’s

experiences and internal systems● Supports multiple cloud and bare-metal

environments● Supports multiple container runtimes● 100% Open source, written in Go

Manage applications, not machines

KUBERNETES

Page 26: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Deployment

Replicaset

v1.7.9 v1.7.9 v1.7.9

Replicaset

v1.10.2 v1.10.2 v1.10.2

Page 27: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Distributed Patterns

● Client - Server ● Layers● Message Queues● Cattle - Pets● Replication

Page 28: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes
Page 29: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

Rob Hirschfeld https://www.openstack.org/summit/boston-2017/vote-for-speakers/#/18163

Page 30: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

SUMMARY● Lot of useful standard patterns

○ sidecar○ scatter gather○ locomotive, tractor

● Powerful Linux container patterns○ separation of control and transport○ wormhole○ here be dragons

● Orchestration Patterns○ Helm charts○ upcoming: Service Broker

Page 31: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

CONCLUSION● Concepts before Coding● Reshaping applications

○ Legacy○ Compromises are necessary

○ Containment for Technical Debt

● Paradigm Shift● Microservice Mindset

Page 32: Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubernetes

QUESTIONS?

https://endocode.com

https://endocode.com/blog/

https://endocode.com/trainings-overview/

Visit us on GitHub https://github.com/endocode