Slide 1

Slide 1 text

Kyle bai R&D @ inwinSTACK www.inwinstack.com An Introduction to Kubernetes and CNI

Slide 2

Slide 2 text

Job R&D @ inwinSTACK Description 早期在校主要撰寫 java 與 objc 程式語⾔言,並專注於 iOS Mobile 應⽤用程式開發,具備四年年開發經驗。次要研讀 Hadoop 與 Spark 資料運算框架,以及 Linux 相關技術。 研所與⼯工作期間則專注於 OpenStack、Ceph 與 Kubernetes 等雲原⽣生相關技術開源專案,閒暇之餘會參參加 相關專案社區及貢獻,並利利⽤用部落落格、GitHub 與 GitBook 進⾏行行筆記記錄。 Drink Coffee Good! Phone #7727 Love Buttocks kairen([email protected]) https://kairen.github.io/ About Me Kyle Bai

Slide 3

Slide 3 text

Kubernetes 47% Containers remain the top emerging technology of interest to users. Among those currently deploying container orchestration or platform services on OpenStack, 47% are using Kubernetes. Why Kubernetes? Kubernetes and CNI Run custom application on Kubernetes How to contribute to Kubernetes Agenda Today I will talk about

Slide 4

Slide 4 text

Why Kubernetes?

Slide 5

Slide 5 text

Virtualization

Slide 6

Slide 6 text

Docker 基於 Linux Kernel 的 cgroup, namespace,以及 Union FS 等 技術,對處理理程式進⾏行行封裝隔離。 屬於作業系統層虛擬化。

Slide 7

Slide 7 text

Problems with standalone Docker 在單個 Docker 主機上運作的⼀一組 Container 應⽤用程式叢集,會受到單點 故障問題(SPOF)影響。

Slide 8

Slide 8 text

Kubernetes Kubernetes 是 Google 開源的容器(Container)分散式管理理系統,是 Google Brog ⼗十幾年年以來來⼤大規模應⽤用容器技術的經驗累積和昇華的⼀一個 重要成果,是建於 Container(OCI容器標準)之上的容器叢集排程系統, 簡稱為K8s( )。 為 CNCF(Cloud Native Computing Foundation) 專案之⼀一。 Stars 25,830+ Commits 52,905+ Contributors 1,331+

Slide 9

Slide 9 text

CNCF Landscape

Slide 10

Slide 10 text

CNCF Members

Slide 11

Slide 11 text

Container Management Platforms Preferences

Slide 12

Slide 12 text

Kubernetes Pros 資源監控 Monitoring 滾動升級 Rolling-update ⾼高可靠性 High-availability ⾃自我修復 Self-healing 雲端⽀支援 Cloud Provider 持久性儲存 Persistent Volumes 組態檔案 Configmap 安全性 Secret Kubernetes 管理理跨區域與主機的容器節點,提供基本部署、維運、管 理理,以及執⾏行行各項應⽤用程式,並具備多種特性。

Slide 13

Slide 13 text

Microservices Kubernetes 架構設計非常適合在微服務(Microservices)軟體架構,透 過多個容器(Container)與負載平衡等來來組成系統。

Slide 14

Slide 14 text

Kubernetes Distributions

Slide 15

Slide 15 text

Kubernetes Architecture

Slide 16

Slide 16 text

Kubernetes Architecture Kubernetes 屬於分散式架構系統,主要由兩兩種節點⾓角⾊色組成: • Masters – 主要⼯工作為提供 API 與管理理⼯工作節點,可視為主節點。 • Nodes(Minions) – 主要執⾏行行容器應⽤用的節點,上⾯面會執⾏行行許多容 器。

Slide 17

Slide 17 text

Kubernetes Master Kubernetes Master 包含了了四個基本組件: • Etcd: 主要為 Kubernetes 的資訊儲存 與服務發現功能。 • API Server:以 REST APIs 介⾯面⽅方式提 供所有業務邏輯CURD操作。 • Controller Manager Server:所有其他 叢集級功能都是透過控制管理理器 (Controller Manager)來來操作。 • Scheduler:負責整個分散式系統的資源 排程。

Slide 18

Slide 18 text

Kubernetes Nodes Kubernetes Node 包含了了三個基本組件: • Kubelet:與 API 溝通,並負責管理理的 映像檔、容器與資料 Volume等操作。 也是連接 Master 的橋樑。 • Kube-proxy: 為了了解決外部網路路能夠 群曲跨機器叢集中容器提供的應⽤用服務 ⽽而設計,⽀支援 L4 的 Load Balancer。 • Container engine: 基於 OCI Container Runtime 來來執⾏行行應⽤用程式容 器實例例。

Slide 19

Slide 19 text

API driven • 通過 API 完成節點之間溝通 • 明確定義與規範 API • 使⽤用 gRPC 進⾏行行 Remote Procedure Call • 可擴展的 API • CRD(Custom Resource Definitions) • Custom Schedulers • API aggregation layer https://blog.openshift.com/kubernetes-deep-dive-api-server-part-1/

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

YAML file to define resource Example resource:

Slide 22

Slide 22 text

Built on standards(plugins) Kubernetes 的容器引擎、網路路與儲存都是透過標準化的規範來來進⾏行行實作,開發者與 供應商只需要依據規範的介⾯面進⾏行行開發對應功能,就能夠與 Kubernetes 進⾏行行整合。

Slide 23

Slide 23 text

Container Runtime Interface CRI 是 Kubernetes 社區提出的規範,由於隨著不同的容器引擎推成出新,Kubernetes 已不在只是管理理 Docker 的容器,CRI 將 Kubernetes 與具體容器實現進⾏行行解耦,來來增加 Kubernetes 的擴展。

Slide 24

Slide 24 text

Container Storage Interface CRI 專案⽬目前正處於初期階段,但⽬目前有多家儲存⼤大廠已經加入已加速 規範,這將是儲存與容器能否成功的關鍵。

Slide 25

Slide 25 text

Container Network Interface CNI 是 CNCF 容器網路路規範,更更是 Kubernetes 網路路插件基礎。其思想為在 Container Runtime 建立時,並建立 network namespace,之後呼叫 CNI 插件 來來設定 netns 網路路,最後提供給容器使⽤用。

Slide 26

Slide 26 text

How to write CNI plugin CNI 插件主要實做兩兩個部份: • CNI Plugins:管理理容器網路路設定,主要有兩兩個基礎介⾯面, AddNetwork 與 DelNetwork。

Slide 27

Slide 27 text

CNI call look like?

Slide 28

Slide 28 text

CNI config look like?

Slide 29

Slide 29 text

Network plugin calls IPAM plugin • IPAM(IP Address Management) Plugin:負責分配 IP 給容器,主要 實做如 host-local 與 DHCP 等。

Slide 30

Slide 30 text

Kubernetes Pod Pod 是 K8s 中最⼩小的部署單位資源,可以將⼀一個或多個容器組成⼀一個 Pod,Pod 所包含的容器只會運⾏行行在同⼀一個 Host 上,並共享 network namespaces、IP port,每個 Pod 的 network mapping 都是由 container pause 所封裝處理理的。

Slide 31

Slide 31 text

Kubernetes Deployments Deployments 是部署 Pod 群組的抽象資源,其會確保 K8s 系統中指定數 量量副本的 Pod 存活於叢集, 也可以利利⽤用 Label 及 Rolling update 來來進⾏行行 副本的擴展或更更新。

Slide 32

Slide 32 text

Kubernetes Service Service 是 Pod 服務的抽象資源,具有簡單負載平衡的功能,由於 Pod 的數量量與IP 不會固定,可將⼀一群 Pod 指派成 Service 並給予⼀一個固定IP (cluster IP),service 會將請求⾄至 cluster IP 的流量量導入其對應 pod。

Slide 33

Slide 33 text

Kubernetes Resources

Slide 34

Slide 34 text

Run custom application on Kubernetes

Slide 35

Slide 35 text

TensorFlow on Kubernetes https://github.com/kairen/workshop413

Slide 36

Slide 36 text

Ethereum on Kubernetes https://github.com/kairen/kubereum

Slide 37

Slide 37 text

Spark on Kubernetes https://github.com/kubernetes/examples/tree/master/staging/spark

Slide 38

Slide 38 text

OpenStack on Kubernetes Deploy and manage OpenStack on Kubernetes: https://github.com/openstack/openstack-helm

Slide 39

Slide 39 text

How to contribute to Kubernetes

Slide 40

Slide 40 text

Kubernetes Community Contribution Kubernetes 可以以多種⽅方式來來進⾏行行社區貢獻: • 回報程式碼 Bug 與提交問題。 • 修改 Bug、問題或是功能實現。 • 新增或修改官⽅方檔案。 • 協助使⽤用者解決遇到的問題。 • 參參加 Special Interest Groups 會議。 https://github.com/kubernetes/community/blob/master/contributors/devel/community-expectations.md

Slide 41

Slide 41 text

Contribute Git Workflow

Slide 42

Slide 42 text

Speed up PR merge 若若想要加快 PR 被 merge 的話,可以透過以下⽅方式來來達成: • 透過⼩小的 Commit 來來將不同功能程式拆分到不同 Commit 或 PR 中,來來⽅方便便檢閱。 • 對於 PR 與邏輯進⾏行行更更多說明。 • 開發程式碼遵守約束,如 Coding Conventions、API Conventions 和 kubectl Conventions。 • 確認修改部分能夠跑過本地單元與功能等測試。 • 利利⽤用 k8s-ci-robot 指令設定正確的標籤與重新失敗測試。

Slide 43

Slide 43 text

台中場 時間:
 11/14(⼆二) 09:30-16:30 
 地點:
 台中科技⼤大學
 資訊館2801室
 
 ⾼高雄場 時間:
 11/21(⼆二) 09:30-16:30 
 地點:
 中⼭山⼤大學
 國際研究⼤大樓樓1樓樓 IR1002
 
 活動免費入場 Kubernetes「容企新航向」巡迴論壇
 台中場/⾼高雄場 —洞洞悉容器新趨勢,開創企業IT新未來來 https://goo.gl/DMGevJ

Slide 44

Slide 44 text

Call for speaker https://goo.gl/HjwikA

Slide 45

Slide 45 text

45 有任何問題與想法,可以⼀一起討論唷。 Thank You!!