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
68
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
Transcript
27 slides
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
More Decks by Kyle Bai
See All by Kyle Bai
讓 Jenkins 老爺爺掌舵帶領開發者航向美好新世界
kairen
1
360
AWS Startup 2020 - AMIS
kairen
0
120
學習 Kubernetes 不是為了成為 YAML Engineer
kairen
0
450
How to make your container:Kubernetes is a bit more secure
kairen
0
250
Vishwakarma: Terraform modules for deploying EKS and Self-hosting Kubernetes(AWS))
kairen
0
140
Vishwakarma: Terraform modules for deploying EKS and Self-hosting Kubernetes
kairen
0
150
Chatbot as a Service on Container(Kubernetes)
kairen
0
1.2k
IT IRONMAN 2020
kairen
0
130
Advanced Kubernetes For UMC
kairen
0
210
Other Decks in Technology
See All in Technology
AIフレンドリーなGenerative UIをJSXで
uhyo
2
350
認知負荷の減らし方 ~開発にも日常業務にも活かせるノウハウ~
minorun365
PRO
17
12k
認知の質も文化醸成も。数年取り組んで見えてきた技術広報のKPI設計 / Tech PR KPIs: Lessons on Awareness Quality and Culture After Several Years
bitkey
PRO
0
230
データから見る AI時代のエンジニア転職と採用
junya_okura
4
1.4k
競馬予想をAIでやってみた話
yoshimura_datam
0
110
さようならSSH鍵、こんにちはゼロトラスト ― AIフレンドリーで快適な自宅鯖SSH
atalie2m
14
7.6k
AWS re:Invent 2026 FSI Pre-Event Networking Night
junjikoide
0
280
デザインシステムのフィードバックループをほぼ自動化した話
tongari07
0
640
AIエージェントのアーキテクチャ設計
nsatoh
0
570
フロントエンドのテストカバレッジは 100%強制がいい
bengo4com
7
3k
Kiro のリモートワークスペース: IDE は手元のままで、ワークスペースをクラウド、コンテナ、自前のマシンに置く
inariku
PRO
2
220
ワークフローからハーネスへ — Web フレームワークの作者たちが AI エージェントに向かう理由
azukiazusa1
4
2.5k
Featured
See All Featured
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.3k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
Docker and Python
trallard
47
4.3k
The Cost Of JavaScript in 2023
addyosmani
56
10k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
570
How STYLIGHT went responsive
nonsquared
100
6.4k
Embracing the Ebb and Flow
colly
88
5.2k
sira's awesome portfolio website redesign presentation
elsirapls
0
530
Optimising Largest Contentful Paint
csswizardry
37
4k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.8k