Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Write an Operator to handle CRD

Kyle Bai
September 13, 2017

Write an Operator to handle CRD

Kyle Bai

September 13, 2017

Transcript

27 slides
  1. 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/
  2. 常⾒見見的 Kubernetes 應⽤用部署 • 利利⽤用 CLI 或是 Dashboard 部署指定應⽤用程式的容器⾄至 Kubernetes。

    • 撰寫⼀一些 Deployment, Services, Configmaps 等物件資源,然後將這些部 署⾄至 Kubernetes。 • 撰寫應⽤用程式的 Helm Chart,並利利⽤用 Helm 來來進⾏行行部署。 • 或是其他⼯工具等
  3. 1.假設有 Config 需要設定,我們需要先建立 ConfigMap 2.然後建立 RC 來來管理理 Pod,並在 Pod 描述

    ConfigMap 使⽤用⽅方式 3.建立 Service 來來提供 Backend Pod 能夠對外提供存取 4.建立 Frontend Pod 來來連接 Backend Pod
  4. 有狀狀態服務(Stateful Service) Database: MySQL, MongoDB Data process: Spark, Hadoop DL/ML:

    TensorFlow, Caffe2 Storage: Gluster, Ceph Logging: Elasticsearch
  5. TensorFlow on Kubernetes Step1: 包裝 Workers 與 Parameters 的程式成 Docker

    images Step2: 建立 TensorFlow 叢集需要的資訊⾄至 ConfigMap 與 Persistent Volume Step3: 定義叢集的 Deployment 與 Service 等等來來執⾏行行於 Kubernetes 中
  6. CustomResourceDefinitions(CRD) CustomResourceDefinition(CRD) 是 v1.7+ 版本新加入的 Kubernetes API 擴 展機制,⽬目標是無需修改核⼼心程式碼就能對 Kubernetes

    進⾏行行擴展,⽽而 CRD 更更是 ThirdPartyResources(TPR) 的升級版。 • 使⽤用⾃自定義物件進⾏行行擴展 Kubernetes API. • CRDs 能夠沿⽤用熟係的 UX ⼯工具,ex: kubectl. • 能夠與 Controllers 進⾏行行結合. • ⽀支援 SubResources(v1.10+).
  7. Step 1: 設計 API types(1/2) • TypeMeta 與 ObjectMeta 是

    Kubernetes 基本資源屬性,如 .metadata.name 等。 • Spec 定義⾃自⼰己資源的屬性內容。 • Status 反應⽬目前資源狀狀態資訊。
  8. 幾個設計原則 • 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
  9. Refers • code-generator • crd-code-generation • apiextensions-apiserver • sample-apiserver •

    sample-controller • apimachinery • apiserver-builder/example • kube-openapi • service-catalog

More Decks by Kyle Bai

Other Decks in Technology