Intro to creating kubernetes operators

Intro to Creating
Kubernetes
Operators
... and what can a framework do for you
About me
● Attila Mészáros (csviri@gmail.com)
● 10+ years Java developer / architect
● Last 3 years more on platform teams
● Currently: Senior Software Engineer @
○ Building multi-cloud platform
○ Golang, K8S, AWS (on-prem, GCP, AZURE)
(Java) + Everything around
● Free Time
○ ❤Rust❤
○ co-creator of Java Operator SDK
Agenda
● Intro to Kubernetes Operators
● Simple Example
● Intro To Java Operator SDK
● Common problems and how we solve them
● Event Sources and the power of operators
Extending K8S API - CRDs
● Define Custom Type in K8S: Custom
Resource Defintion
● Abstraction over a more complex
domain
● Instance of our type we call Custom
Resource
● “kubectl apply” this =>
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: webservers.sample.javaoperatorsdk
spec:
group: sample.javaoperatorsdk
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
html:
type: string
scope: Namespaced
names:
plural: webservers
singular: webserver
kind: WebServer
shortNames:
- ws
Sample Custom Resource
apiVersion: "sample.javaoperatorsdk/v1"
kind: WebServer
metadata:
name: hellows
spec:
html: |
<html>
<head>
<title>Hello Operator World</title>
</head>
<body>
Hello Meetup
</body>
</html>
● simple examples: abstraction over
static website
Kubernetes Operator - Definition
● “Operators are software extensions to Kubernetes that make use of custom resources to
manage applications and their components. Operators follow Kubernetes principles, notably the
control loop.”
● That’s it, K8S does not provide any additional facilities. Only:
○ Extension to API - CRD/CR
○ and the operations we have on K8S Objects: CRUD, Patch, Watch
○ (ok for golang it kinda provides )
What is a control loop?
The Operator Pattern
● At the end it’s a Pod watching
Custom Resources
● and Reconciling the desired state
with the target world
Demo Time - WebServer Example
Managing K8S and non-K8S Resources
● Manage all well known K8S resources (pods, config maps, ingress, service, pv)
○ Create nice abstractions
○ Deploy/Manage Complex Applications (Kafka, Postgres)
○ Flux
● External Resources (or anything that has an API)
○ Git Repositories,
○ Users in external System
○ CockroachDB users
○ AWS Controllers for Kubernetes (ACK)
Framework Support
● Well known frameworks
○ Operator SDK (go, from RedHat)
○ Java Operator SDK
○ Kopf (python)
○ ...
History to Java Operator SDK
● Started on ~ May 2019
● Spinoff from a project on Java based big Enterprise Company
● From ~ 2020 November heavy RedHat involvement
● Now dedicated RedHat maintiners
● https://twitter.com/maxandersen/status/1387683489877831685
● Plugin to Operator SDK to generate Java Operator SDK project
● Interesting for big enterprises building heavily on Java
Why to use it?
● Why not just creating a watch?
● Fixes typical problem independent of programming language
● It’s a (micro)framework, so you have to just think about missing pieces.
○ Usually implementing a method
● Non trivial design issues
○ Like optimistic locking of status subresource?
Concurrency
● No concurrent event processing for same Custom Resource
● Correct handling of Optimistic Locking
Automatic Retries
● Network problems?
● Essential for correctness
● Configurable retries
○ Various backoff strategies
Finalizers
● Essential for correctness
● Automatically handled
● What if operator is down?
apiVersion: "sample.javaoperatorsdk/v1"
kind: WebServer
metadata:
name: hellows
finalizers:
- webservers.sample.javaoperatorsdk/finalizer
spec:
html: |
<html>
<head>
<title>Hello Operator World</title>
</head>
<body>
Hello Meetup
</body>
</html>
...and more
● Support for Generations
● Nice API to update custom resource and/or status-subresource
● Integration with Quarkus and Spring Boot
● ...
Event Sources - Dependent Resources
Event Sources
How does it compare to Terraform
● With Terraform we provision resources managed by cloud providers
● With Operators we manage resources
○ (IMHO) But how it should be managed inside the controller implementation it’s quite
close to terraform
■ Status is state
■ Reconcile always all the resources independently from event
○ Note that some patterns are still just being explored.
Thank you!
Time for Questions!
1 von 21

Recomendados

The evolving container landscape von
The evolving container landscapeThe evolving container landscape
The evolving container landscapeNilesh Trivedi
456 views14 Folien
Cncf storage-final-filip von
Cncf storage-final-filipCncf storage-final-filip
Cncf storage-final-filipJuraj Hantak
121 views17 Folien
AWS Lambda and serverless Java | DevNation Live von
AWS Lambda and serverless Java | DevNation LiveAWS Lambda and serverless Java | DevNation Live
AWS Lambda and serverless Java | DevNation LiveRed Hat Developers
7.3K views26 Folien
16. Cncf meetup-docker von
16. Cncf meetup-docker16. Cncf meetup-docker
16. Cncf meetup-dockerJuraj Hantak
266 views16 Folien
Introduction to Kubernetes and Google Container Engine (GKE) von
Introduction to Kubernetes and Google Container Engine (GKE)Introduction to Kubernetes and Google Container Engine (GKE)
Introduction to Kubernetes and Google Container Engine (GKE)Opsta
2.7K views37 Folien
Promise of DevOps von
Promise of DevOpsPromise of DevOps
Promise of DevOpsJuraj Hantak
132 views43 Folien

Más contenido relacionado

Was ist angesagt?

Swarm migration von
Swarm migrationSwarm migration
Swarm migrationJanakiram MSV
1.2K views14 Folien
5 - Hands-on Kubernetes Workshop: von
5 - Hands-on Kubernetes Workshop:5 - Hands-on Kubernetes Workshop:
5 - Hands-on Kubernetes Workshop:Kangaroot
218 views27 Folien
State of the Container Ecosystem von
State of the Container EcosystemState of the Container Ecosystem
State of the Container EcosystemVinay Rao
601 views32 Folien
Mirantis Contributions to Kubernetes Ecosystem von
Mirantis Contributions to Kubernetes EcosystemMirantis Contributions to Kubernetes Ecosystem
Mirantis Contributions to Kubernetes EcosystemMoscowKubernetes
1.4K views15 Folien
3 - Delen Private Bank: FOSS adventures in a Cloud Native world von
3 - Delen Private Bank: FOSS adventures in a Cloud Native world3 - Delen Private Bank: FOSS adventures in a Cloud Native world
3 - Delen Private Bank: FOSS adventures in a Cloud Native worldKangaroot
397 views17 Folien
Monitoring with prometheus at scale von
Monitoring with prometheus at scaleMonitoring with prometheus at scale
Monitoring with prometheus at scaleJuraj Hantak
209 views21 Folien

Was ist angesagt?(20)

5 - Hands-on Kubernetes Workshop: von Kangaroot
5 - Hands-on Kubernetes Workshop:5 - Hands-on Kubernetes Workshop:
5 - Hands-on Kubernetes Workshop:
Kangaroot218 views
State of the Container Ecosystem von Vinay Rao
State of the Container EcosystemState of the Container Ecosystem
State of the Container Ecosystem
Vinay Rao601 views
Mirantis Contributions to Kubernetes Ecosystem von MoscowKubernetes
Mirantis Contributions to Kubernetes EcosystemMirantis Contributions to Kubernetes Ecosystem
Mirantis Contributions to Kubernetes Ecosystem
MoscowKubernetes1.4K views
3 - Delen Private Bank: FOSS adventures in a Cloud Native world von Kangaroot
3 - Delen Private Bank: FOSS adventures in a Cloud Native world3 - Delen Private Bank: FOSS adventures in a Cloud Native world
3 - Delen Private Bank: FOSS adventures in a Cloud Native world
Kangaroot397 views
Monitoring with prometheus at scale von Juraj Hantak
Monitoring with prometheus at scaleMonitoring with prometheus at scale
Monitoring with prometheus at scale
Juraj Hantak209 views
Google Cloud Platform and Kubernetes von Kasper Nissen
Google Cloud Platform and KubernetesGoogle Cloud Platform and Kubernetes
Google Cloud Platform and Kubernetes
Kasper Nissen3.5K views
Kubernetes User Group: 維運 Kubernetes 的兩三事 von smalltown
Kubernetes User Group: 維運 Kubernetes 的兩三事Kubernetes User Group: 維運 Kubernetes 的兩三事
Kubernetes User Group: 維運 Kubernetes 的兩三事
smalltown 1.4K views
Introduction of Kubernetes - Trang Nguyen von Trang Nguyen
Introduction of Kubernetes - Trang NguyenIntroduction of Kubernetes - Trang Nguyen
Introduction of Kubernetes - Trang Nguyen
Trang Nguyen490 views
Secrets management vault cncf meetup von Juraj Hantak
Secrets management vault cncf meetupSecrets management vault cncf meetup
Secrets management vault cncf meetup
Juraj Hantak154 views
What you have to know about Certified Kubernetes Administrator (CKA) von Opsta
What you have to know about Certified Kubernetes Administrator (CKA)What you have to know about Certified Kubernetes Administrator (CKA)
What you have to know about Certified Kubernetes Administrator (CKA)
Opsta3.8K views
Beyond OpenStack | OpenStack in Real Life von Opsta
Beyond OpenStack | OpenStack in Real LifeBeyond OpenStack | OpenStack in Real Life
Beyond OpenStack | OpenStack in Real Life
Opsta761 views
Designing Cloud Native Applications with Kubernetes von Bilgin Ibryam
Designing Cloud Native Applications with KubernetesDesigning Cloud Native Applications with Kubernetes
Designing Cloud Native Applications with Kubernetes
Bilgin Ibryam52.4K views
Architectural caching patterns for kubernetes von Rafał Leszko
Architectural caching patterns for kubernetesArchitectural caching patterns for kubernetes
Architectural caching patterns for kubernetes
Rafał Leszko447 views
Kubernetes Meetup: CNI, Flex Volume, and Scheduler von Katie Crimi
Kubernetes Meetup: CNI, Flex Volume, and SchedulerKubernetes Meetup: CNI, Flex Volume, and Scheduler
Kubernetes Meetup: CNI, Flex Volume, and Scheduler
Katie Crimi500 views
Kubernetes and OpenStack at Scale von Stephen Gordon
Kubernetes and OpenStack at ScaleKubernetes and OpenStack at Scale
Kubernetes and OpenStack at Scale
Stephen Gordon1.4K views
Kubernetes & Google Kubernetes Engine (GKE) von Akash Agrawal
Kubernetes & Google Kubernetes Engine (GKE)Kubernetes & Google Kubernetes Engine (GKE)
Kubernetes & Google Kubernetes Engine (GKE)
Akash Agrawal1.2K views

Similar a Intro to creating kubernetes operators

Intro to Kubernetes & GitOps Workshop von
Intro to Kubernetes & GitOps WorkshopIntro to Kubernetes & GitOps Workshop
Intro to Kubernetes & GitOps WorkshopWeaveworks
142 views56 Folien
CON6423: Scalable JavaScript applications with Project Nashorn von
CON6423: Scalable JavaScript applications with Project NashornCON6423: Scalable JavaScript applications with Project Nashorn
CON6423: Scalable JavaScript applications with Project NashornMichel Graciano
539 views45 Folien
Second Skin: Real-Time Retheming a Legacy Web Application with Diazo in the C... von
Second Skin: Real-Time Retheming a Legacy Web Application with Diazo in the C...Second Skin: Real-Time Retheming a Legacy Web Application with Diazo in the C...
Second Skin: Real-Time Retheming a Legacy Web Application with Diazo in the C...Chris Shenton
407 views21 Folien
Free GitOps Workshop + Intro to Kubernetes & GitOps von
Free GitOps Workshop + Intro to Kubernetes & GitOpsFree GitOps Workshop + Intro to Kubernetes & GitOps
Free GitOps Workshop + Intro to Kubernetes & GitOpsWeaveworks
180 views60 Folien
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes von
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with KubernetesKubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with KubernetesSeungYong Oh
903 views30 Folien
NetflixOSS Meetup season 3 episode 1 von
NetflixOSS Meetup season 3 episode 1NetflixOSS Meetup season 3 episode 1
NetflixOSS Meetup season 3 episode 1Ruslan Meshenberg
21.4K views90 Folien

Similar a Intro to creating kubernetes operators (20)

Intro to Kubernetes & GitOps Workshop von Weaveworks
Intro to Kubernetes & GitOps WorkshopIntro to Kubernetes & GitOps Workshop
Intro to Kubernetes & GitOps Workshop
Weaveworks142 views
CON6423: Scalable JavaScript applications with Project Nashorn von Michel Graciano
CON6423: Scalable JavaScript applications with Project NashornCON6423: Scalable JavaScript applications with Project Nashorn
CON6423: Scalable JavaScript applications with Project Nashorn
Michel Graciano539 views
Second Skin: Real-Time Retheming a Legacy Web Application with Diazo in the C... von Chris Shenton
Second Skin: Real-Time Retheming a Legacy Web Application with Diazo in the C...Second Skin: Real-Time Retheming a Legacy Web Application with Diazo in the C...
Second Skin: Real-Time Retheming a Legacy Web Application with Diazo in the C...
Chris Shenton407 views
Free GitOps Workshop + Intro to Kubernetes & GitOps von Weaveworks
Free GitOps Workshop + Intro to Kubernetes & GitOpsFree GitOps Workshop + Intro to Kubernetes & GitOps
Free GitOps Workshop + Intro to Kubernetes & GitOps
Weaveworks180 views
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes von SeungYong Oh
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with KubernetesKubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
SeungYong Oh903 views
NetflixOSS Meetup season 3 episode 1 von Ruslan Meshenberg
NetflixOSS Meetup season 3 episode 1NetflixOSS Meetup season 3 episode 1
NetflixOSS Meetup season 3 episode 1
Ruslan Meshenberg21.4K views
LINE's Private Cloud - Meet Cloud Native World von LINE Corporation
LINE's Private Cloud - Meet Cloud Native WorldLINE's Private Cloud - Meet Cloud Native World
LINE's Private Cloud - Meet Cloud Native World
LINE Corporation2.4K views
Node.js Web Apps @ ebay scale von Dmytro Semenov
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scale
Dmytro Semenov1.8K views
Kubernetes @ Squarespace: Kubernetes in the Datacenter von Kevin Lynch
Kubernetes @ Squarespace: Kubernetes in the DatacenterKubernetes @ Squarespace: Kubernetes in the Datacenter
Kubernetes @ Squarespace: Kubernetes in the Datacenter
Kevin Lynch1.2K views
Cloud Native Java Development Patterns von Bilgin Ibryam
Cloud Native Java Development PatternsCloud Native Java Development Patterns
Cloud Native Java Development Patterns
Bilgin Ibryam6.4K views
Red Hat Java Update and Quarkus Introduction von John Archer
Red Hat Java Update and Quarkus IntroductionRed Hat Java Update and Quarkus Introduction
Red Hat Java Update and Quarkus Introduction
John Archer687 views
Cinder Update, OpenInfra Meetup Q3 China, 2020-09-26 von Brian Rosmaita
Cinder Update, OpenInfra Meetup Q3 China, 2020-09-26Cinder Update, OpenInfra Meetup Q3 China, 2020-09-26
Cinder Update, OpenInfra Meetup Q3 China, 2020-09-26
Brian Rosmaita104 views
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423] von Leonardo Zanivan
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
JavaOne 2014 - Scalable JavaScript Applications with Project Nashorn [CON6423]
Leonardo Zanivan2.9K views
Netflix Container Scheduling and Execution - QCon New York 2016 von aspyker
Netflix Container Scheduling and Execution - QCon New York 2016Netflix Container Scheduling and Execution - QCon New York 2016
Netflix Container Scheduling and Execution - QCon New York 2016
aspyker14K views
Scheduling a fuller house - Talk at QCon NY 2016 von Sharma Podila
Scheduling a fuller house - Talk at QCon NY 2016Scheduling a fuller house - Talk at QCon NY 2016
Scheduling a fuller house - Talk at QCon NY 2016
Sharma Podila6.3K views
Reactive Amsterdam - Maxim Burgerhout - Quarkus Intro von Fabio Tiriticco
Reactive Amsterdam - Maxim Burgerhout - Quarkus IntroReactive Amsterdam - Maxim Burgerhout - Quarkus Intro
Reactive Amsterdam - Maxim Burgerhout - Quarkus Intro
Fabio Tiriticco955 views
Building a Pluggable, Cloud-native Event-driven Serverless Architecture - Rea... von Dan Farrelly
Building a Pluggable, Cloud-native Event-driven Serverless Architecture - Rea...Building a Pluggable, Cloud-native Event-driven Serverless Architecture - Rea...
Building a Pluggable, Cloud-native Event-driven Serverless Architecture - Rea...
Dan Farrelly13 views

Más de Juraj Hantak

Kubernetes day 2 @ zse energia von
Kubernetes day 2 @ zse energiaKubernetes day 2 @ zse energia
Kubernetes day 2 @ zse energiaJuraj Hantak
92 views12 Folien
Dev ops culture_final von
Dev ops culture_finalDev ops culture_final
Dev ops culture_finalJuraj Hantak
141 views11 Folien
23 meetup rancher von
23 meetup rancher23 meetup rancher
23 meetup rancherJuraj Hantak
191 views13 Folien
Integracia security do ci cd pipelines von
Integracia security do ci cd pipelinesIntegracia security do ci cd pipelines
Integracia security do ci cd pipelinesJuraj Hantak
158 views10 Folien
CNCF opa von
CNCF opaCNCF opa
CNCF opaJuraj Hantak
203 views44 Folien
Introductiontohelmcharts2021 von
Introductiontohelmcharts2021Introductiontohelmcharts2021
Introductiontohelmcharts2021Juraj Hantak
111 views26 Folien

Más de Juraj Hantak(20)

Kubernetes day 2 @ zse energia von Juraj Hantak
Kubernetes day 2 @ zse energiaKubernetes day 2 @ zse energia
Kubernetes day 2 @ zse energia
Juraj Hantak92 views
Integracia security do ci cd pipelines von Juraj Hantak
Integracia security do ci cd pipelinesIntegracia security do ci cd pipelines
Integracia security do ci cd pipelines
Juraj Hantak158 views
Introductiontohelmcharts2021 von Juraj Hantak
Introductiontohelmcharts2021Introductiontohelmcharts2021
Introductiontohelmcharts2021
Juraj Hantak111 views
19. stretnutie komunity kubernetes von Juraj Hantak
19. stretnutie komunity kubernetes19. stretnutie komunity kubernetes
19. stretnutie komunity kubernetes
Juraj Hantak99 views
16. meetup sietovy model v kubernetes von Juraj Hantak
16. meetup sietovy model v kubernetes16. meetup sietovy model v kubernetes
16. meetup sietovy model v kubernetes
Juraj Hantak118 views
Kubernetes monitoring using prometheus stack von Juraj Hantak
Kubernetes monitoring using prometheus stackKubernetes monitoring using prometheus stack
Kubernetes monitoring using prometheus stack
Juraj Hantak225 views
12.cncfsk meetup observability and analysis von Juraj Hantak
12.cncfsk meetup observability and analysis12.cncfsk meetup observability and analysis
12.cncfsk meetup observability and analysis
Juraj Hantak120 views
Nginx app protect-for-meetup-v1.0-202006_lk von Juraj Hantak
Nginx app protect-for-meetup-v1.0-202006_lkNginx app protect-for-meetup-v1.0-202006_lk
Nginx app protect-for-meetup-v1.0-202006_lk
Juraj Hantak163 views
10. th cncf meetup - Routing microservice-architectures-with-traefik-cncfsk von Juraj Hantak
10. th cncf meetup - Routing microservice-architectures-with-traefik-cncfsk10. th cncf meetup - Routing microservice-architectures-with-traefik-cncfsk
10. th cncf meetup - Routing microservice-architectures-with-traefik-cncfsk
Juraj Hantak123 views
Ingress controller present, past and future von Juraj Hantak
Ingress controller present, past and futureIngress controller present, past and future
Ingress controller present, past and future
Juraj Hantak209 views
Cncf meetup-service-mesh-sk von Juraj Hantak
Cncf meetup-service-mesh-skCncf meetup-service-mesh-sk
Cncf meetup-service-mesh-sk
Juraj Hantak187 views
Kubernetes ingress-pixelfederation von Juraj Hantak
Kubernetes ingress-pixelfederationKubernetes ingress-pixelfederation
Kubernetes ingress-pixelfederation
Juraj Hantak169 views

Último

40th TWNIC Open Policy Meeting: A quick look at QUIC von
40th TWNIC Open Policy Meeting: A quick look at QUIC40th TWNIC Open Policy Meeting: A quick look at QUIC
40th TWNIC Open Policy Meeting: A quick look at QUICAPNIC
109 views20 Folien
Penetration Testing for Cybersecurity Professionals von
Penetration Testing for Cybersecurity ProfessionalsPenetration Testing for Cybersecurity Professionals
Penetration Testing for Cybersecurity Professionals211 Check
49 views17 Folien
40th TWNIC Open Policy Meeting: APNIC PDP update von
40th TWNIC Open Policy Meeting: APNIC PDP update40th TWNIC Open Policy Meeting: APNIC PDP update
40th TWNIC Open Policy Meeting: APNIC PDP updateAPNIC
106 views20 Folien
Cracking the Code Decoding Leased Line Quotes for Connectivity Excellence.pptx von
Cracking the Code Decoding Leased Line Quotes for Connectivity Excellence.pptxCracking the Code Decoding Leased Line Quotes for Connectivity Excellence.pptx
Cracking the Code Decoding Leased Line Quotes for Connectivity Excellence.pptxLeasedLinesQuote
5 views8 Folien
Amine el bouzalimi von
Amine el bouzalimiAmine el bouzalimi
Amine el bouzalimiAmine EL BOUZALIMI
6 views38 Folien
hamro digital logics.pptx von
hamro digital logics.pptxhamro digital logics.pptx
hamro digital logics.pptxtupeshghimire
11 views36 Folien

Último(13)

40th TWNIC Open Policy Meeting: A quick look at QUIC von APNIC
40th TWNIC Open Policy Meeting: A quick look at QUIC40th TWNIC Open Policy Meeting: A quick look at QUIC
40th TWNIC Open Policy Meeting: A quick look at QUIC
APNIC109 views
Penetration Testing for Cybersecurity Professionals von 211 Check
Penetration Testing for Cybersecurity ProfessionalsPenetration Testing for Cybersecurity Professionals
Penetration Testing for Cybersecurity Professionals
211 Check49 views
40th TWNIC Open Policy Meeting: APNIC PDP update von APNIC
40th TWNIC Open Policy Meeting: APNIC PDP update40th TWNIC Open Policy Meeting: APNIC PDP update
40th TWNIC Open Policy Meeting: APNIC PDP update
APNIC106 views
Cracking the Code Decoding Leased Line Quotes for Connectivity Excellence.pptx von LeasedLinesQuote
Cracking the Code Decoding Leased Line Quotes for Connectivity Excellence.pptxCracking the Code Decoding Leased Line Quotes for Connectivity Excellence.pptx
Cracking the Code Decoding Leased Line Quotes for Connectivity Excellence.pptx
ATPMOUSE_융합2조.pptx von kts120898
ATPMOUSE_융합2조.pptxATPMOUSE_융합2조.pptx
ATPMOUSE_융합2조.pptx
kts12089835 views
WITS Deck von W.I.T.S.
WITS DeckWITS Deck
WITS Deck
W.I.T.S.36 views
40th TWNIC OPM: On LEOs (Low Earth Orbits) and Starlink Download von APNIC
40th TWNIC OPM: On LEOs (Low Earth Orbits) and Starlink Download40th TWNIC OPM: On LEOs (Low Earth Orbits) and Starlink Download
40th TWNIC OPM: On LEOs (Low Earth Orbits) and Starlink Download
APNIC112 views
The Dark Web : Hidden Services von Anshu Singh
The Dark Web : Hidden ServicesThe Dark Web : Hidden Services
The Dark Web : Hidden Services
Anshu Singh22 views
cis5-Project-11a-Harry Lai von harrylai126
cis5-Project-11a-Harry Laicis5-Project-11a-Harry Lai
cis5-Project-11a-Harry Lai
harrylai1269 views

Intro to creating kubernetes operators

  • 1. Intro to Creating Kubernetes Operators ... and what can a framework do for you
  • 2. About me ● Attila Mészáros (csviri@gmail.com) ● 10+ years Java developer / architect ● Last 3 years more on platform teams ● Currently: Senior Software Engineer @ ○ Building multi-cloud platform ○ Golang, K8S, AWS (on-prem, GCP, AZURE) (Java) + Everything around ● Free Time ○ ❤Rust❤ ○ co-creator of Java Operator SDK
  • 3. Agenda ● Intro to Kubernetes Operators ● Simple Example ● Intro To Java Operator SDK ● Common problems and how we solve them ● Event Sources and the power of operators
  • 4. Extending K8S API - CRDs ● Define Custom Type in K8S: Custom Resource Defintion ● Abstraction over a more complex domain ● Instance of our type we call Custom Resource ● “kubectl apply” this => apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: webservers.sample.javaoperatorsdk spec: group: sample.javaoperatorsdk versions: - name: v1 served: true storage: true schema: openAPIV3Schema: type: object properties: spec: type: object properties: html: type: string scope: Namespaced names: plural: webservers singular: webserver kind: WebServer shortNames: - ws
  • 5. Sample Custom Resource apiVersion: "sample.javaoperatorsdk/v1" kind: WebServer metadata: name: hellows spec: html: | <html> <head> <title>Hello Operator World</title> </head> <body> Hello Meetup </body> </html> ● simple examples: abstraction over static website
  • 6. Kubernetes Operator - Definition ● “Operators are software extensions to Kubernetes that make use of custom resources to manage applications and their components. Operators follow Kubernetes principles, notably the control loop.” ● That’s it, K8S does not provide any additional facilities. Only: ○ Extension to API - CRD/CR ○ and the operations we have on K8S Objects: CRUD, Patch, Watch ○ (ok for golang it kinda provides )
  • 7. What is a control loop?
  • 8. The Operator Pattern ● At the end it’s a Pod watching Custom Resources ● and Reconciling the desired state with the target world
  • 9. Demo Time - WebServer Example
  • 10. Managing K8S and non-K8S Resources ● Manage all well known K8S resources (pods, config maps, ingress, service, pv) ○ Create nice abstractions ○ Deploy/Manage Complex Applications (Kafka, Postgres) ○ Flux ● External Resources (or anything that has an API) ○ Git Repositories, ○ Users in external System ○ CockroachDB users ○ AWS Controllers for Kubernetes (ACK)
  • 11. Framework Support ● Well known frameworks ○ Operator SDK (go, from RedHat) ○ Java Operator SDK ○ Kopf (python) ○ ...
  • 12. History to Java Operator SDK ● Started on ~ May 2019 ● Spinoff from a project on Java based big Enterprise Company ● From ~ 2020 November heavy RedHat involvement ● Now dedicated RedHat maintiners ● https://twitter.com/maxandersen/status/1387683489877831685 ● Plugin to Operator SDK to generate Java Operator SDK project ● Interesting for big enterprises building heavily on Java
  • 13. Why to use it? ● Why not just creating a watch? ● Fixes typical problem independent of programming language ● It’s a (micro)framework, so you have to just think about missing pieces. ○ Usually implementing a method ● Non trivial design issues ○ Like optimistic locking of status subresource?
  • 14. Concurrency ● No concurrent event processing for same Custom Resource ● Correct handling of Optimistic Locking
  • 15. Automatic Retries ● Network problems? ● Essential for correctness ● Configurable retries ○ Various backoff strategies
  • 16. Finalizers ● Essential for correctness ● Automatically handled ● What if operator is down? apiVersion: "sample.javaoperatorsdk/v1" kind: WebServer metadata: name: hellows finalizers: - webservers.sample.javaoperatorsdk/finalizer spec: html: | <html> <head> <title>Hello Operator World</title> </head> <body> Hello Meetup </body> </html>
  • 17. ...and more ● Support for Generations ● Nice API to update custom resource and/or status-subresource ● Integration with Quarkus and Spring Boot ● ...
  • 18. Event Sources - Dependent Resources
  • 20. How does it compare to Terraform ● With Terraform we provision resources managed by cloud providers ● With Operators we manage resources ○ (IMHO) But how it should be managed inside the controller implementation it’s quite close to terraform ■ Status is state ■ Reconcile always all the resources independently from event ○ Note that some patterns are still just being explored.
  • 21. Thank you! Time for Questions!