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
76
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
130
Flow Based Programming in Elixir
overbryd
0
160
Configuration in Elixir
overbryd
0
180
Metabase, three good practises for a hosted setup
overbryd
0
97
Elixir Deployment
overbryd
1
56
NIFs and C-Nodes
overbryd
0
69
SQL Workshop Part 1
overbryd
0
130
Other Decks in Technology
See All in Technology
Understanding_Thread_Tuning_for_Inference_Servers_of_Deep_Models.pdf
lycorptech_jp
PRO
0
140
2年でここまで成長!AWSで育てたAI Slack botの軌跡
iwamot
PRO
4
770
登壇ネタの見つけ方 / How to find talk topics
pinkumohikan
5
530
mrubyと micro-ROSが繋ぐロボットの世界
kishima
2
350
米国国防総省のDevSecOpsライフサイクルをAWSのセキュリティサービスとOSSで実現
syoshie
2
1.2k
生成AI時代の開発組織・技術・プロセス 〜 ログラスの挑戦と考察 〜
itohiro73
1
290
Wasm元年
askua
0
150
「Chatwork」の認証基盤の移行とログ活用によるプロダクト改善
kubell_hr
1
200
エンジニア向け技術スタック情報
kauche
1
280
JEDAI Databricks Free Editionもくもく会
taka_aki
1
100
Абьюзим random_bytes(). Фёдор Кулаков, разработчик Lamoda Tech
lamodatech
0
350
TechLION vol.41~MySQLユーザ会のほうから来ました / techlion41_mysql
sakaik
0
190
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Site-Speed That Sticks
csswizardry
10
660
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
17
940
Why Our Code Smells
bkeepers
PRO
337
57k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
800
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
181
53k
Facilitating Awesome Meetings
lara
54
6.4k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
For a Future-Friendly Web
brad_frost
179
9.8k
What's in a price? How to price your products and services
michaelherold
246
12k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
How to train your dragon (web standard)
notwaldorf
94
6.1k
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]