SlideShare a Scribd company logo
1 of 31
Download to read offline
Let The Computer Do It
Usage Of Declarative APIs
Frank Müller
•Oldenburg, Germany


•Born 1965


•Working at Kubermatic


•Team Lead Development


•@themue
Introduction Frank Müller
The World Of APIs Today
• Since many years using imperative APIs is normal


• Examples are XML-RPC, RESTful APIs, and gRPC


• Have proven themselves in simple client/server scenarios


• The load of multiple related calls lies with the client


• This increases in increasingly distributed and integrative fields of
application
Most APIs Work Imperative Frank Müller
Imperative Environments Frank Müller
Service A
Service B
Service C
Service D
Client
• Heat 300 ml of milk to lukewarm ✔


• Dissolve a tablespoon of margarine in it ✔


• Crumble a block of yeast into a tall glass and pour a little warm
milk and sugar over it; stir the yeast and let everything warm ✔


• Put 500 gr of flour with the rest of the milk and one egg in a
mixing bowl and mix 👀


• Ouch, I don't have any flour anymore 😱
Recipe As An Example Frank Müller
• Complexity grows disproportionately in distributed environments


• Error handlings and rollbacks even more


• Keeping business logic on client side is hard to synchronize


• Implementations and version in web and apps will differ


• Runtime for business logic has to be scalable too
Complexity in Distributed Environments Frank Müller
Complexity In Distributed Environments
The Idea Of Declarative APIs
• Move responsibility from client to a controller


• Describe wanted state in a well defined document


• Store document in a database


• Notify interested controllers about wanted state changes


• Let controller perform changes and document them in database


• Let controller also perform rollback in error case
Don't Control, Just Describe Frank Müller
• Services care for low level tasks


• Controllers care for business logic


• Controllers continuously reconcile the wanted state with the
current state


• Two options:


‣ Call the services


‣ Write documents for nested common business logic
Responsibilities Frank Müller
apiVersion: api.bettercode.eu/v1


kind: BreadBaking


metadata:


name: raisin_mare


client: frank_mueller


spec:


count: 1


weight: 1000gr


template:


name: mare


addons:


- name: raisins


weight: 200gr
Example Of Document Frank Müller
Declarative Environments Frank Müller
API Server
Bread Bakery


Controller
1. ...


2. ...


3. ...


4. ...


5. ...
Stew


Controller
BBQ


Controller
• Define controller specification


• Implement controller specification as data structure


• Implement controller processing additions, changes, and
deletions of documents


• Start controller with subscription to changes of interested
documents (can also be others than the own ones)


• Listen to notifications and process them
Process Frank Müller
Take A Look At Kubernetes
• API server receives documents via HTTP


• Documents are stored in high-available database etcd


• Scheduler compares wanted with current state and assigns
based on resources, restrictions, locations, and dependencies to
nodes


• Controller Manager manages resources and deployments,
monitors differences between current and wanted cluster state
and performs changes via API
Kubernetes Master Frank Müller
• Kubelet on each node performs installation if needed


• Kube-Proxy retrieves container images from internet or own
repositories


• Container runtime like Docker or containerd run the individual
containers
Kubernetes Nodes Frank Müller
Kubernetes Architecture Frank Müller
Master
Controller


Manager
API Server
etcd
Client


(e.g. kubectl)
Scheduler


Internet
Node
kubelet kube-proxy
Docker Pod
Pod
Node
kubelet kube-proxy
Docker Pod
Pod
• Own controllers can run in a cluster


• They subscribe to changes of standard objects and/or self-
defined objects


• Subscriptions may be filtered by meta-data, e.g. to react only on
ConfigMaps labeled for own controller


• API documents are specified via Custom Resource Definitions
(CRD)


• Changes are applied as according Custom Resources
Controllers Frank Müller
apiVersion: apiextensions.k8s.io/v1


kind: CustomResourceDefinition


metadata:


name: talks.api.bettercode.eu


spec:


group: api.bettercode.eu


versions:


- name: v1


served: true


storage: true


schema:


openAPIV3Schema:


type: object


properties:


spec:
Custom Resource Definition Frank Müller
type: object


properties:


title:


type: string


speaker:


type: string


time:


type: integer


scope: Namespaced


names:


plural: talks


singular: talk


kind: Talk


shortNames:


- tlk
• Deployment of a microservice


• Configuration of staging, cloud provider, network, and scaling


• Configuration of needed backend resources like volumes,
databases, caches, queues, logging, monitoring, and search


• Applying document (Custom Resource) leads to installation,
update, or reconfiguration of microservice


• CRD became quite large
Example Of Controller Usage Frank Müller
Why Not Commercial APIs Too?
Declarative Business Environment Frank Müller
Service A
Service B
Service C
External


Service
Controller X
Controller Y
API Server
Controller


Manager
Scheduler
apiVersion: api.bettercode.eu/v1


kind: BreadBaking


metadata:


name: raisin_mare


client: frank_mueller


spec:


count: 1


weight: 1000gr


template:


name: mare


addons:


- name: raisins


weight: 200gr
Custom Resource For Baking Bread Frank Müller
factory := informers.NewSharedInformerFactory(client, time.Second*30)


svcInformer = factory.Core().V1().Services().Informer()


svcInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{


AddFunc: addServiceHandler,


UpdateFunc: updateServiceHandler,


DeleteFunc: deleteServiceHandler,


})


go cd.svcInformer.Run(wait.NeverStop)


Specification As Code Frank Müller
type BreadBakingSpec struct {


Count int


Weight BreadBakingWeightSpec


...


}


type BreadBaking struct {


metav1.TypeMeta `json:",inline"`


metav1.ObjectMeta `json:"metadata,omitempty"`


Spec BreadBakingSpec `json:"spec"`


}
factory := informers.NewSharedInformerFactory(client, time.Second*30)


svcInformer = factory.Core().V1().Services().Informer()


svcInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{


AddFunc: addServiceHandler,


UpdateFunc: updateServiceHandler,


DeleteFunc: deleteServiceHandler,


})


go cd.svcInformer.Run(wait.NeverStop)


Registering And Run The Controller Frank Müller
func (b *BreadBakery) Register() {


factory := informers.NewSharedInformerFactory(b.client, time.Second*30)


breadBakingInformer = factory.Query("v1", "BreadBaking").Informer()


breadBakingInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{


AddFunc: b.addHandler,


UpdateFunc: b.updateHandler,


DeleteFunc: b.deleteHandler,


})


go b.breadBakingInformer.Run(wait.NeverStop)


}
factory := informers.NewSharedInformerFactory(client, time.Second*30)


svcInformer = factory.Core().V1().Services().Informer()


svcInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{


AddFunc: addServiceHandler,


UpdateFunc: updateServiceHandler,


DeleteFunc: deleteServiceHandler,


})


go cd.svcInformer.Run(wait.NeverStop)


Handle Added Resource Frank Müller
func (b *BreadBakery) addHandler(obj interface{}) {


bb := obj.(*BreadBaking)


// Check client and more.


if bb.Client() != b.client {


return


}


...


// Bake bread by calling according services.


...


}
• Microservices and external software for individual business
domains


• Controller for business processes


• Controller runtime for call documentation and distribution


• Clients and controller send documents to API server


• Documents allow to be handled individually


• Status is always transparent
Overview Frank Müller
• Own runtime similar to Kubernetes has to be build


• Only cares for documentation and distribution of business
process documents


• Runtime alternatively could be Kubernetes itself


• Still a less technical wrapper for Kubernetes API would be
needed
Runtime Frank Müller
Closing
• Complex business process are handled central


• Processing is scalable


• Versions are possible


• Process calls are documented


• Still different kind of thinking
Closing Frank Müller
Thanks a lot and


have a nice


evening


Image Sources


123RF


Pexels


iStockphoto


Own photos

More Related Content

Similar to Let The Computer Do It

How kubernetes operators can rescue dev secops in midst of a pandemic updated
How kubernetes operators can rescue dev secops in midst of a pandemic updatedHow kubernetes operators can rescue dev secops in midst of a pandemic updated
How kubernetes operators can rescue dev secops in midst of a pandemic updated
Shikha Srivastava
 
Tech talk specflow_bddx_hassa_nagy
Tech talk specflow_bddx_hassa_nagyTech talk specflow_bddx_hassa_nagy
Tech talk specflow_bddx_hassa_nagy
Skills Matter
 
ClusterAPI Overview - Managing multi-cloud Kubernetes Clusters - k8s Meetup@v...
ClusterAPI Overview - Managing multi-cloud Kubernetes Clusters - k8s Meetup@v...ClusterAPI Overview - Managing multi-cloud Kubernetes Clusters - k8s Meetup@v...
ClusterAPI Overview - Managing multi-cloud Kubernetes Clusters - k8s Meetup@v...
Tobias Schneck
 

Similar to Let The Computer Do It (20)

OSDC 2018 | Three years running containers with Kubernetes in Production by T...
OSDC 2018 | Three years running containers with Kubernetes in Production by T...OSDC 2018 | Three years running containers with Kubernetes in Production by T...
OSDC 2018 | Three years running containers with Kubernetes in Production by T...
 
How kubernetes operators can rescue dev secops in midst of a pandemic updated
How kubernetes operators can rescue dev secops in midst of a pandemic updatedHow kubernetes operators can rescue dev secops in midst of a pandemic updated
How kubernetes operators can rescue dev secops in midst of a pandemic updated
 
Kubernetes-Presentation-Syed-Murtaza-Hassan
Kubernetes-Presentation-Syed-Murtaza-HassanKubernetes-Presentation-Syed-Murtaza-Hassan
Kubernetes-Presentation-Syed-Murtaza-Hassan
 
IBM Bluemix OpenWhisk: Serverless Conference 2016, London, UK: The Future of ...
IBM Bluemix OpenWhisk: Serverless Conference 2016, London, UK: The Future of ...IBM Bluemix OpenWhisk: Serverless Conference 2016, London, UK: The Future of ...
IBM Bluemix OpenWhisk: Serverless Conference 2016, London, UK: The Future of ...
 
18th Athens Big Data Meetup - 2nd Talk - Run Spark and Flink Jobs on Kubernetes
18th Athens Big Data Meetup - 2nd Talk - Run Spark and Flink Jobs on Kubernetes18th Athens Big Data Meetup - 2nd Talk - Run Spark and Flink Jobs on Kubernetes
18th Athens Big Data Meetup - 2nd Talk - Run Spark and Flink Jobs on Kubernetes
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals Training
 
9th docker meetup 2016.07.13
9th docker meetup 2016.07.139th docker meetup 2016.07.13
9th docker meetup 2016.07.13
 
Deploy your machine learning models to production with Kubernetes
Deploy your machine learning models to production with KubernetesDeploy your machine learning models to production with Kubernetes
Deploy your machine learning models to production with Kubernetes
 
KFServing and Feast
KFServing and FeastKFServing and Feast
KFServing and Feast
 
[Workshop] API Management in Microservices Architecture
[Workshop] API Management in Microservices Architecture[Workshop] API Management in Microservices Architecture
[Workshop] API Management in Microservices Architecture
 
Tech talk specflow_bddx_hassa_nagy
Tech talk specflow_bddx_hassa_nagyTech talk specflow_bddx_hassa_nagy
Tech talk specflow_bddx_hassa_nagy
 
Francisco Javier Ramirez Urea - Hopla - OSL19
Francisco Javier Ramirez Urea - Hopla - OSL19Francisco Javier Ramirez Urea - Hopla - OSL19
Francisco Javier Ramirez Urea - Hopla - OSL19
 
Kube Overview and Kube Conformance Certification OpenSource101 Raleigh
Kube Overview and Kube Conformance Certification OpenSource101 RaleighKube Overview and Kube Conformance Certification OpenSource101 Raleigh
Kube Overview and Kube Conformance Certification OpenSource101 Raleigh
 
ClusterAPI Overview - Managing multi-cloud Kubernetes Clusters - k8s Meetup@v...
ClusterAPI Overview - Managing multi-cloud Kubernetes Clusters - k8s Meetup@v...ClusterAPI Overview - Managing multi-cloud Kubernetes Clusters - k8s Meetup@v...
ClusterAPI Overview - Managing multi-cloud Kubernetes Clusters - k8s Meetup@v...
 
Kubernetes "Ubernetes" Cluster Federation by Quinton Hoole (Google, Inc) Huaw...
Kubernetes "Ubernetes" Cluster Federation by Quinton Hoole (Google, Inc) Huaw...Kubernetes "Ubernetes" Cluster Federation by Quinton Hoole (Google, Inc) Huaw...
Kubernetes "Ubernetes" Cluster Federation by Quinton Hoole (Google, Inc) Huaw...
 
Edge 2016 Session 1886 Building your own docker container cloud on ibm power...
Edge 2016 Session 1886  Building your own docker container cloud on ibm power...Edge 2016 Session 1886  Building your own docker container cloud on ibm power...
Edge 2016 Session 1886 Building your own docker container cloud on ibm power...
 
The Evolution of Distributed Systems on Kubernetes
The Evolution of Distributed Systems on KubernetesThe Evolution of Distributed Systems on Kubernetes
The Evolution of Distributed Systems on Kubernetes
 
Develop and deploy Kubernetes applications with Docker - IBM Index 2018
Develop and deploy Kubernetes  applications with Docker - IBM Index 2018Develop and deploy Kubernetes  applications with Docker - IBM Index 2018
Develop and deploy Kubernetes applications with Docker - IBM Index 2018
 
Docker on docker leveraging kubernetes in docker ee
Docker on docker leveraging kubernetes in docker eeDocker on docker leveraging kubernetes in docker ee
Docker on docker leveraging kubernetes in docker ee
 
Mattia Gandolfi - Improving utilization and portability with Containers and C...
Mattia Gandolfi - Improving utilization and portability with Containers and C...Mattia Gandolfi - Improving utilization and portability with Containers and C...
Mattia Gandolfi - Improving utilization and portability with Containers and C...
 

More from Frank Müller

RESTful Web Applications with Google Go
RESTful Web Applications with Google GoRESTful Web Applications with Google Go
RESTful Web Applications with Google Go
Frank Müller
 

More from Frank Müller (20)

JAX 2023 - Cloud Provider APIs
JAX 2023 - Cloud Provider APIsJAX 2023 - Cloud Provider APIs
JAX 2023 - Cloud Provider APIs
 
JAX 2023 - Generics in Go
JAX 2023 - Generics in GoJAX 2023 - Generics in Go
JAX 2023 - Generics in Go
 
Concurrency with Go
Concurrency with GoConcurrency with Go
Concurrency with Go
 
2021 OOP - Kubernetes Operatoren
2021   OOP - Kubernetes Operatoren2021   OOP - Kubernetes Operatoren
2021 OOP - Kubernetes Operatoren
 
DevOpsCon - Verteilte Entwicklung in Go
DevOpsCon - Verteilte Entwicklung in GoDevOpsCon - Verteilte Entwicklung in Go
DevOpsCon - Verteilte Entwicklung in Go
 
Devs@Home - Einführung in Go
Devs@Home - Einführung in GoDevs@Home - Einführung in Go
Devs@Home - Einführung in Go
 
Fun with functions
Fun with functionsFun with functions
Fun with functions
 
Ein Gopher im Netz
Ein Gopher im NetzEin Gopher im Netz
Ein Gopher im Netz
 
Blockchains - Mehr als nur digitale Währungen
Blockchains - Mehr als nur digitale WährungenBlockchains - Mehr als nur digitale Währungen
Blockchains - Mehr als nur digitale Währungen
 
Spaß an der Nebenläufigkeit
Spaß an der NebenläufigkeitSpaß an der Nebenläufigkeit
Spaß an der Nebenläufigkeit
 
Go - Googles Sprache für skalierbare Systeme
Go - Googles Sprache für skalierbare SystemeGo - Googles Sprache für skalierbare Systeme
Go - Googles Sprache für skalierbare Systeme
 
Cloud Provisioning mit Juju
Cloud Provisioning mit JujuCloud Provisioning mit Juju
Cloud Provisioning mit Juju
 
Juju - Scalable Software with Google Go
Juju - Scalable Software with Google GoJuju - Scalable Software with Google Go
Juju - Scalable Software with Google Go
 
RESTful Web Applications with Google Go
RESTful Web Applications with Google GoRESTful Web Applications with Google Go
RESTful Web Applications with Google Go
 
Clouds, leicht beherrschbar
Clouds, leicht beherrschbarClouds, leicht beherrschbar
Clouds, leicht beherrschbar
 
Skalierbare Anwendungen mit Google Go
Skalierbare Anwendungen mit Google GoSkalierbare Anwendungen mit Google Go
Skalierbare Anwendungen mit Google Go
 
WTC 2013 - Juju - Mit etwas Magie zur perfekten Cloud
WTC 2013 - Juju - Mit etwas Magie zur perfekten CloudWTC 2013 - Juju - Mit etwas Magie zur perfekten Cloud
WTC 2013 - Juju - Mit etwas Magie zur perfekten Cloud
 
Juju - Google Go in a scalable Environment
Juju - Google Go in a scalable EnvironmentJuju - Google Go in a scalable Environment
Juju - Google Go in a scalable Environment
 
OOP 2013 - Weltweite Entwicklung von Open Source Software
OOP 2013 - Weltweite Entwicklung von Open Source SoftwareOOP 2013 - Weltweite Entwicklung von Open Source Software
OOP 2013 - Weltweite Entwicklung von Open Source Software
 
Beauty and Power of Go
Beauty and Power of GoBeauty and Power of Go
Beauty and Power of Go
 

Recently uploaded

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Recently uploaded (20)

MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 

Let The Computer Do It

  • 1. Let The Computer Do It Usage Of Declarative APIs Frank Müller
  • 2. •Oldenburg, Germany •Born 1965 •Working at Kubermatic •Team Lead Development •@themue Introduction Frank Müller
  • 3. The World Of APIs Today
  • 4. • Since many years using imperative APIs is normal • Examples are XML-RPC, RESTful APIs, and gRPC • Have proven themselves in simple client/server scenarios • The load of multiple related calls lies with the client • This increases in increasingly distributed and integrative fields of application Most APIs Work Imperative Frank Müller
  • 5. Imperative Environments Frank Müller Service A Service B Service C Service D Client
  • 6. • Heat 300 ml of milk to lukewarm ✔ • Dissolve a tablespoon of margarine in it ✔ • Crumble a block of yeast into a tall glass and pour a little warm milk and sugar over it; stir the yeast and let everything warm ✔ • Put 500 gr of flour with the rest of the milk and one egg in a mixing bowl and mix 👀 • Ouch, I don't have any flour anymore 😱 Recipe As An Example Frank Müller
  • 7. • Complexity grows disproportionately in distributed environments • Error handlings and rollbacks even more • Keeping business logic on client side is hard to synchronize • Implementations and version in web and apps will differ • Runtime for business logic has to be scalable too Complexity in Distributed Environments Frank Müller Complexity In Distributed Environments
  • 8. The Idea Of Declarative APIs
  • 9. • Move responsibility from client to a controller • Describe wanted state in a well defined document • Store document in a database • Notify interested controllers about wanted state changes • Let controller perform changes and document them in database • Let controller also perform rollback in error case Don't Control, Just Describe Frank Müller
  • 10. • Services care for low level tasks • Controllers care for business logic • Controllers continuously reconcile the wanted state with the current state • Two options: ‣ Call the services ‣ Write documents for nested common business logic Responsibilities Frank Müller
  • 11. apiVersion: api.bettercode.eu/v1 kind: BreadBaking metadata: name: raisin_mare client: frank_mueller spec: count: 1 weight: 1000gr template: name: mare addons: - name: raisins weight: 200gr Example Of Document Frank Müller
  • 12. Declarative Environments Frank Müller API Server Bread Bakery 
 Controller 1. ... 2. ... 3. ... 4. ... 5. ... Stew 
 Controller BBQ 
 Controller
  • 13. • Define controller specification • Implement controller specification as data structure • Implement controller processing additions, changes, and deletions of documents • Start controller with subscription to changes of interested documents (can also be others than the own ones) • Listen to notifications and process them Process Frank Müller
  • 14. Take A Look At Kubernetes
  • 15. • API server receives documents via HTTP • Documents are stored in high-available database etcd • Scheduler compares wanted with current state and assigns based on resources, restrictions, locations, and dependencies to nodes • Controller Manager manages resources and deployments, monitors differences between current and wanted cluster state and performs changes via API Kubernetes Master Frank Müller
  • 16. • Kubelet on each node performs installation if needed • Kube-Proxy retrieves container images from internet or own repositories • Container runtime like Docker or containerd run the individual containers Kubernetes Nodes Frank Müller
  • 17. Kubernetes Architecture Frank Müller Master Controller 
 Manager API Server etcd Client 
 (e.g. kubectl) Scheduler 
 Internet Node kubelet kube-proxy Docker Pod Pod Node kubelet kube-proxy Docker Pod Pod
  • 18. • Own controllers can run in a cluster • They subscribe to changes of standard objects and/or self- defined objects • Subscriptions may be filtered by meta-data, e.g. to react only on ConfigMaps labeled for own controller • API documents are specified via Custom Resource Definitions (CRD) • Changes are applied as according Custom Resources Controllers Frank Müller
  • 19. apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: talks.api.bettercode.eu spec: group: api.bettercode.eu versions: - name: v1 served: true storage: true schema: openAPIV3Schema: type: object properties: spec: Custom Resource Definition Frank Müller type: object properties: title: type: string speaker: type: string time: type: integer scope: Namespaced names: plural: talks singular: talk kind: Talk shortNames: - tlk
  • 20. • Deployment of a microservice • Configuration of staging, cloud provider, network, and scaling • Configuration of needed backend resources like volumes, databases, caches, queues, logging, monitoring, and search • Applying document (Custom Resource) leads to installation, update, or reconfiguration of microservice • CRD became quite large Example Of Controller Usage Frank Müller
  • 21. Why Not Commercial APIs Too?
  • 22. Declarative Business Environment Frank Müller Service A Service B Service C External 
 Service Controller X Controller Y API Server Controller 
 Manager Scheduler
  • 23. apiVersion: api.bettercode.eu/v1 kind: BreadBaking metadata: name: raisin_mare client: frank_mueller spec: count: 1 weight: 1000gr template: name: mare addons: - name: raisins weight: 200gr Custom Resource For Baking Bread Frank Müller
  • 24. factory := informers.NewSharedInformerFactory(client, time.Second*30) svcInformer = factory.Core().V1().Services().Informer() svcInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: addServiceHandler, UpdateFunc: updateServiceHandler, DeleteFunc: deleteServiceHandler, }) go cd.svcInformer.Run(wait.NeverStop) Specification As Code Frank Müller type BreadBakingSpec struct { Count int Weight BreadBakingWeightSpec ... } type BreadBaking struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` Spec BreadBakingSpec `json:"spec"` }
  • 25. factory := informers.NewSharedInformerFactory(client, time.Second*30) svcInformer = factory.Core().V1().Services().Informer() svcInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: addServiceHandler, UpdateFunc: updateServiceHandler, DeleteFunc: deleteServiceHandler, }) go cd.svcInformer.Run(wait.NeverStop) Registering And Run The Controller Frank Müller func (b *BreadBakery) Register() { factory := informers.NewSharedInformerFactory(b.client, time.Second*30) breadBakingInformer = factory.Query("v1", "BreadBaking").Informer() breadBakingInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: b.addHandler, UpdateFunc: b.updateHandler, DeleteFunc: b.deleteHandler, }) go b.breadBakingInformer.Run(wait.NeverStop) }
  • 26. factory := informers.NewSharedInformerFactory(client, time.Second*30) svcInformer = factory.Core().V1().Services().Informer() svcInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: addServiceHandler, UpdateFunc: updateServiceHandler, DeleteFunc: deleteServiceHandler, }) go cd.svcInformer.Run(wait.NeverStop) Handle Added Resource Frank Müller func (b *BreadBakery) addHandler(obj interface{}) { bb := obj.(*BreadBaking) // Check client and more. if bb.Client() != b.client { return } ... // Bake bread by calling according services. ... }
  • 27. • Microservices and external software for individual business domains • Controller for business processes • Controller runtime for call documentation and distribution • Clients and controller send documents to API server • Documents allow to be handled individually • Status is always transparent Overview Frank Müller
  • 28. • Own runtime similar to Kubernetes has to be build • Only cares for documentation and distribution of business process documents • Runtime alternatively could be Kubernetes itself • Still a less technical wrapper for Kubernetes API would be needed Runtime Frank Müller
  • 30. • Complex business process are handled central • Processing is scalable • Versions are possible • Process calls are documented • Still different kind of thinking Closing Frank Müller
  • 31. Thanks a lot and have a nice evening Image Sources 123RF Pexels iStockphoto Own photos