Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ahoi! Complex applications on Kubernetes
Search
Lukas Rieder
June 13, 2019
Technology
0
75
Ahoi! Complex applications on Kubernetes
This is a talk I gave at the 60th Berlin Elixir UG on Jun 13
Lukas Rieder
June 13, 2019
Tweet
Share
More Decks by Lukas Rieder
See All by Lukas Rieder
Modeling Document Databases
overbryd
1
130
Flow Based Programming in 2 minutes
overbryd
0
70
Metabase UG, November 2018
overbryd
0
120
Flow Based Programming in Elixir
overbryd
0
160
Configuration in Elixir
overbryd
0
170
Metabase, three good practises for a hosted setup
overbryd
0
92
Elixir Deployment
overbryd
1
53
NIFs and C-Nodes
overbryd
0
66
SQL Workshop Part 1
overbryd
0
120
Other Decks in Technology
See All in Technology
LT Slide 2025-04-22
takesection
0
100
CodeRabbitと過ごした1ヶ月 ─ AIコードレビュー導入で実感したチーム開発の進化
mitohato14
0
200
もう難しくない!誰でもカンタンDocker入門 〜30分であなたのPCにアプリを立ち上げる〜
devops_vtj
0
170
Dataverseの検索列について
miyakemito
1
150
【Oracle Cloud ウェビナー】ご希望のクラウドでOracle Databaseを実行〜マルチクラウド・ソリューション徹底解説〜
oracle4engineer
PRO
1
140
Azure Maps Visual in PowerBIで分析しよう
nakasho
0
180
Microsoft の SSE の現在地
skmkzyk
0
270
Perl歴約10年のエンジニアがフルスタックTypeScriptに出会ってみた
papix
1
250
MCPを理解する
yudai00
12
8.3k
Oracle Cloud Infrastructure:2025年4月度サービス・アップデート
oracle4engineer
PRO
0
260
AIコーディングの最前線 〜活用のコツと課題〜
pharma_x_tech
4
2.9k
OpsJAWS34_CloudTrailLake_for_Organizations
hiashisan
0
230
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.7k
Why You Should Never Use an ORM
jnunemaker
PRO
56
9.3k
The Invisible Side of Design
smashingmag
299
50k
Agile that works and the tools we love
rasmusluckow
329
21k
Done Done
chrislema
184
16k
Testing 201, or: Great Expectations
jmmastey
42
7.5k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.8k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
How to Think Like a Performance Engineer
csswizardry
23
1.5k
Code Reviewing Like a Champion
maltzj
523
40k
Faster Mobile Websites
deanohume
306
31k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
23
2.7k
Transcript
Ahoi!
Your captain today is Lukas Rieder.
I run a data consultancy. https://www.hibase.co/
I give talks. https://speakerdeck.com/Overbryd
Complex applications.
What are complex applications?
We start out simple…
We extend…
and store…
and integrate.
The world is complex. Simply manage it.
Complex applications.
Introducing Kubernetes.
Imagine an Elixir Supervisor. children = [ %{ id: MyApplication,
start: {MyApplication, :start_link, [[:hello]]} } ] {:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one)
Imagine an Elixir Supervisor. children = [ %{ id: MyApplication,
start: {MyApplication, :start_link, [[:hello]]} } ] {:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one)
Imagine an Elixir Supervisor. children = [ %{ id: MyApplication,
start: {MyApplication, :start_link, [[:hello]]} } ] {:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one)
Imagine an Elixir Supervisor. Supervisor.count_children(pid) #=> %{active: 1, specs: 1,
supervisors: 0, workers: 1}
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"]
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
Single-responsibility principle. Job Service Ingress Deployment Supervisor Processes Elixir Kubernetes
Organized in graphs. Elixir Kubernetes
State converges.
Extend Kubernetes with Elixir.
Meet the operator pattern.
Meet the operator pattern. Operators are a combination of K8
resources.
Meet the operator pattern. It allows developers to encode domain
knowledge into an extension of the K8s API.
Custom Resource Definition Controller API Custom Resource Meet the operator
pattern.
Custom Resource Definition Controller API Custom Resource The CRD defines
your object through a schema.
Custom Resource Definition Controller API Custom Resource Resources are the
common declarative language, to describe a desired state.
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
Custom Resource Definition Controller API Custom Resource The API handles
CRUD, storage, changes, etc.
Custom Resource Definition Controller API Custom Resource The controller implements
domain specific knowledge.
Custom Resource Definition Controller API Custom Resource The controller manages
K8s and Custom resources for the given application domain.
Why Elixir?
Excellent state handling. Process Process
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}] } ] } } } }
There are great libraries. https://github.com/coryodaniel/bonny https://github.com/coryodaniel/k8s
Inter-cluster communication. Solved. BeamVM BeamVM BeamVM BeamVM
Long running. High self sufficiency.
Real world examples.
hs-preview "As a customer, I want to see my campaigns
live, to check if they meet my expectations."
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
hs-preview Controller Ingress Deployment Service www.example.com git:feat/xyz
hs-preview Controller Ingress Deployment Service www.example.com git:feat/xyz
hs-preview Controller Ingress Deployment Service www.example.com preview-b32bef.example.com git:feat/xyz
hs-preview Ingress Deployment Service www.example.com Ingress preview-b32bef.example.com Controller git:feat/xyz
hs-preview Ingress Deployment Service www.example.com Ingress Deployment preview-b32bef.example.com Controller git:feat/xyz
hs-preview Ingress Deployment Service www.example.com Ingress Deployment Service preview-b32bef.example.com Controller
git:feat/xyz
hs-preview Ingress Deployment Service www.example.com Ingress Deployment Service preview-b32bef.example.com Domain
Controller git:feat/xyz
hs-preview preview-b32bef.example.com git:feat/xyz
hs-preview https://tech.highsnobiety.com/optimizing-our-deployment- pipeline-part-1-3fb04e727013
Software multitenancy "As a customer, I want my workflows to
run in a predictable and reliable manner."
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
Customer Database Scheduler Job (k8s) Namespace (k8s) Deployment (k8s) Customer
Controller API Database Controller Scheduler Controller Software multitenancy
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)
Robots building robots.
Getting started
Getting started ✓ Docker / Docker for Mac ✓ minikube
/ Kubernetes ✓ Elixir, Erlang ✓ bonni / k8s
Docker for mac is a one-stop-shop.
Example: global connection pools "As a customer, I want my
database to be running at all times, in order to make money."
Example: global connection pools App
Example: global connection pools App Worker 1
Example: global connection pools App Worker 1 Worker 2
Example: global connection pools App Worker 1 Worker 2
Example: global connection pools App Worker 1 Worker 2 pgbouncer
Example: global connection pools App Worker 1 Worker 2 pgbouncer
pgbouncer Customer A Customer B
Example: global connection pools Terminal time
Thank you for having me.
Contact: lukas@hibase.co