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
73
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
68
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
52
NIFs and C-Nodes
overbryd
0
65
SQL Workshop Part 1
overbryd
0
120
Other Decks in Technology
See All in Technology
新卒エンジニア研修の試行錯誤と工夫/nikkei-tech-talk-31
nishiuma
0
190
Go製のマイグレーションツールの git-schemalex の紹介と運用方法
shinnosuke_kishida
1
370
スケールアップ企業のQA組織のバリューを最大限に引き出すための取り組み
tarappo
4
890
AWS のポリシー言語 Cedar を活用した高速かつスケーラブルな認可技術の探求 #phperkaigi / PHPerKaigi 2025
ytaka23
7
1.5k
Vision Language Modelを活用した メルカリの類似画像レコメンドの性能改善
yadayuki
9
1.2k
LINEギフトのLINEミニアプリアクセシビリティ改善事例
lycorptech_jp
PRO
0
230
SpannerとAurora DSQLの同時実行制御の違いに想いを馳せる
masakikato5
0
560
技術好きなエンジニアが _リーダーへの進化_ によって得たものと失ったもの / The Gains and Losses of a Tech-Enthusiast Engineer’s “Evolution into Leadership”
kaminashi
0
200
LINE Notify互換のボットを作った話
kenichirokimura
0
170
Explainable Software Engineering in the Public Sector
avandeursen
0
350
モンテカルロ木探索のパフォーマンスを予測する Kaggleコンペ解説 〜生成AIによる未知のゲーム生成〜
rist
4
1k
グループポリシー再確認
murachiakira
0
160
Featured
See All Featured
Making Projects Easy
brettharned
116
6.1k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Raft: Consensus for Rubyists
vanstee
137
6.8k
Facilitating Awesome Meetings
lara
53
6.3k
Fontdeck: Realign not Redesign
paulrobertlloyd
83
5.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
227
22k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.4k
It's Worth the Effort
3n
184
28k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Reflections from 52 weeks, 52 projects
jeffersonlam
349
20k
Bash Introduction
62gerente
611
210k
Unsuck your backbone
ammeep
670
57k
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