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
71
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
120
Flow Based Programming in 2 minutes
overbryd
0
66
Metabase UG, November 2018
overbryd
0
120
Flow Based Programming in Elixir
overbryd
0
150
Configuration in Elixir
overbryd
0
170
Metabase, three good practises for a hosted setup
overbryd
0
89
Elixir Deployment
overbryd
1
51
NIFs and C-Nodes
overbryd
0
65
SQL Workshop Part 1
overbryd
0
120
Other Decks in Technology
See All in Technology
re:Invent2024 KeynoteのAmazon Q Developer考察
yusukeshimizu
1
160
【Oracle Cloud ウェビナー】2025年のセキュリティ脅威を読み解く:リスクに備えるためのレジリエンスとデータ保護
oracle4engineer
PRO
1
110
Reactフレームワークプロダクトを モバイルアプリにして、もっと便利に。 ユーザに価値を届けよう。/React Framework with Capacitor
rdlabo
0
140
「隙間家具OSS」に至る道/Fujiwara Tech Conference 2025
fujiwara3
7
6.6k
2025年に挑戦したいこと
molmolken
0
180
[IBM TechXchange Dojo]Watson Discoveryとwatsonx.aiでRAGを実現!事例のご紹介+座学②
siyuanzh09
0
120
Visual StudioとかIDE関連小ネタ話
kosmosebi
1
380
20250122_個人向けCopilotどうなん
ponponmikankan
0
130
2024AWSで個人的にアツかったアップデート
nagisa53
1
110
PaaSの歴史と、 アプリケーションプラットフォームのこれから
jacopen
7
1.5k
データ基盤におけるIaCの重要性とその運用
mtpooh
4
620
2025年の挑戦 コーポレートエンジニアの技術広報/techpr5
nishiuma
0
150
Featured
See All Featured
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
360
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Building Applications with DynamoDB
mza
93
6.2k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
870
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
4 Signs Your Business is Dying
shpigford
182
22k
Measuring & Analyzing Core Web Vitals
bluesmoon
5
210
Agile that works and the tools we love
rasmusluckow
328
21k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
Designing Experiences People Love
moore
139
23k
Practical Orchestrator
shlominoach
186
10k
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:
[email protected]