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
Write an Operator to handle CRD
Search
Kyle Bai
September 13, 2017
Technology
0
54
Write an Operator to handle CRD
Kyle Bai
September 13, 2017
Tweet
Share
More Decks by Kyle Bai
See All by Kyle Bai
讓 Jenkins 老爺爺掌舵帶領開發者航向美好新世界
kairen
1
210
AWS Startup 2020 - AMIS
kairen
0
68
學習 Kubernetes 不是為了成為 YAML Engineer
kairen
0
310
How to make your container:Kubernetes is a bit more secure
kairen
0
180
Vishwakarma: Terraform modules for deploying EKS and Self-hosting Kubernetes(AWS))
kairen
0
88
Vishwakarma: Terraform modules for deploying EKS and Self-hosting Kubernetes
kairen
0
92
Chatbot as a Service on Container(Kubernetes)
kairen
0
910
IT IRONMAN 2020
kairen
0
79
Advanced Kubernetes For UMC
kairen
0
150
Other Decks in Technology
See All in Technology
[VPoE Global Summit] サービスレベル目標による信頼性への投資最適化
satos
0
250
もう外には出ない。より快適なフルリモート環境を目指して
mottyzzz
13
10k
可観測性は開発環境から、開発環境にもオブザーバビリティ導入のススメ
layerx
PRO
0
310
GraphRAG グラフDBを使ったLLM生成(自作漫画DBを用いた具体例を用いて)
seaturt1e
1
150
CNCFの視点で捉えるPlatform Engineering - 最新動向と展望 / Platform Engineering from the CNCF Perspective
hhiroshell
0
140
オブザーバビリティと育てた ID管理・認証認可基盤の歩み / The Journey of an ID Management, Authentication, and Authorization Platform Nurtured with Observability
kaminashi
1
690
ハノーファーメッセ2025で見た生成AI活用ユースケース.pdf
hamadakoji
1
470
ヘンリー会社紹介資料(エンジニア向け) / company deck for engineer
henryofficial
0
390
事業開発におけるDify活用事例
kentarofujii
5
1.5k
あなたの知らない Linuxカーネル脆弱性の世界
recruitengineers
PRO
3
160
QA業務を変える(!?)AIを併用した不具合分析の実践
ma2ri
0
140
Linux カーネルが支えるコンテナの仕組み / LF Japan Community Days 2025 Osaka
tenforward
1
130
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
38
2.9k
Facilitating Awesome Meetings
lara
57
6.6k
GraphQLとの向き合い方2022年版
quramy
49
14k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
4 Signs Your Business is Dying
shpigford
185
22k
How GitHub (no longer) Works
holman
315
140k
Speed Design
sergeychernyshev
32
1.2k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.7k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
30
2.9k
Visualization
eitanlees
149
16k
What's in a price? How to price your products and services
michaelherold
246
12k
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