Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Write an Operator to handle CRD
Search
Kyle Bai
September 13, 2017
Technology
66
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Write an Operator to handle CRD
Kyle Bai
September 13, 2017
More Decks by Kyle Bai
See All by Kyle Bai
讓 Jenkins 老爺爺掌舵帶領開發者航向美好新世界
kairen
1
330
AWS Startup 2020 - AMIS
kairen
0
110
學習 Kubernetes 不是為了成為 YAML Engineer
kairen
0
410
How to make your container:Kubernetes is a bit more secure
kairen
0
240
Vishwakarma: Terraform modules for deploying EKS and Self-hosting Kubernetes(AWS))
kairen
0
130
Vishwakarma: Terraform modules for deploying EKS and Self-hosting Kubernetes
kairen
0
150
Chatbot as a Service on Container(Kubernetes)
kairen
0
1.1k
IT IRONMAN 2020
kairen
0
130
Advanced Kubernetes For UMC
kairen
0
210
Other Decks in Technology
See All in Technology
AIカンパニーへの転換を支えた、エンジニアの仕事の再定義
kworkdev
PRO
2
1.2k
AIにシークレットを見せない、WSL2で安全な開発環境
yazm
0
300
Rustuna: Rustによる高速なOptuna実装
pfn
PRO
0
190
ソフトウェア ファクトリー - 再現性のあるソフトウェアの工場づくり / Software factory
iktakahiro
6
4.9k
Optunaの最新リリースv5.0について
pfn
PRO
0
120
しろおびから始める!ログ活用の第一歩
shumei_ito
0
950
エンタメ企業のM&Aを支えるデータ基盤 ― 統合から店舗のリアルタイム分析まで / Data Engineering Summit 2026
genda
0
180
Metadata - Section 1: HTML Basics
mohab1
0
120
Local CI × GitHub Actions
gogutan
2
200
"優秀な誰か"の下位互換にならないために
yut0naga1_fa
1
1.8k
go-sqletch
moznion
0
140
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
110
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
55
13k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.3k
HDC tutorial
michielstock
2
960
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
Thoughts on Productivity
jonyablonski
76
5.4k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
600
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Transcript
Write an Operator to handle CRD SDN x Cloud Native
#2
About Me Kyle Bai • Interested in emerging technologies. •
COSCUP, Kubernetes Day and OpenStack Day Speaker • OpenStack and Kubernetes Projects Contributor(100+ PR) • Certified Kubernetes Administrator @kairen(
[email protected]
) https://kairen.github.io/
常⾒見見的 Kubernetes 應⽤用部署 • 利利⽤用 CLI 或是 Dashboard 部署指定應⽤用程式的容器⾄至 Kubernetes。
• 撰寫⼀一些 Deployment, Services, Configmaps 等物件資源,然後將這些部 署⾄至 Kubernetes。 • 撰寫應⽤用程式的 Helm Chart,並利利⽤用 Helm 來來進⾏行行部署。 • 或是其他⼯工具等
1.假設有 Config 需要設定,我們需要先建立 ConfigMap 2.然後建立 RC 來來管理理 Pod,並在 Pod 描述
ConfigMap 使⽤用⽅方式 3.建立 Service 來來提供 Backend Pod 能夠對外提供存取 4.建立 Frontend Pod 來來連接 Backend Pod
1.設計與開發 Helm Chart 2.安裝 Helm 到⾃自⼰己 Kubernetes 3.利利⽤用 Helm 來來部署
Chart ⾄至 Kubernetes
有狀狀態服務(Stateful Service) Database: MySQL, MongoDB Data process: Spark, Hadoop DL/ML:
TensorFlow, Caffe2 Storage: Gluster, Ceph Logging: Elasticsearch
TensorFlow on Kubernetes Step1: 包裝 Workers 與 Parameters 的程式成 Docker
images Step2: 建立 TensorFlow 叢集需要的資訊⾄至 ConfigMap 與 Persistent Volume Step3: 定義叢集的 Deployment 與 Service 等等來來執⾏行行於 Kubernetes 中
https://github.com/tensorflow/k8s TensorFlow Kubernetes Operator
Operator Operator 是 CoreOS 開發的框 架,⽬目標是簡化複雜有狀狀態應⽤用 的管理理,它能夠達到應⽤用程式的 狀狀態事件變化,並利利⽤用控制器來來 透過擴展的 Kubernetes
API 進⾏行行 ⾃自動建立、管理理與配置應⽤用程式 容器實例例。 Applications
Operator Pattern
• Reflector: Watch API,監聽指定資 源下的事件。 • Lister: List/Get Method。 •
Informer: 資源變更更通知與輪輪詢。
None
None
CustomResourceDefinitions(CRD) CustomResourceDefinition(CRD) 是 v1.7+ 版本新加入的 Kubernetes API 擴 展機制,⽬目標是無需修改核⼼心程式碼就能對 Kubernetes
進⾏行行擴展,⽽而 CRD 更更是 ThirdPartyResources(TPR) 的升級版。 • 使⽤用⾃自定義物件進⾏行行擴展 Kubernetes API. • CRDs 能夠沿⽤用熟係的 UX ⼯工具,ex: kubectl. • 能夠與 Controllers 進⾏行行結合. • ⽀支援 SubResources(v1.10+).
CRD Example(1/2)
CRD Example(2/2)
Add operator to handle events
Step 1: 設計 API types(1/2) • TypeMeta 與 ObjectMeta 是
Kubernetes 基本資源屬性,如 .metadata.name 等。 • Spec 定義⾃自⼰己資源的屬性內容。 • Status 反應⽬目前資源狀狀態資訊。
Step 2: 註冊 API 當設計好 API types 結構後,需要將要使⽤用資源物件加入⾄至 apimachinery 的
Runtime schema 中。
Step 3: 產⽣生 Client code(1/2) 當註冊完成後,利利⽤用 k8s.io/code- generator 來來產⽣生指定 API
的 Clientset 來來便便利利存取該 API 的資源物件。
Step 3: 產⽣生 Client code(2/2)
Step 4: 透過 Client 建立 CRD 資源
Step 5: 註冊事件 最後註冊事件來來進⾏行行監聽資源變化,分析變化狀狀態來來進⾏行行對應事情。
Demo https://github.com/kairen/simple-operator
幾個設計原則 • Operators should not be too big • Operators
should have single responsibilities • Operators should keep simple and maintainable • Complex Cluster should be managed by a group of interacting micro- operators • Use Deployment to deploy operators
Refers • code-generator • crd-code-generation • apiextensions-apiserver • sample-apiserver •
sample-controller • apimachinery • apiserver-builder/example • kube-openapi • service-catalog
Thanks