Slide 1

Slide 1 text

Ahoi!

Slide 2

Slide 2 text

Your captain today is Lukas Rieder.

Slide 3

Slide 3 text

I run a data consultancy. https://www.hibase.co/

Slide 4

Slide 4 text

I give talks. https://speakerdeck.com/Overbryd

Slide 5

Slide 5 text

Complex applications.

Slide 6

Slide 6 text

What are complex applications?

Slide 7

Slide 7 text

We start out simple…

Slide 8

Slide 8 text

We extend…

Slide 9

Slide 9 text

and store…

Slide 10

Slide 10 text

and integrate.

Slide 11

Slide 11 text

The world is complex.
 Simply manage it.

Slide 12

Slide 12 text

Complex applications.

Slide 13

Slide 13 text

Introducing Kubernetes.

Slide 14

Slide 14 text

Imagine an Elixir Supervisor. children = [
 %{
 id: MyApplication,
 start: {MyApplication, :start_link, [[:hello]]}
 }
 ]
 
 {:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one)

Slide 15

Slide 15 text

Imagine an Elixir Supervisor. children = [
 %{
 id: MyApplication,
 start: {MyApplication, :start_link, [[:hello]]}
 }
 ]
 
 {:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one)

Slide 16

Slide 16 text

Imagine an Elixir Supervisor. children = [
 %{
 id: MyApplication,
 start: {MyApplication, :start_link, [[:hello]]}
 }
 ]
 
 {:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one)

Slide 17

Slide 17 text

Imagine an Elixir Supervisor. Supervisor.count_children(pid)
 #=> %{active: 1, specs: 1, supervisors: 0, workers: 1}

Slide 18

Slide 18 text

A Deployment in Kubernetes. apiVersion: apps/v1
 kind: Deployment
 metadata:
 name: my-app
 labels:
 app: my-app
 spec:
 # ... snip ...
 template:
 spec:
 containers:
 - name: my-container
 image: my-app:1.7.9
 command: ["myapp", "start_link"]
 args: ["hello"]


Slide 19

Slide 19 text

Elixir Declarative programming. apiVersion: apps/v1
 kind: Deployment
 metadata:
 name: my-app
 labels:
 app: my-app
 spec:
 # ... snip ...
 template:
 spec:
 containers:
 - name: my-container
 image: my-app:1.7.9
 command: ["myapp", "start_link"]
 args: ["hello"]
 children = [
 %{
 id: MyApplication,
 start: {MyApplication, :start_link, [[:hello]]}
 }
 ]
 
 {:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one) Kubernetes

Slide 20

Slide 20 text

Single-responsibility principle. Job Service Ingress Deployment Supervisor Processes Elixir Kubernetes

Slide 21

Slide 21 text

Organized in graphs. Elixir Kubernetes

Slide 22

Slide 22 text

State converges.

Slide 23

Slide 23 text

Extend Kubernetes with Elixir.

Slide 24

Slide 24 text

Meet the operator pattern.

Slide 25

Slide 25 text

Meet the operator pattern. Operators are a combination of K8 resources.

Slide 26

Slide 26 text

Meet the operator pattern. It allows developers to encode domain knowledge
 into an extension of the K8s API.

Slide 27

Slide 27 text

Custom
 Resource
 Definition Controller API Custom
 Resource Meet the operator pattern.

Slide 28

Slide 28 text

Custom
 Resource
 Definition Controller API Custom
 Resource The CRD defines your object through a schema.

Slide 29

Slide 29 text

Custom
 Resource
 Definition Controller API Custom
 Resource Resources are the common declarative language, to describe a desired state.

Slide 30

Slide 30 text

Custom
 Resource
 Definition Controller API Custom
 Resource apiVersion: apiextensions.k8s.io/v1beta1
 kind: CustomResourceDefinition
 metadata:
 name: crontabs.stable.example.com
 spec:
 group: stable.example.com
 versions:
 - name: v1
 served: true
 storage: true
 scope: Namespaced
 names:
 plural: crontabs
 singular: crontab
 kind: CronTab
 shortNames:
 - ct


Slide 31

Slide 31 text

Custom
 Resource
 Definition Controller API Custom
 Resource The API handles CRUD, storage, changes, etc.

Slide 32

Slide 32 text

Custom
 Resource
 Definition Controller API Custom
 Resource The controller implements domain specific knowledge.

Slide 33

Slide 33 text

Custom
 Resource
 Definition Controller API Custom
 Resource The controller manages K8s and Custom resources for the given application domain.

Slide 34

Slide 34 text

Why Elixir?

Slide 35

Slide 35 text

Excellent state handling. Process Process

Slide 36

Slide 36 text

Pattern matching. Deconstruction. %{ "apiVersion" => "apps/v1", "kind" => "Deployment", "metadata" => %{ "labels" => %{"app" => "nginx"}, "name" => "nginx-deployment", "namespace" => "default" }, "spec" => %{ "replicas" => 3, "selector" => %{"matchLabels" => %{"app" => "nginx"}}, "template" => %{ "metadata" => %{"labels" => %{"app" => "nginx"}}, "spec" => %{ "containers" => [ %{ "image" => "nginx:1.7.9", "name" => "nginx", "ports" => [%{"containerPort" => 80}] } ] } } } }

Slide 37

Slide 37 text

There are great libraries. https://github.com/coryodaniel/bonny https://github.com/coryodaniel/k8s

Slide 38

Slide 38 text

Inter-cluster communication. Solved. BeamVM BeamVM BeamVM BeamVM

Slide 39

Slide 39 text

Long running. High self sufficiency.

Slide 40

Slide 40 text

Real world examples.

Slide 41

Slide 41 text

hs-preview "As a customer, I want to see my campaigns live, to check if they meet my expectations."

Slide 42

Slide 42 text

hs-preview www.example.com staging.example.com preview-aefd23.example.com preview-b32bef.example.com git:master git:live git:feat/abc git:feat/xyz

Slide 43

Slide 43 text

hs-preview Controller Ingress Deployment Service www.example.com git:feat/xyz

Slide 44

Slide 44 text

hs-preview Controller Ingress Deployment Service www.example.com git:feat/xyz

Slide 45

Slide 45 text

hs-preview Controller Ingress Deployment Service www.example.com preview-b32bef.example.com git:feat/xyz

Slide 46

Slide 46 text

hs-preview Ingress Deployment Service www.example.com Ingress preview-b32bef.example.com Controller git:feat/xyz

Slide 47

Slide 47 text

hs-preview Ingress Deployment Service www.example.com Ingress Deployment preview-b32bef.example.com Controller git:feat/xyz

Slide 48

Slide 48 text

hs-preview Ingress Deployment Service www.example.com Ingress Deployment Service preview-b32bef.example.com Controller git:feat/xyz

Slide 49

Slide 49 text

hs-preview Ingress Deployment Service www.example.com Ingress Deployment Service preview-b32bef.example.com Domain Controller git:feat/xyz

Slide 50

Slide 50 text

hs-preview preview-b32bef.example.com git:feat/xyz

Slide 51

Slide 51 text

hs-preview https://tech.highsnobiety.com/optimizing-our-deployment- pipeline-part-1-3fb04e727013

Slide 52

Slide 52 text

Software multitenancy "As a customer, I want my workflows to run in a predictable and reliable manner."

Slide 53

Slide 53 text

Customer apiVersion: "internal.example.com/v1"
 kind: Customer
 metadata:
 name: big-client-0815
 spec:
 features:
 database:
 enabled: true
 storage: 256gb
 scheduler:
 enabled: true
 workers: 4
 webhooks:
 enabled: false
 Software multitenancy

Slide 54

Slide 54 text

Customer Database Scheduler Job
 (k8s) Namespace
 (k8s) Deployment
 (k8s) Customer
 Controller API Database
 Controller Scheduler
 Controller Software multitenancy

Slide 55

Slide 55 text

Software multitenancy Customer Database Scheduler Job
 (k8s) Namespace
 (k8s) Deployment
 (k8s) Customer Database Scheduler Job
 (k8s) Namespace
 (k8s) Deployment
 (k8s) Customer Database Scheduler Job
 (k8s) Namespace
 (k8s) Deployment
 (k8s)

Slide 56

Slide 56 text

Robots building robots.

Slide 57

Slide 57 text

Getting started

Slide 58

Slide 58 text

Getting started ✓ Docker / Docker for Mac ✓ minikube / Kubernetes ✓ Elixir, Erlang ✓ bonni / k8s

Slide 59

Slide 59 text

Docker for mac is a one-stop-shop.

Slide 60

Slide 60 text

Example: global connection pools "As a customer, I want my database to be running at all times, in order to make money."

Slide 61

Slide 61 text

Example: global connection pools App

Slide 62

Slide 62 text

Example: global connection pools App Worker 1

Slide 63

Slide 63 text

Example: global connection pools App Worker 1 Worker 2

Slide 64

Slide 64 text

Example: global connection pools App Worker 1 Worker 2

Slide 65

Slide 65 text

Example: global connection pools App Worker 1 Worker 2 pgbouncer

Slide 66

Slide 66 text

Example: global connection pools App Worker 1 Worker 2 pgbouncer pgbouncer Customer A Customer B

Slide 67

Slide 67 text

Example: global connection pools Terminal time

Slide 68

Slide 68 text

Thank you for having me.

Slide 69

Slide 69 text