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
68
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
110
Flow Based Programming in 2 minutes
overbryd
0
61
Metabase UG, November 2018
overbryd
0
110
Flow Based Programming in Elixir
overbryd
0
140
Configuration in Elixir
overbryd
0
120
Metabase, three good practises for a hosted setup
overbryd
0
81
Elixir Deployment
overbryd
1
46
NIFs and C-Nodes
overbryd
0
61
SQL Workshop Part 1
overbryd
0
100
Other Decks in Technology
See All in Technology
AOAI をきっかけに 社内の Azure 管理を見直した話
recruitengineers
PRO
1
270
EMとして2023年度に頑張ったこと / What we did well in FY2023 as a EM
pauli
1
170
競技としてのKaggle、役に立つKaggle
yu4u
2
330
Gitlab本から学んだこと - そーだいなるプレイバック / gitlab-book
soudai
4
230
本当のAWS基礎
toru_kubota
0
510
Postman v10リリース後を振り返る / Looking back at Postman v10 after release
yokawasa
1
160
Delivering Millions of Messages within seconds @ Duolingo
pelelgrino
0
350
家族アルバム みてねにおけるGrafana活用術 / Grafana Meetup Japan Vol.1 LT
isaoshimizu
1
600
Python と Snowflake はズッ友だょ!~ Snowflake の Python 関連機能をふりかえる ~
__allllllllez__
1
120
APIファーストなプロダクトマネジメントの実践 〜SaaSus Platformでの例〜 / "Practicing API-First Product Management - An Example with SaaSus Platform
oztick139
0
100
Compose Compiler Metricsを使った実践的なコードレビュー
tomorrowkey
1
220
MLOpsの「壁」を乗り越える、LINEヤフーの Data Quality as Code
lycorptech_jp
PRO
5
500
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.6k
Optimizing for Happiness
mojombo
370
69k
Designing for humans not robots
tammielis
248
25k
The Power of CSS Pseudo Elements
geoffreycrofte
60
5k
The Invisible Side of Design
smashingmag
294
49k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
14
1.6k
Six Lessons from altMBA
skipperchong
21
3k
Visualization
eitanlees
136
14k
Being A Developer After 40
akosma
57
580k
Automating Front-end Workflow
addyosmani
1356
200k
Ruby is Unlike a Banana
tanoku
96
10k
Building a Modern Day E-commerce SEO Strategy
aleyda
17
6.4k
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]